Files
wasm2elf-mb/justfile
2026-11-21 01:03:32 -08:00

46 lines
1.2 KiB
Makefile

exe := "_build/native/debug/build/cmd/main/main.exe"
# list recipes
default:
@just --list
# build the compiler
build:
moon build --target native
# type-check only
check:
moon check
# compile examples/<name>.wat to out/<name> (a static ELF)
compile name: build
mkdir -p out
wasm-tools parse examples/{{name}}.wat -o out/{{name}}.wasm
wasm-tools validate out/{{name}}.wasm
{{exe}} out/{{name}}.wasm out/{{name}}
# compile and run one example
run name: (compile name)
-./out/{{name}}; echo "exit code: $?"
# compile a wasi:cli component example (examples/<name>.wat + examples/wit, world <name>) to out/<name>
component name: build
mkdir -p out
wasm-tools component embed examples/wit examples/{{name}}.wat --world {{name}} -o out/{{name}}.embed.wasm
wasm-tools component new out/{{name}}.embed.wasm -o out/{{name}}.wasm
wasm-tools validate out/{{name}}.wasm
{{exe}} out/{{name}}.wasm out/{{name}}
# compile and run a wasi:cli component example
run-component name: (component name)
-./out/{{name}}; echo "exit code: $?"
# build and run every example
examples: build
./run_examples.sh
# remove build output
clean:
moon clean
rm -rf out