Files
chandra/scripts/build-compositor-wasm.sh
Claude 41c6ec1135
CI / test (push) Canceled after 0s
Remove the Rust host (host-wasm)
The MoonBit host (wasmhost/, build/wasmhost) is the only host now. Gone:
host-wasm/ (Rust on the wasmtime crate, ~5,700 lines incl. Cargo.lock),
the run-rust, run-drm-rust and host-wasm recipes, and `just install --rust`
(both the recipe and session/install.py now stop with an error naming the
removal instead of quietly ignoring the flag). remote-build.sh builds and
pulls build/wasmhost. README, wasmhost/README and docs no longer describe a
second host, apart from short history notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiBxpbLoeUM9xfZayq
2026-11-26 04:19:19 +00:00

23 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the compositor itself as a wasm component: build/compositor.wasm.
# It imports the chandra:host interfaces (wit/host) and exports `run`; the host (wasmhost/,
# build/wasmhost) provides the imports. Needs moon and wasm-tools.
# scripts/build-compositor-wasm.sh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT"
export PATH="$ROOT/.tools/bin:$HOME/.moon/bin:$PATH"
for t in moon wasm-tools; do
command -v "$t" >/dev/null || { echo "error: $t not found" >&2; exit 1; }
done
moon build --target wasm --release components/compositor/gen 2>&1 | grep -E '^Error' -A8 || true
[ "${PIPESTATUS[0]}" -eq 0 ] || { echo "error: moon build failed" >&2; exit 1; }
core="_build/wasm/release/build/components/compositor/gen/gen.wasm"
[ -f "$core" ] || { echo "error: $core missing" >&2; exit 1; }
mkdir -p build
wasm-tools component embed wit/host "$core" --world compositor --encoding utf16 -o build/compositor.embed.wasm
wasm-tools component new build/compositor.embed.wasm -o build/compositor.wasm
rm -f build/compositor.embed.wasm
wasm-tools validate --features component-model build/compositor.wasm
printf 'compositor.wasm %s bytes imports=[%s]\n' "$(stat -c %s build/compositor.wasm)" \
"$(wasm-tools component wit build/compositor.wasm | sed -n 's/^ import \(.*\);/\1/p' | paste -sd, -)"