Add native/extract_core.py to extract embedded core Wasm modules from curl.wasm and native/wasi_host.c providing a POSIX/OpenSSL WASI 0.2 host shim for wasm2c. Add native, test-native, and run-native recipes to justfile (with positional-arguments enabled), support CURL_WASM_NATIVE in tests/test_curl.py, ignore build artifacts in .gitignore, and document native compilation in README.md.
34 lines
1011 B
Makefile
34 lines
1011 B
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
|
|
mkdir -p build
|
|
python3 native/extract_core.py curl.wasm build
|
|
wasm2c build/mem_mod.wasm -n mem_mod -o build/mem_mod.c
|
|
wasm2c build/curl_core.wasm -n curl_core -o build/curl_core.c
|
|
cc -O2 -w -Ibuild -c build/mem_mod.c -o build/mem_mod.o
|
|
cc -O2 -w -Ibuild -c build/curl_core.c -o build/curl_core.o
|
|
cc -O2 -Wall -Wextra -Werror -Wno-unused-parameter -Ibuild -c native/wasi_host.c -o build/wasi_host.o
|
|
cc -O2 build/mem_mod.o build/curl_core.o build/wasi_host.o -lwasm-rt-impl -lssl -lcrypto -lm -o curl-native
|
|
|
|
test: build
|
|
python3 tests/test_curl.py
|
|
|
|
test-native: native
|
|
CURL_WASM_NATIVE=./curl-native 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 build
|