Skip to content

Commit

Permalink
feat(rust): add support for wasm32-unknown-unknown
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Jul 19, 2023
1 parent 5fe7823 commit 174765c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
package: rust-hello-armv7-unknown-linux-musleabihf
test-bin: file ./result/bin/rust-hello

- os: macos-12
package: rust-hello-wasm32-unknown-unknown
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm

- os: macos-12
package: rust-hello-wasm32-wasi
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
Expand Down Expand Up @@ -102,6 +106,10 @@ jobs:
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/rust-hello
test-oci: docker load < ./result

- os: ubuntu-22.04
package: rust-hello-wasm32-unknown-unknown
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm

- os: ubuntu-22.04
package: rust-hello-wasm32-wasi
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
Expand Down
1 change: 1 addition & 0 deletions lib/rust/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ in {
targets.aarch64-unknown-linux-gnu = "aarch64-unknown-linux-gnu";
targets.aarch64-unknown-linux-musl = "aarch64-unknown-linux-musl";
targets.armv7-unknown-linux-musleabihf = "armv7-unknown-linux-musleabihf";
targets.wasm32-unknown-unknown = "wasm32-unknown-unknown";
targets.wasm32-wasi = "wasm32-wasi";
targets.x86_64-apple-darwin = "x86_64-apple-darwin";
targets.x86_64-pc-windows-gnu = "x86_64-pc-windows-gnu";
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/defaultPkgsFor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ with self.lib.rust.targets;
then pkgs.pkgsCross.gnu64
else if target == x86_64-unknown-linux-musl
then pkgs.pkgsCross.musl64
else if target == wasm32-wasi
else if target == wasm32-unknown-unknown || target == wasm32-wasi
then pkgs.pkgsCross.wasi32
else
import nixpkgs {
Expand Down
5 changes: 5 additions & 0 deletions lib/rust/mkAttrs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ with self.lib.rust.targets;
// optionalAttrs final.stdenv.buildPlatform.isDarwin {
doCheck = warn "testing not currently supported when cross-compiling for `${target}` on Darwin" false;
}
else if target == wasm32-unknown-unknown
then {
doCheck = warn "testing not currently supported when cross-compiling for `${target}`" false;
}
else if target == wasm32-wasi
then {
CARGO_TARGET_WASM32_WASI_RUNNER = "wasmtime --disable-cache";
Expand Down Expand Up @@ -416,6 +420,7 @@ with self.lib.rust.targets;
default.${aarch64-unknown-linux-gnu} = true;
default.${aarch64-unknown-linux-musl} = true;
default.${armv7-unknown-linux-musleabihf} = true;
default.${wasm32-unknown-unknown} = true;
default.${wasm32-wasi} = true;
default.${x86_64-apple-darwin} = prev.stdenv.buildPlatform.isDarwin && prev.stdenv.buildPlatform.isx86_64;
default.${x86_64-pc-windows-gnu} = true;
Expand Down

0 comments on commit 174765c

Please sign in to comment.