Skip to content

Commit

Permalink
Implement Native WASM Support
Browse files Browse the repository at this point in the history
A lot of crates are polyfilled in the platform module. Most of the
polyfills work more or less correctly. Go to issue #96 for more
information.
  • Loading branch information
CryZe committed Jan 28, 2018
1 parent 4bc82c7 commit 9e1e559
Show file tree
Hide file tree
Showing 64 changed files with 2,490 additions and 104 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ capi/target
capi/Cargo.lock
capi/bindings
capi/bind_gen/target
capi/js/livesplit.js
capi/js/livesplit_core.wasm
capi/js/node/livesplit_core.js
capi/js/node/index.js
capi/js/node/README.md
emscripten/target
emscripten/Cargo.lock
js/livesplit.js
js/node/livesplit_core.js
js/node/index.js
js/node/README.md
Cargo.lock
**.rs.bk
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,31 @@ matrix:
# - env: TARGET=thumbv7m-none-eab
# - env: TARGET=thumbv7em-none-eabihf

# emscripten
# Web
- env: TARGET=asmjs-unknown-emscripten
rust: nightly
- env: TARGET=wasm32-unknown-emscripten
rust: nightly
- env: TARGET=wasm32-unknown-unknown
rust: nightly

# Linux
- env: TARGET=i686-unknown-linux-gnu
- env: TARGET=i686-unknown-linux-musl
- env: TARGET=i686-unknown-linux-musl NO_DYLIB=1
- env: TARGET=x86_64-unknown-linux-gnu
- env: TARGET=x86_64-unknown-linux-musl
- env: TARGET=x86_64-unknown-linux-musl NO_DYLIB=1
- env: TARGET=i586-unknown-linux-gnu

# iOS
- env: TARGET=aarch64-apple-ios DISABLE_TESTS=1
- env: TARGET=aarch64-apple-ios DISABLE_TESTS=1 NO_DYLIB=1
os: osx
- env: TARGET=armv7-apple-ios DISABLE_TESTS=1
- env: TARGET=armv7-apple-ios DISABLE_TESTS=1 NO_DYLIB=1
os: osx
- env: TARGET=armv7s-apple-ios DISABLE_TESTS=1
- env: TARGET=armv7s-apple-ios DISABLE_TESTS=1 NO_DYLIB=1
os: osx
- env: TARGET=i386-apple-ios DISABLE_TESTS=1
- env: TARGET=i386-apple-ios DISABLE_TESTS=1 NO_DYLIB=1
os: osx
- env: TARGET=x86_64-apple-ios DISABLE_TESTS=1
- env: TARGET=x86_64-apple-ios DISABLE_TESTS=1 NO_DYLIB=1
os: osx

# Android
Expand Down Expand Up @@ -121,7 +123,7 @@ deploy:
file_glob: true
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
on:
condition: $TRAVIS_RUST_VERSION == 'stable' || $TARGET = 'asmjs-unknown-emscripten' || $TARGET == 'wasm32-unknown-emscripten'
condition: $TRAVIS_RUST_VERSION == 'stable' || $TARGET = 'asmjs-unknown-emscripten' || $TARGET == 'wasm32-unknown-emscripten' || $TARGET == 'wasm32-unknown-unknown'
tags: true
provider: releases
skip_cleanup: true
Expand Down
18 changes: 13 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lto = true
panic = "abort"

[workspace]
members = ["capi", "capi/bind_gen", "js"]
members = ["capi", "capi/bind_gen", "capi/js", "capi/staticlib", "capi/cdylib"]

[[bench]]
name = "balanced_pb"
Expand All @@ -37,18 +37,26 @@ name = "parsing"
[dependencies]
base64 = "0.9.0"
byteorder = "1.2.1"
chrono = { version = "0.4.0", features = ["serde"] }
derive_more = "0.7.0"
image = "0.18.0"
livesplit-hotkey = { path = "hotkey", version = "0.3.0" }
odds = { version = "0.3.1", features = ["std-vec"] }
ordered-float = "0.5.0"
ordermap = "0.3.2"
palette = "0.2.1"
parking_lot = "0.5.3"
quick-error = "1.2.0"
quick-xml = "0.11.0"
serde = "1.0.24"
serde_derive = "1.0.24"
serde_json = "1.0.8"
unicase = "2.1.0"

[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
# Blocked by chrono's time dependency
# https://github.com/chronotope/chrono/pull/137
chrono = { version = "0.4.0", features = ["serde"] }
# Blocked by rand 0.4.0 not being used yet and rustc-serialize being broken
# https://github.com/rust-lang-deprecated/rustc-serialize/pull/190
image = "0.18.0"
# Same as image
palette = "0.2.1"
# Blocked by rand 0.4.0 not being used yet
parking_lot = "0.5.3"
9 changes: 6 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ install:
test_script:
# we don't run the "test phase" when doing deploys
- if [%APPVEYOR_REPO_TAG%]==[false] (
cargo build -p livesplit-core-capi --target %TARGET% &&
cargo build -p livesplit-core-capi --target %TARGET% --release &&
cargo build -p staticlib --target %TARGET% &&
cargo build -p cdylib --target %TARGET% &&
cargo build -p staticlib --target %TARGET% --release &&
cargo build -p cdylib --target %TARGET% --release &&
cargo test -p livesplit-core --target %TARGET% &&
cargo test -p livesplit-core --target %TARGET% --release
)

before_deploy:
- cargo rustc -p livesplit-core-capi --target %TARGET% --release
- cargo rustc -p staticlib --target %TARGET% --release
- cargo rustc -p cdylib --target %TARGET% --release
- ps: ci\before_deploy.ps1

deploy:
Expand Down
6 changes: 1 addition & 5 deletions capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ version = "0.8.1"
authors = ["Christopher Serr <christopher.serr@gmail.com>"]

[dependencies]
livesplit-core = { path = ".." }
libc = "0.2.18"

[lib]
crate-type = ["rlib", "cdylib", "staticlib"]
livesplit-core = { path = ".." }
14 changes: 14 additions & 0 deletions capi/bind_gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod python;
mod ruby;
mod swift;
mod typescript;
mod wasm;

use structopt::StructOpt;
use std::path::Path;
Expand Down Expand Up @@ -277,6 +278,19 @@ fn write_files(classes: &BTreeMap<String, Class>, opt: &Opt) -> Result<()> {
}
path.pop();

path.push("wasm");
create_dir_all(&path)?;
{
path.push("livesplit_core.js");
wasm::write(BufWriter::new(File::create(&path)?), classes, false)?;
path.pop();

path.push("livesplit_core.ts");
wasm::write(BufWriter::new(File::create(&path)?), classes, true)?;
path.pop();
}
path.pop();

path.push("LiveSplitCore.cs");
csharp::write(BufWriter::new(File::create(&path)?), classes)?;
path.pop();
Expand Down
Loading

0 comments on commit 9e1e559

Please sign in to comment.