MVP #1

Merged
jbwdevries merged 73 commits from idea_crc32 into master 2022-08-21 12:59:21 +00:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit 6b717dba0b - Show all commits

View File

@ -19,7 +19,7 @@ server:
python3.8 -m http.server python3.8 -m http.server
test: venv/.done test: venv/.done
venv/bin/pytest tests $(TEST_FLAGS) WAT2WASM=$(WAT2WASM) venv/bin/pytest tests $(TEST_FLAGS)
lint: venv/.done lint: venv/.done
venv/bin/pylint py2wasm venv/bin/pylint py2wasm

View File

@ -1,6 +1,8 @@
import io import io
import os
import subprocess import subprocess
import sys import sys
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from pywasm import binary from pywasm import binary
@ -9,14 +11,16 @@ from pywasm import Runtime
from py2wasm.utils import process from py2wasm.utils import process
def wat2wasm(code_wat): def wat2wasm(code_wat):
path = os.environ.get('WAT2WASM', 'wat2wasm')
with NamedTemporaryFile('w+t') as input_fp: with NamedTemporaryFile('w+t') as input_fp:
input_fp.write(code_wat) input_fp.write(code_wat)
input_fp.flush() input_fp.flush()
with NamedTemporaryFile('w+b') as output_fp: with NamedTemporaryFile('w+b') as output_fp:
result = subprocess.run( subprocess.run(
[ [
'wat2wasm', path,
input_fp.name, input_fp.name,
'-o', '-o',
output_fp.name, output_fp.name,