Rudimentary multi-file shit
parent
6ba61b891a
commit
c9661a5858
@ -0,0 +1,2 @@
|
||||
intermediate.wat
|
||||
output.wasmu
|
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
INTERMEDIATE=intermediate.wat
|
||||
|
||||
read -r -d '' PREAMBLE <<'EOF'
|
||||
(module $main
|
||||
(import "wasi_unstable" "proc_exit" (func $proc_exit (param i32)))
|
||||
|
||||
(memory (export "memory") 10)
|
||||
|
||||
EOF
|
||||
|
||||
read -r -d '' EPILOGUE <<'EOF'
|
||||
)
|
||||
EOF
|
||||
|
||||
# clear file
|
||||
> $INTERMEDIATE
|
||||
trap "err=$?; rm $INTERMEDIATE; exit $err" EXIT
|
||||
|
||||
# generate file
|
||||
echo "$PREAMBLE" >> $INTERMEDIATE
|
||||
find ./src | grep -e '\.wat$' | xargs cat | sed 's/^./ &/'>> $INTERMEDIATE
|
||||
echo "$EPILOGUE" >> $INTERMEDIATE
|
||||
|
||||
# test file
|
||||
wasmer inspect $INTERMEDIATE
|
||||
wasmer compile -o ./output.wasmu $INTERMEDIATE
|
@ -1,12 +0,0 @@
|
||||
(module
|
||||
(import "wasi_unstable" "proc_exit" (func $proc_exit (param i32)))
|
||||
|
||||
(memory (export "memory") 10)
|
||||
|
||||
(func (export "_start") (result i32)
|
||||
i32.const 0
|
||||
call $proc_exit
|
||||
|
||||
unreachable
|
||||
)
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
(func $start (export "_start") (result i32)
|
||||
i32.const 5
|
||||
i32.const 4
|
||||
call $test
|
||||
|
||||
call $proc_exit
|
||||
|
||||
unreachable
|
||||
)
|
||||
|
||||
(func $test (param $a i32) (param $b i32) (result i32)
|
||||
local.get $a
|
||||
local.get $b
|
||||
i32.add
|
||||
)
|
Loading…
Reference in New Issue