#!/usr/bin/env bash # Build on a sprites.dev sprite instead of locally, then pull the artifacts back: # build/compositor.wasm, build/components/ and build/wasmhost. # The sprite checks the tree out at the same absolute path as here, so paths in the build match # (build/wasmhost's rpath points at the checkout's .pixi/envs/default/lib, relative to the binary). # One-off sprite setup (apt dev libs, pixi, moon, wasm-tools, moon update): scripts/sprite-setup.sh. # scripts/remote-build.sh [just-target ...] (default: wasmhost compositor-wasm modules) set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT" SPRITE="${CHANDRA_SPRITE:-chandra-build}" targets=("$@"); [ ${#targets[@]} -gt 0 ] || targets=(wasmhost compositor-wasm modules) sp() { sprite exec -s "$SPRITE" "$@"; } echo "== sync source to $SPRITE" { git ls-files -z --cached --others --exclude-standard; } | sort -zu \ | while IFS= read -r -d '' f; do [ -e "$f" ] && printf '%s\0' "$f"; done \ | tar --null -T - -cf - | sp --stdin --dir "$ROOT" -- tar xf - echo "== build: just ${targets[*]}" sp --no-stdin --dir "$ROOT" -- bash -c \ 'export PATH=$HOME/.pixi/bin:$HOME/.moon/bin:$HOME/.local/bin:$PATH; pixi run just '"${targets[*]}" echo "== pull artifacts" # `sprite file pull` rather than a tar stream over exec: a streamed binary can break on reconnect. # -r on a directory fails, so pull build/components/ file by file. mkdir -p build/components pull() { sprite file pull -s "$SPRITE" -p "$@"; } pull "$ROOT/build/compositor.wasm" build/ pull "$ROOT/build/wasmhost" build/ mods=(); while IFS= read -r f; do mods+=("$ROOT/build/components/$f"); done \ < <(sp --no-stdin --dir "$ROOT" -- ls build/components | grep -E '\.(wasm|json)$') pull "${mods[@]}" build/components/ ls -la build/compositor.wasm build/wasmhost