Files
curl-wasm/justfile
T
nandiandClaude Sonnet 5.5 27ce306c7c Spike: build a static ELF via wasm2elf with WAT syscall shims
Add elf/ (flatten.py, shim.wat, wasm2elf.patch pinned to wasm2elf-mb rev) and
just elf / test-elf recipes. The ELF handles plain HTTP, DNS, files and stdin;
26/27 repo tests pass, https:// is unsupported (no TLS).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 18:01:13 -08:00

46 lines
1.2 KiB
Makefile

set positional-arguments
default:
@just --list
build:
wasm-tools parse curl.wat -o curl.wasm
wasm-tools validate curl.wasm --features component-model
native: build
python3 native/build_native.py
test: build
python3 tests/test_curl.py
test-native: native
CURL_WASM_NATIVE=./curl-native python3 tests/test_curl.py
# Spike: static x86-64 ELF via wasm2elf (no libc/runtime; plain HTTP only, no TLS yet)
elf:
#!/usr/bin/env bash
set -euo pipefail
W=build/wasm2elf
if [ ! -d $W ]; then
git clone https://git.site.latha.org/nandi/wasm2elf-mb $W
git -C $W checkout "$(cat elf/wasm2elf.rev)"
git -C $W apply ../../elf/wasm2elf.patch
fi
(cd $W && moon build --target native)
python3 elf/flatten.py curl.wat elf/shim.wat build/curl-flat.wat
wasm-tools parse build/curl-flat.wat -o build/curl-flat.wasm
wasm-tools validate build/curl-flat.wasm
$W/_build/native/debug/build/cmd/main/main.exe build/curl-flat.wasm curl-elf run
test-elf: elf
CURL_WASM_NATIVE=./curl-elf python3 tests/test_curl.py
run *args: build
wasmtime run -S http --dir=. -- ./curl.wasm "$@"
run-native *args: native
./curl-native "$@"
clean:
rm -rf curl.wasm curl-native curl-elf build