Skip to content

Commit

Permalink
feat(rust)!: build wasip2 by default
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Nov 7, 2024
1 parent fd9fbf5 commit 3a6ef92
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- package: rust-hello-wasm32-unknown-unknown
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm

- package: rust-hello-wasm32-wasip1
- package: rust-hello-wasm32-wasip2
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
test-oci: docker load < ./result

Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-s390x ./result/bin/rust-hello
test-oci: docker load < ./result

- package: rust-hello-debug-wasm32-wasip1
- package: rust-hello-debug-wasm32-wasip2
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
test-oci: docker load < ./result

Expand Down Expand Up @@ -265,7 +265,7 @@ jobs:
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

- package: rust-complex-wasm32-wasip1
- package: rust-complex-wasm32-wasip2
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

Expand Down Expand Up @@ -330,7 +330,7 @@ jobs:
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

- package: rust-complex-debug-wasm32-wasip1
- package: rust-complex-debug-wasm32-wasip2
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

Expand Down Expand Up @@ -399,7 +399,7 @@ jobs:
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

- package: rust-complex-wasm32-wasip1
- package: rust-complex-wasm32-wasip2
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

Expand Down Expand Up @@ -447,7 +447,7 @@ jobs:
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

- package: rust-complex-debug-wasm32-wasip1
- package: rust-complex-debug-wasm32-wasip2
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/foo.wasm
suffix: .wasm

Expand Down
10 changes: 5 additions & 5 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ in
assert flakes.rust.complex.checks.${system} ? doctest;
assert flakes.rust.complex.packages.${system} ? default;
assert flakes.rust.hello-multibin.packages.${system} ? default;
assert flakes.rust.hello-multibin.packages.${system} ? rust-hello-multibin-wasm32-wasip1;
assert flakes.rust.hello-multibin.packages.${system} ? rust-hello-multibin-wasm32-wasip2;
assert flakes.rust.hello.packages.${system} ? default;
assert flakes.rust.hello.packages.${system} ? rust-hello-wasm32-wasip1-oci;
assert flakes.rust.hello.packages.${system} ? rust-hello-wasm32-wasip1;
assert flakes.rust.lib.packages.${system} ? rust-lib-wasm32-wasip1;
assert flakes.rust.hello.packages.${system} ? rust-hello-wasm32-wasip2-oci;
assert flakes.rust.hello.packages.${system} ? rust-hello-wasm32-wasip2;
assert flakes.rust.lib.packages.${system} ? rust-lib-wasm32-wasip2;
assert flakes.rust.workspace.packages.${system} ? default;
assert flakes.rust.workspace.packages.${system} ? rust-workspace-wasm32-wasip1;
assert flakes.rust.workspace.packages.${system} ? rust-workspace-wasm32-wasip2;
(assertRustPackages flakes.rust.complex.packages "rust-complex")
(assertRustPackages flakes.rust.hello-multibin.packages "rust-hello-multibin")
(assertRustPackages flakes.rust.hello.packages "rust-hello")
Expand Down
1 change: 1 addition & 0 deletions lib/rust/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ in {
targets.s390x-unknown-linux-musl = "s390x-unknown-linux-musl";
targets.wasm32-unknown-unknown = "wasm32-unknown-unknown";
targets.wasm32-wasip1 = "wasm32-wasip1";
targets.wasm32-wasip2 = "wasm32-wasip2";
targets.x86_64-apple-darwin = "x86_64-apple-darwin";
targets.x86_64-apple-ios = "x86_64-apple-ios";
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 @@ -85,7 +85,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-unknown-unknown || target == wasm32-wasip1
else if target == wasm32-unknown-unknown || target == wasm32-wasip1 || target == wasm32-wasip2
then pkgs.pkgsCross.wasi32
else
import (
Expand Down
8 changes: 7 additions & 1 deletion lib/rust/mkAttrs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ with self.lib.rust.targets;
then {
CARGO_TARGET_WASM32_WASIP1_RUNNER = "wasmtime run -C cache=n";
}
else if target == wasm32-wasip2
then {
CARGO_TARGET_WASM32_WASIP2_RUNNER = "wasmtime run -C cache=n";
}
else if target == x86_64-unknown-linux-gnu
then
{
Expand Down Expand Up @@ -647,7 +651,8 @@ with self.lib.rust.targets;
default.${s390x-unknown-linux-gnu} = true;
default.${s390x-unknown-linux-musl} = false;
default.${wasm32-unknown-unknown} = true;
default.${wasm32-wasip1} = true;
default.${wasm32-wasip1} = false;
default.${wasm32-wasip2} = true;
default.${x86_64-apple-darwin} = true;
default.${x86_64-apple-ios} = false;
default.${x86_64-pc-windows-gnu} = true;
Expand Down Expand Up @@ -729,6 +734,7 @@ with self.lib.rust.targets;
ociArchitecture.${armv7-unknown-linux-musleabihf} = "arm";
ociArchitecture.${wasm32-unknown-unknown} = "wasm";
ociArchitecture.${wasm32-wasip1} = "wasm";
ociArchitecture.${wasm32-wasip2} = "wasm";
ociArchitecture.${x86_64-apple-darwin} = "amd64";
ociArchitecture.${x86_64-pc-windows-gnu} = "amd64";
ociArchitecture.${x86_64-unknown-linux-gnu} = "amd64";
Expand Down

0 comments on commit 3a6ef92

Please sign in to comment.