Skip to content

Commit

Permalink
test: add building reactor, rework Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
G4Vi committed Feb 21, 2024
1 parent c5b1a6b commit be09cf1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
34 changes: 23 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
WASICC?=$(WASI_SDK_PATH)/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot
WASM_INSTR_API_KEY=?

WASM_INSTR_API_KEY?=
.NOTINTERMEDIATE:
.PHONY: test
test:
cargo run --example=basic test/test.c.instr.wasm "Test"
cargo run --example=many test/test.c.instr.wasm "Test"

C_MODULES := $(wildcard test/*.c)
RS_MODULES := $(wildcard test/*.rs)
instrument:
@for file in $(C_MODULES); do \
$(WASICC) -o $$file.wasm $$file; \
curl -F wasm=@$$file.wasm https://compiler-preview.dylibso.com/instrument -X POST -H "Authorization: Bearer $(WASM_INSTR_API_KEY)" > $$file.instr.wasm; \
done
@for file in $(RS_MODULES); do \
rustc $$file --target=wasm32-wasi -C opt-level=3 -C debuginfo=0 -o $$file.wasm; \
curl -F wasm=@$$file.wasm https://compiler-preview.dylibso.com/instrument -X POST -H "Authorization: Bearer $(WASM_INSTR_API_KEY)" > $$file.instr.wasm; \
done
ALL_MODULES := $(C_MODULES) $(RS_MODULES)
ALL_MODULES_INSTR_WASM := $(addsuffix .instr.wasm, $(ALL_MODULES))

test/reactor-%.c.wasm: test/reactor-%.c
$(WASICC) -mexec-model=reactor -o $@ $^

test/%.c.wasm: test/%.c
$(WASICC) -o $@ $^

test/%.rs.wasm: test/%.rs
rustc $^ --target=wasm32-wasi -C opt-level=3 -C debuginfo=0 -o $@

test/%.instr.wasm: test/%.wasm
curl -F wasm=@$^ https://compiler-preview.dylibso.com/instrument -X POST -H "Authorization: Bearer $(WASM_INSTR_API_KEY)" > $@

.PHONY: instrument
instrument: $(ALL_MODULES_INSTR_WASM)

.PHONY: clean
clean:
rm -f test/*.wasm
2 changes: 2 additions & 0 deletions test/reactor-hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <stdio.h>
void hello(void) { printf("hello world\n"); }
Binary file added test/reactor-hello.c.instr.wasm
Binary file not shown.
Binary file added test/reactor-hello.c.wasm
Binary file not shown.

0 comments on commit be09cf1

Please sign in to comment.