Skip to content

Commit ec0c92a

Browse files
committed
Using the local wabt toolchain
1 parent bd1fbdd commit ec0c92a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

script/build_example.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import contextlib
22
import os
3-
import pathlib
3+
import shutil
44
import subprocess
55
import typing
66

@@ -18,15 +18,20 @@ def cd(dst: str) -> typing.Generator[None, typing.Any, None]:
1818
os.chdir(cwd)
1919

2020

21-
for name in [p.name for p in pathlib.Path('example').iterdir() if p.is_dir()]:
21+
root = os.path.dirname(os.path.dirname(__file__))
22+
os.chdir(root)
23+
24+
for name in os.listdir('example'):
25+
if not os.path.isdir(f'example/{name}'):
26+
continue
2227
if os.path.exists(f'example/{name}/bin/{name}.wasm'):
2328
continue
2429
with cd(f'example/{name}'):
2530
if not os.path.exists('bin'):
26-
call('mkdir bin')
31+
os.mkdir('bin')
2732
call('cargo build --release')
2833
if os.path.exists('target/wasm32-unknown-unknown'):
29-
call(f'cp target/wasm32-unknown-unknown/release/{name}.wasm bin')
34+
shutil.copy(f'target/wasm32-unknown-unknown/release/{name}.wasm', 'bin')
3035
if os.path.exists('target/wasm32-wasip1'):
31-
call(f'cp target/wasm32-wasip1/release/{name}.wasm bin')
32-
call(f'wasm2wat -o bin/{name}.wat bin/{name}.wasm')
36+
shutil.copy(f'target/wasm32-wasip1/release/{name}.wasm', 'bin')
37+
call(f'{root}/res/wabt/bin/wasm2wat -o bin/{name}.wat bin/{name}.wasm')

script/build_spec.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def cd(dst: str) -> typing.Generator[None, typing.Any, None]:
1818
os.chdir(cwd)
1919

2020

21+
root = os.path.dirname(os.path.dirname(__file__))
22+
os.chdir(root)
23+
2124
with cd('res'):
2225
if not os.path.exists('spec'):
2326
call('git clone https://github.com/WebAssembly/spec')
@@ -29,7 +32,7 @@ def cd(dst: str) -> typing.Generator[None, typing.Any, None]:
2932
call('git checkout fffc6e12fa454e475455a7b58d3b5dc343980c10')
3033
with cd('res/spec/test/core'):
3134
for e in sorted(glob.glob('*.wast')):
32-
call(f'wast2json {e}')
35+
call(f'{root}/res/wabt/bin/wast2json {e}')
3336
with cd('res/spec/test/core/simd'):
3437
for e in sorted(glob.glob('*.wast')):
35-
call(f'wast2json {e}')
38+
call(f'{root}/res/wabt/bin/wast2json {e}')

0 commit comments

Comments
 (0)