Skip to content

Commit

Permalink
Merge pull request #19 from jhelwig/build-updates-and-readme
Browse files Browse the repository at this point in the history
Build update & add README
  • Loading branch information
jhelwig authored Jul 8, 2018
2 parents 078d10f + ee99891 commit a4c8863
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ install:
build_script:
- ps: cd ui; yarn install; cd ..
- ps: cd ui; yarn run build; cd ..
- cargo build --verbose --all
- cargo build --verbose --all --release
- ps: $env:YARN_PATH = (Get-Command cmd).Path
- ps: cmd /c 'cargo build --verbose --all 2>&1'
- ps: cmd /c 'cargo build --verbose --all --release 2>&1'
test_script:
- cargo test --verbose --all
- ps: cmd /c 'cargo test --verbose --all 2>&1'
artifacts:
- path: target/release/sd2snes-lttp-rando-tracker.exe
name: Release build
Expand Down
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# sd2snes-lttp-rando-tracker

[![Travis CI Build Status](https://travis-ci.com/jhelwig/sd2snes-lttp-rando-tracker.svg?branch=master)](https://travis-ci.com/jhelwig/sd2snes-lttp-rando-tracker)
[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/jhelwig/sd2snes-lttp-rando-tracker?branch=master&svg=true)](https://ci.appveyor.com/project/jhelwig/sd2snes-lttp-rando-tracker)

## About

sd2snes-lttp-rando-tracker can be used to automatically track collected items in
[The Legend of Zelda: A Link to the Past Randomizer](https://alttpr.com), when
using an SD2SNES with the [USB2SNES](https://github.com/RedGuyyyy/sd2snes/releases)
firmware. sd2snes-lttp-rando-tracker will periodically poll the SD2SNES over the
USB serial connection to track the retrieved item states.

sd2snes-lttp-rando-tracker is supported on macOS, Windows, and Linux.

## Usage

Pre-compiled binaries are available from the [releases listing](https://github.com/jhelwig/sd2snes-lttp-rando-tracker/releases). Download the
binary, and put it in the location of your choosing.

### macOS & Linux

```Shell
sd2snes-rando-tracker --serial /path/to/sd2snes/serial/device
```

`/path/to/sd2snes/serial/device` will probably be something like `/dev/tty.usbmodem<sequence of numbers>`.

### Windows

Open the terminal of your choosing, and change directory to where you downloaded
the binary.

```Shell
sd2snes-rando-tracker.exe --serial COM<number>
```

`COM<number>` should be the COM device that the SD2SNES creates on your system.
This can be found via Device Manager.

### General

After starting sd2snes-rando-tracker, it will let you know what address & port
the UI HTTP server was started on. By default, the HTTP server binds to all
addresses on port 8000. Open `http://localhost:8000` in your browser to view the
UI. If you wish to only view the item/dungeon tracker, or the map, you can go to
`http://localhost:8000/#/items` and `http://localhost:8000/#/map`, respectively.
These limited views can be handy for use with things like the browser capture in
OBS Studio.

Additional help is available via the `--help` flag. You can use `--file <file>`
to test things using the `example-data.json` file in the repository, if you do
not have a SD2SNES with the USB2SNES firmware available (very handy for
developing while away from a SNES).

## Not yet implemented

* Calculate map location availability based on retrieved items.
* Persist item collection state during save & quit. Items re-appear once save is
loaded.

## Acknowledgements

The UI is heavily modeled after, and uses assets from [pickfifteen/lttp-tracker](https://github.com/pickfifteen/lttp-tracker/) under the MIT license.

## Development

### Requirements

* Nightly Rust compiler. Recommend using [`rustup`](https://rustup.rs/)
* Node.js & Yarn

### Running in development

#### UI

The Vue.js UI is under the `ui` directory, and can be served during development
by running `yarn start`, after running `yarn install` to install all
dependencies.

#### CLI & API server

The main entry point for building the project is via running `cargo build` from
the root of the project. By default, this will also build the UI, but this can
be skipped in development by setting the `SKIP_UI_BUILD` environment variable to
have any value. This can be useful when running the UI separately via `yarn`.

There is an `example-data.json` in the root of the project that can be useful
when doing development while away from a SNES.

```Shell
cargo run -- --file example-data.json
```
34 changes: 34 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
extern crate includedir_codegen;

use includedir_codegen::Compression;
use std::process::Command;

fn main() {
build_ui_files();
package_ui_files();
}

fn build_ui_files() {
if let Ok(_) = std::env::var("SKIP_UI_BUILD") {
return;
}

let ui_dir = match std::env::current_dir() {
Ok(mut d) => {
d.push("ui");
d
},
Err(e) => panic!("Could not get current directory: {}", e),
};

let yarn_command = match std::env::var("YARN_PATH") {
Ok(c) => c,
_ => "yarn".to_string(),
};
println!("yarn command: {}", &yarn_command);
let ui_build_status = Command::new(yarn_command)
.arg("build")
.current_dir(ui_dir)
.status()
.expect("Failed to build UI");
if !ui_build_status.success() {
panic!("Could not build UI");
}
}

fn package_ui_files() {
includedir_codegen::start("UI_FILES")
.dir("ui/dist", Compression::Gzip)
.build("ui_files.rs")
Expand Down

0 comments on commit a4c8863

Please sign in to comment.