Skip to content

Commit 3ac525d

Browse files
authored
feat: make ada-rust compile for wasm32-wasi and -unknown (#23)
* Make ada-rust compile for wasm32-wasi and -unknown This adds ability to compile for wasm32-wasi and wasm32-unknown-unknown targets. Both of those use WASI SDK for compilation and add necessary flags for linking C++ library. WASI SDK is a bit more straightforward, while wasm32-unknown-unknown requires a few hacks to get a pure Wasm output w/o any imports, but it works too. While changing flags in build.rs, also leveraged some new `cc` options and made it possible to compile on Windows via Clang instead of MSVC if user chooses to do so. * Fix Windows CI * Add wasm32-wasi matrix item * Remove separate test job Already included in the check job.
1 parent 85e7424 commit 3ac525d

File tree

5 files changed

+110
-253
lines changed

5 files changed

+110
-253
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,32 @@ concurrency:
1616
cancel-in-progress: ${{ github.ref_name != 'main' }}
1717

1818
jobs:
19-
check:
20-
name: Check
19+
test:
20+
name: Check & Test
2121
strategy:
2222
fail-fast: false
2323
matrix:
2424
include:
2525
- os: windows-latest
2626
- os: ubuntu-latest
2727
- os: macos-latest
28+
- os: ubuntu-latest
29+
env:
30+
CARGO_BUILD_TARGET: wasm32-wasi
31+
CARGO_TARGET_WASM32_WASI_RUNNER: /home/runner/.wasmtime/bin/wasmtime --dir=.
2832
runs-on: ${{ matrix.os }}
33+
env: ${{ matrix.env || fromJSON('{}') }}
2934
steps:
3035
- uses: actions/checkout@v3
3136

37+
- name: Install Wasm deps
38+
if: matrix.env.CARGO_BUILD_TARGET == 'wasm32-wasi'
39+
run: |
40+
rustup target add wasm32-wasi
41+
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk_20.0_amd64.deb
42+
sudo dpkg --install wasi-sdk_20.0_amd64.deb
43+
curl https://wasmtime.dev/install.sh -sSf | bash
44+
3245
- uses: Swatinem/rust-cache@v2
3346
with:
3447
shared-key: ci
@@ -37,10 +50,10 @@ jobs:
3750
- run: rustup show
3851

3952
- name: Cargo Check
40-
shell: bash
41-
run: |
42-
cargo check --all-targets --all-features --locked
43-
cargo test --no-run --all-targets --all-features
53+
run: cargo check --all-targets --all-features --locked
54+
55+
- name: Cargo Test
56+
run: cargo test --all-targets --all-features
4457

4558
format:
4659
name: Format
@@ -66,25 +79,3 @@ jobs:
6679
- run: rustup show
6780

6881
- run: cargo clippy -- -D warnings
69-
70-
test:
71-
name: Test
72-
strategy:
73-
fail-fast: false
74-
matrix:
75-
include:
76-
- os: windows-latest
77-
- os: ubuntu-latest
78-
- os: macos-latest
79-
runs-on: ${{ matrix.os }}
80-
steps:
81-
- uses: actions/checkout@v3
82-
83-
- uses: Swatinem/rust-cache@v2
84-
with:
85-
shared-key: ci
86-
save-if: false
87-
88-
- run: rustup show
89-
90-
- run: cargo test

Cargo.lock

Lines changed: 2 additions & 213 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ thiserror = "1"
3232
serde = { version = "1.0", optional = true, features = ["derive"] }
3333

3434
[dev-dependencies]
35-
criterion = "0.5"
35+
criterion = { version = "0.5", default-features = false, features = ["cargo_bench_support"] }
3636
url = "2" # Used by benchmarks
3737
serde = { version = "1.0", features = ["derive"] }
3838
serde_json = "1.0"
3939

4040
[build-dependencies]
41-
cc = { version = "1.0", features = ["parallel"] }
41+
cc = { version = "1.0.83", features = ["parallel"] }
4242
link_args = "0.6"
4343

4444
[package.metadata.docs.rs]

0 commit comments

Comments
 (0)