This commit is contained in:
1 parent
ccb809bdc3
commit
7caadb3f7f
59 files changed
+7495
-16
No files matched your search
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build wasi-gfx GUI loader MoonBit component from wit/gfx/ and transpile with jco.
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT"
|
||||
export PATH="$ROOT/.tools/bin:$HOME/.moon/bin:$PATH"
|
||||
JCO="$ROOT/host/node_modules/.bin/jco"
|
||||
[ -x "$JCO" ] || { echo "error: jco missing; run: (cd host && npm ci)" >&2; exit 1; }
|
||||
|
||||
wasm-tools component wit wit/gfx >/dev/null
|
||||
moon build --target wasm --release components/gfx-gui/gen 2>&1 | grep -v -E 'Warning|^\s*$|[│╭╰─]' || true
|
||||
[ "${PIPESTATUS[0]}" -eq 0 ] || { echo "error: moon build failed" >&2; exit 1; }
|
||||
|
||||
mkdir -p build/components build/jco
|
||||
core="_build/wasm/release/build/components/gfx-gui/gen/gen.wasm"
|
||||
[ -f "$core" ] || { echo "error: $core missing" >&2; exit 1; }
|
||||
out="build/components/gfx-gui.wasm"
|
||||
wasm-tools component embed wit/gfx "$core" --world gui-loader --encoding utf16 -o "build/components/gfx-gui.embed.wasm"
|
||||
wasm-tools component new "build/components/gfx-gui.embed.wasm" -o "$out"
|
||||
rm -f "build/components/gfx-gui.embed.wasm"
|
||||
wasm-tools validate --features component-model "$out"
|
||||
wasm-tools component targets --world gui-loader wit/gfx "$out" >/dev/null
|
||||
|
||||
rm -rf "build/jco/gfx-gui"
|
||||
"$JCO" transpile "$out" -o "build/jco/gfx-gui" --instantiation async --no-typescript --name gfx-gui >/dev/null
|
||||
echo '{"type":"module"}' > "build/jco/gfx-gui/package.json"
|
||||
printf ' %-18s %-20s %7s bytes\n' "gfx-gui" "gui-loader" "$(stat -c %s "$out")"
|
||||
echo "ok (gfx)"
|
||||
Reference in new issue
Block a user