-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathwasm-micro-runtime.py
More file actions
executable file
·54 lines (37 loc) · 1.23 KB
/
wasm-micro-runtime.py
File metadata and controls
executable file
·54 lines (37 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import subprocess
import os
import shlex
import sys
from pathlib import Path
from typing import Dict, List, Tuple
import importlib
# shlex.split() splits according to shell quoting rules
IWASM = shlex.split(os.getenv("IWASM", "iwasm"))
def get_name() -> str:
return "wamr"
def get_version() -> str:
# ensure no args when version is queried
result = subprocess.run(IWASM + ["--version"],
encoding="UTF-8", capture_output=True,
check=True)
output = result.stdout.splitlines()[0].split(" ")
return output[1]
def get_wasi_versions() -> List[str]:
return ["wasm32-wasip1"]
def get_wasi_worlds() -> List[str]:
return ["wasi:cli/command"]
def compute_argv(test_path: str,
args_env_dirs: Tuple[List[str], Dict[str, str], List[Tuple[Path, str]]],
proposals: List[str],
wasi_world: str,
wasi_version: str) -> List[str]:
argv = []
argv += IWASM
args, env, dirs = args_env_dirs
for k, v in env.items():
argv += ["--env", f"{k}={v}"]
for host, guest in dirs:
argv += ["--map-dir", f"{host}::{guest}"] # noqa: E231
argv += [test_path]
argv += args
return argv