Skip to content

Commit ffc26be

Browse files
committed
Simplify build.py for Rust
This commit attempts to simplify a bit Rust builds. In essence it derives the channel to use depending on the WASI version. This make the invocation a bit more uniform across other language builders.
1 parent 1ff3c4f commit ffc26be

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

.github/workflows/compile-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Build tests
6767
working-directory: tests/rust
6868
run: |
69-
./build.py --toolchain=wasm32-wasip3:nightly
69+
./build.py
7070
7171
- name: 'Tar files'
7272
if: matrix.os == 'ubuntu-latest'

doc/writing-tests.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ rustup +nightly target add wasm32-wasip2 # for wasip3
9696
Note that until wasip3 is released, we use the wasip2 toolchain for
9797
wasip3.
9898

99-
Now you can run `build.py`. For Rust, run as `./build.py
100-
--toolchain=wasm32-wasip3:nightly`, so as to use the nightly channel
101-
instead of the default stable, for wasip3.
99+
Now you can run `build.py`. For Rust, the build script will
100+
automatically derive the right channel to use depending on the WASI
101+
version.
102102

103103
## Final notes
104104

tests/rust/build.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,10 @@
1515
help="print commands to be executed")
1616
parser.add_argument("--release", action="store_true",
1717
help="build tests in release mode")
18-
parser.add_argument("--toolchain", action="append",
19-
help="TARGET:TOOLCHAIN, pass +TOOLCHAIN to cargo for TARGET")
20-
2118
args = parser.parse_args()
2219
if args.dry_run:
2320
args.verbose = True
2421

25-
TOOLCHAINS={}
26-
if args.toolchain is not None:
27-
for toolchain_arg in args.toolchain:
28-
match toolchain_arg.split(':'):
29-
case (target, toolchain):
30-
TOOLCHAINS[target] = toolchain
31-
case arg:
32-
print(f"expected --toolchain=TARGET:TOOLCHAIN, got {toolchain_arg}",
33-
file=sys.stderr)
34-
sys.exit(1)
35-
3622
CARGO = ['cargo']
3723
SYSTEMS = ['wasm32']
3824
VERSIONS = ['wasip1', 'wasip3']
@@ -46,6 +32,14 @@ def compute_build_target(system, version):
4632
return compute_target(system, 'wasip2')
4733
return compute_target(system, version)
4834

35+
def compute_channel_for_version(version):
36+
# At the time of writing, the nightly channel is
37+
# needed in order to make everything work with
38+
# WASI p3
39+
if version == 'wasip3':
40+
return "+nightly"
41+
return "+stable"
42+
4943
BASE_DIR = Path(__file__).parent
5044

5145
def run(argv):
@@ -105,9 +99,9 @@ def mkdir_p(path):
10599
target = compute_target(system, version)
106100
build_target = compute_build_target(system, version)
107101
build_mode = "release" if args.release else "debug"
108-
toolchain = [f"+{TOOLCHAINS[target]}"] if target in TOOLCHAINS else []
102+
channel = compute_channel_for_version(version)
109103

110-
build_args = CARGO + toolchain + [
104+
build_args = CARGO + [channel] + [
111105
"build",
112106
f"--manifest-path={BASE_DIR / target / 'Cargo.toml'}",
113107
f"--target={build_target}"

0 commit comments

Comments
 (0)