26 lines
1.2 KiB
Bash
Executable File
26 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build WM and decoration MoonBit components from wit/wm/.
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT"
|
|
export PATH="$ROOT/.tools/bin:$HOME/.moon/bin:$PATH"
|
|
|
|
wasm-tools component wit wit/wm >/dev/null
|
|
moon build --target wasm --release 2>&1 | grep -v -E 'Warning|^\s*$|[│╭╰─]' || true
|
|
[ "${PIPESTATUS[0]}" -eq 0 ] || { echo "error: moon build failed" >&2; exit 1; }
|
|
|
|
mkdir -p build/components
|
|
for pair in "wm-hybrid:window-manager" "decoration-breeze:decoration-provider"; do
|
|
name="${pair%%:*}"
|
|
world="${pair#*:}"
|
|
core="_build/wasm/release/build/components/$name/gen/gen.wasm"
|
|
[ -f "$core" ] || { echo "error: $core missing" >&2; exit 1; }
|
|
out="build/components/$name.wasm"
|
|
wasm-tools component embed wit/wm "$core" --world "$world" --encoding utf16 -o "build/components/$name.embed.wasm"
|
|
wasm-tools component new "build/components/$name.embed.wasm" -o "$out"
|
|
rm -f "build/components/$name.embed.wasm"
|
|
wasm-tools validate --features component-model "$out"
|
|
wasm-tools component targets --world "$world" wit/wm "$out" >/dev/null
|
|
printf ' %-18s %-20s %7s bytes\n' "$name" "$world" "$(stat -c %s "$out")"
|
|
done
|
|
echo "ok (wm)"
|