Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions script/build_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import contextlib
import os
import pathlib
import shutil
import subprocess
import typing

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


for name in [p.name for p in pathlib.Path('example').iterdir() if p.is_dir()]:
root = os.path.dirname(os.path.dirname(__file__))
os.chdir(root)

for name in os.listdir('example'):
if not os.path.isdir(f'example/{name}'):
continue
if os.path.exists(f'example/{name}/bin/{name}.wasm'):
continue
with cd(f'example/{name}'):
if not os.path.exists('bin'):
call('mkdir bin')
os.mkdir('bin')
call('cargo build --release')
if os.path.exists('target/wasm32-unknown-unknown'):
call(f'cp target/wasm32-unknown-unknown/release/{name}.wasm bin')
shutil.copy(f'target/wasm32-unknown-unknown/release/{name}.wasm', 'bin')
if os.path.exists('target/wasm32-wasip1'):
call(f'cp target/wasm32-wasip1/release/{name}.wasm bin')
call(f'wasm2wat -o bin/{name}.wat bin/{name}.wasm')
shutil.copy(f'target/wasm32-wasip1/release/{name}.wasm', 'bin')
call(f'{root}/res/wabt/bin/wasm2wat -o bin/{name}.wat bin/{name}.wasm')
7 changes: 5 additions & 2 deletions script/build_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def cd(dst: str) -> typing.Generator[None, typing.Any, None]:
os.chdir(cwd)


root = os.path.dirname(os.path.dirname(__file__))
os.chdir(root)

with cd('res'):
if not os.path.exists('spec'):
call('git clone https://github.com/WebAssembly/spec')
Expand All @@ -29,7 +32,7 @@ def cd(dst: str) -> typing.Generator[None, typing.Any, None]:
call('git checkout fffc6e12fa454e475455a7b58d3b5dc343980c10')
with cd('res/spec/test/core'):
for e in sorted(glob.glob('*.wast')):
call(f'wast2json {e}')
call(f'{root}/res/wabt/bin/wast2json {e}')
with cd('res/spec/test/core/simd'):
for e in sorted(glob.glob('*.wast')):
call(f'wast2json {e}')
call(f'{root}/res/wabt/bin/wast2json {e}')
Loading