Skip to content

Commit

Permalink
Merge pull request #120 from stadiamaps/wasm-js-initial-support
Browse files Browse the repository at this point in the history
Initial pass at supporting wasm32-unknown-unknown in a web browser
  • Loading branch information
ianthetechie authored Jun 24, 2024
2 parents a00df59 + f2a23f0 commit ea359dd
Show file tree
Hide file tree
Showing 21 changed files with 1,136 additions and 983 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
manifest-path: common/Cargo.toml
feature-group: default-features

rustfmt:
runs-on: macos-14
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/wasm-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: WASM (JS)
on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always

jobs:
msrv:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with:
tool: cargo-hack
- run: >-
cargo hack check --rust-version --workspace --all-targets
--ignore-private
working-directory: common
build:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Cargo Build
run: cargo build --verbose --lib --target wasm32-unknown-unknown --no-default-features --features wasm_js
working-directory: common
# TODO: Figure out a strategy for running unit tests; probably requires a web browser for time and randomness...
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,19 @@ Before pushing, run the following in the `common` folder:

1. Run `cargo fmt` to automatically format any new rust code.
2. Run `cargo insta review` to update snapshot testing changes.
3. Run `cargo test` to validate testing and ensure snapshot changes were correctly applied by step 2.
3. Run `cargo test` to validate testing and ensure snapshot changes were correctly applied by step 2.

#### WASM

We support `wasm32-unknown-unknown` for use in a JavaScript environment.
That last qualifier is important, as we currently depend on being able to get the system time in several places.
This comes through crates that rely on a JS environment.

You can build the wasm module like so:

```shell
cargo build --lib --release --target wasm32-unknown-unknown --no-default-features --features wasm_js
```

### iOS

Expand Down
Loading

0 comments on commit ea359dd

Please sign in to comment.