CI / test (push) Failing after 29s
just run depends on just modules; a component listed in components.txt without a built core module (pulse, tasks, layout, ...) aborted the whole build. It now warns and carries on, so the panel loads whichever modules do exist. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
43 lines
2.3 KiB
Bash
Executable File
43 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build the panel's wasm modules (every *-widget component in scripts/components.txt)
|
|
# into build/components/<name>.wasm, the directory the compositor loads its panel from.
|
|
# Same steps as scripts/build.sh minus the jco/JS-host transpile, so it needs only
|
|
# moon and wasm-tools.
|
|
# scripts/build-modules.sh [name ...]
|
|
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
|
|
want=("$@")
|
|
mkdir -p build/components
|
|
moon build --target wasm --release 2>&1 | grep -E '^Error' -A8 || true
|
|
[ "${PIPESTATUS[0]}" -eq 0 ] || { echo "error: moon build failed" >&2; exit 1; }
|
|
n=0
|
|
while read -r name world; do
|
|
case "$name" in ''|'#'*) continue;; esac
|
|
case "$world" in *-widget) ;; *) continue;; esac
|
|
if [ ${#want[@]} -gt 0 ] && [[ ! " ${want[*]} " =~ " $name " ]]; then continue; fi
|
|
core="_build/wasm/release/build/components/$name/gen/gen.wasm"
|
|
if [ ! -f "$core" ]; then
|
|
# Listed in components.txt but its source isn't in the tree (yet): skip it, don't fail the build.
|
|
echo " $name: skipped (no source: $core missing)" >&2
|
|
continue
|
|
fi
|
|
out="build/components/$name.wasm"
|
|
wasm-tools component embed wit "$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 "$out" >/dev/null
|
|
imports="$(wasm-tools component wit "$out" | sed -n 's/^ import moonplasma:desktop\/\([a-z-]*\)@.*;/\1/p' | grep -v '^types$' | sort | paste -sd, - || true)"
|
|
exports="$(wasm-tools component wit "$out" | sed -n 's/^ export moonplasma:desktop\/\([a-z-]*\)@.*;/\1/p' | sort | paste -sd, -)"
|
|
printf '{"name":"%s","world":"%s","imports":[%s],"exports":[%s]}\n' "$name" "$world" \
|
|
"$(echo "$imports" | sed 's/\([a-z-]\+\)/"\1"/g')" "$(echo "$exports" | sed 's/\([a-z-]\+\)/"\1"/g')" \
|
|
> "build/components/$name.meta.json"
|
|
printf ' %-16s %-22s %7s bytes imports=[%s]\n' "$name" "$world" "$(stat -c %s "$out")" "$imports"
|
|
n=$((n + 1))
|
|
done < scripts/components.txt
|
|
echo "built $n module(s) into build/components/"
|