summaryrefslogtreecommitdiffstats
path: root/third_party/rust/lucet-wasi-wasmsbx/examples/Makefile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/lucet-wasi-wasmsbx/examples/Makefile
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/lucet-wasi-wasmsbx/examples/Makefile')
-rw-r--r--third_party/rust/lucet-wasi-wasmsbx/examples/Makefile54
1 files changed, 54 insertions, 0 deletions
diff --git a/third_party/rust/lucet-wasi-wasmsbx/examples/Makefile b/third_party/rust/lucet-wasi-wasmsbx/examples/Makefile
new file mode 100644
index 0000000000..bbca5518ab
--- /dev/null
+++ b/third_party/rust/lucet-wasi-wasmsbx/examples/Makefile
@@ -0,0 +1,54 @@
+WASI_CC ?= /opt/wasi-sdk/bin/clang
+WASI_LD ?= /opt/wasi-sdk/bin/wasm-ld
+
+default: run-hello
+
+.PHONY: run-hello
+run-hello: build/hello.so
+ cargo run -p lucet-wasi -- ./build/hello.so
+
+.PHONY: run-hello-all
+run-hello-all: run-hello
+ cargo run -p lucet-wasi -- ./build/hello.so -- "makefile user"
+ GREETING="goodbye" cargo run -p lucet-wasi -- ./build/hello.so -- "makefile user"
+
+build/hello.so: build/hello.wasm ../bindings.json
+ cargo run -p lucetc -- $< --bindings ../bindings.json -o $@
+
+build/hello.wasm: hello.c
+ mkdir -p build
+ $(WASI_CC) $< -o $@
+
+build/hello.wat: build/hello.wasm
+ wasm2wat -f $< > $@
+
+.PHONY: run-pseudoquine
+run-pseudoquine: build/pseudoquine.so
+ cargo run -p lucet-wasi -- ./build/pseudoquine.so --dir "$(CURDIR):/examples"
+
+build/pseudoquine.so: build/pseudoquine.wasm ../bindings.json
+ cargo run -p lucetc -- $< --bindings ../bindings.json -o $@
+
+build/pseudoquine.wasm: pseudoquine.c
+ mkdir -p build
+ $(WASI_CC) $< -o $@
+
+build/pseudoquine.wat: build/pseudoquine.wasm
+ wasm2wat -f $< > $@
+
+.PHONY: run-kgt
+run-kgt: build/kgt.so
+ cargo run -p lucet-wasi -- ./build/kgt.so -- -l bnf -e rrutf8 < build/kgt/examples/expr.bnf
+
+build/kgt.so: build/kgt/build/bin/kgt ../bindings.json
+ cargo run -p lucetc -- $< --bindings ../bindings.json -o $@
+
+build/kgt/build/bin/kgt: build/kgt
+ NOSTRIP=1 CC=$(WASI_CC) LD=$(WASI_LD) pmake -C build/kgt -r all
+
+build/kgt:
+ git clone --recursive https://github.com/katef/kgt.git build/kgt
+
+.PHONY: clean
+clean:
+ @rm -rf build