Skip to content

Commit 2bf54bc

Browse files
authored
Merge pull request #163 from wingo/wasmtime-adapter-version
Wasmtime adapter adds appropriate args according to wasi version
2 parents 4665b67 + c41ba0b commit 2bf54bc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

adapters/wasmtime.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,22 @@ def compute_argv(test_path: str,
3737
argv += ["--dir", f"{host}::{guest}"] # noqa: E231
3838
argv += [test_path]
3939
argv += args
40+
_add_wasi_version_options(argv, wasi_version)
4041
return argv
42+
43+
44+
# The user might provide WASMTIME="wasmtime --option -Sfoo". Let's
45+
# insert the options to choose the WASI version before the user's
46+
# options, so that the user can override our choices.
47+
def _add_wasi_version_options(argv: List[str], wasi_version: str) -> None:
48+
splice_pos = len(WASMTIME)
49+
while splice_pos > 1 and args[splice_pos-1].startswith("-"):
50+
splice_pos -= 1
51+
match wasi_version:
52+
case "wasm32-wasip1":
53+
pass
54+
case "wasm32-wasip3":
55+
argv[splice_pos:splice_pos] = ["-Wcomponent-model-async",
56+
"-Sp3,http"]
57+
case _:
58+
pass

0 commit comments

Comments
 (0)