Files
next.orly.dev/pkg/wasm/shell/build.sh
mleku 24eef5b5a8
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
fix CORS headers and a wasm experiment
2025-11-14 19:15:50 +00:00

35 lines
763 B
Bash
Executable File

#!/bin/bash
# Build script for WASM shell examples
# Compiles WAT (WebAssembly Text) to WASM binary
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Building WASM modules from WAT files..."
# Check if wat2wasm is available
if ! command -v wat2wasm &> /dev/null; then
echo "Error: wat2wasm not found. Install wabt:"
echo " sudo apt install wabt"
exit 1
fi
# Build each .wat file to .wasm
for wat_file in *.wat; do
if [ -f "$wat_file" ]; then
wasm_file="${wat_file%.wat}.wasm"
echo " $wat_file -> $wasm_file"
wat2wasm "$wat_file" -o "$wasm_file"
fi
done
echo "Build complete!"
echo ""
echo "Run with:"
echo " ./run.sh hello.wasm"
echo " or"
echo " wasmtime hello.wasm"