-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (74 loc) · 4.67 KB
/
Copy pathMakefile
File metadata and controls
101 lines (74 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Firebird WASM Build System
# Builds all WASM fixtures from source
.PHONY: all clean build-rust build-go build-wat test bench help
help: ## Show this help
@echo "🔥 Firebird Build System"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
all: build-rust build-go build-wat ## Build all WASM fixtures
# ── Rust targets ──────────────────────────────────────────────
build-rust: fixtures/rust_math.wasm fixtures/rust_algorithms.wasm fixtures/rust_float.wasm fixtures/rust_wasi.wasm ## Build Rust WASM modules
fixtures/rust_math.wasm: fixtures/rust_math_src/src/lib.rs fixtures/rust_math_src/Cargo.toml
cd fixtures/rust_math_src && cargo build --target wasm32-unknown-unknown --release
cp fixtures/rust_math_src/target/wasm32-unknown-unknown/release/rust_math.wasm $@
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
fixtures/rust_algorithms.wasm: fixtures/rust_algorithms/src/lib.rs fixtures/rust_algorithms/Cargo.toml
cd fixtures/rust_algorithms && cargo build --target wasm32-unknown-unknown --release
cp fixtures/rust_algorithms/target/wasm32-unknown-unknown/release/algorithms.wasm $@
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
fixtures/rust_float.wasm: fixtures/rust_float/src/lib.rs fixtures/rust_float/Cargo.toml
cd fixtures/rust_float && cargo build --target wasm32-unknown-unknown --release
cp fixtures/rust_float/target/wasm32-unknown-unknown/release/float_math.wasm $@
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
fixtures/rust_wasi.wasm: fixtures/rust_wasi/src/main.rs fixtures/rust_wasi/Cargo.toml
cd fixtures/rust_wasi && cargo build --target wasm32-wasip1 --release
cp fixtures/rust_wasi/target/wasm32-wasip1/release/wasi_demo.wasm $@
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
# ── Go targets ────────────────────────────────────────────────
build-go: fixtures/go_math.wasm fixtures/go_algorithms.wasm fixtures/go_bitwise.wasm ## Build Go WASM modules (requires TinyGo)
fixtures/go_math.wasm: fixtures/go_math/main.go
cd fixtures/go_math && tinygo build -o ../go_math.wasm -target wasi -no-debug main.go
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
fixtures/go_algorithms.wasm: fixtures/go_algorithms/main.go
cd fixtures/go_algorithms && tinygo build -o ../go_algorithms.wasm -target wasi -no-debug main.go
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
fixtures/go_bitwise.wasm: fixtures/go_bitwise/main.go
cd fixtures/go_bitwise && tinygo build -o ../go_bitwise.wasm -target wasi -no-debug main.go
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
# ── WAT targets ───────────────────────────────────────────────
build-wat: fixtures/math.wasm fixtures/wat_bitwise.wasm ## Build WAT text format modules
fixtures/math.wasm: fixtures/wat_examples/math.wat
wat2wasm $< -o $@
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
fixtures/wat_bitwise.wasm: fixtures/wat_examples/bitwise.wat
wat2wasm $< -o $@
@echo "✅ Built $@ ($$(wc -c < $@) bytes)"
# ── Testing & Benchmarks ─────────────────────────────────────
test: ## Run all tests
mix test
bench: ## Run all benchmarks
mix run bench/wasm_vs_native.exs
mix run bench/wasm_startup.exs
mix run bench/wasm_memory.exs
bench-quick: ## Run quick WASM vs native benchmark
mix run bench/wasm_vs_native.exs
# ── Cleanup ───────────────────────────────────────────────────
clean: ## Remove build artifacts
rm -rf fixtures/rust_math/target
rm -rf fixtures/rust_algorithms/target
@echo "✅ Cleaned build artifacts"
clean-wasm: ## Remove compiled WASM files (rebuild with 'make all')
rm -f fixtures/rust_math.wasm fixtures/rust_algorithms.wasm
rm -f fixtures/go_math.wasm fixtures/go_algorithms.wasm
rm -f fixtures/math.wasm
@echo "✅ Removed compiled WASM files"
# ── Size report ───────────────────────────────────────────────
sizes: ## Show WASM file sizes
@echo "📦 WASM Module Sizes:"
@echo ""
@printf " %-35s %s\n" "Module" "Size"
@printf " %-35s %s\n" "──────────────────────────────────" "─────────"
@for f in fixtures/*.wasm; do \
printf " %-35s %s bytes\n" "$$(basename $$f)" "$$(wc -c < $$f)"; \
done