diff --git a/justfile b/justfile index e0a56ae..c46d9d9 100644 --- a/justfile +++ b/justfile @@ -103,6 +103,10 @@ uninstall-session: client *cmd="foot": WAYLAND_DISPLAY={{socket}} {{cmd}} +# Build host + wasm compositor + modules on a sprites.dev sprite (CHANDRA_SPRITE, default chandra-build) and pull the artifacts back. +remote-build *targets: + scripts/remote-build.sh {{targets}} + # Compositor + wasm component + lib tests. test: modules XDG_CONFIG_HOME="$(mktemp -d)" CHANDRA_TEST_CONFIG=1 moon test --target native --warn-list -a compositor/renderer compositor/wasm compositor/host diff --git a/scripts/remote-build.sh b/scripts/remote-build.sh new file mode 100755 index 0000000..4ce12a3 --- /dev/null +++ b/scripts/remote-build.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Build on a sprites.dev sprite instead of locally, then pull the artifacts back: +# build/compositor.wasm, build/components/ and host-wasm/target/release/chandra-host. +# The sprite checks the tree out at the same absolute path as here, because host-wasm/build.rs +# bakes /.pixi/envs/default/lib into the host's rpath. +# One-off sprite setup (apt dev libs, pixi, moon, wasm-tools, moon update): scripts/sprite-setup.sh. +# scripts/remote-build.sh [just-target ...] (default: host-wasm compositor-wasm modules) +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT" +SPRITE="${CHANDRA_SPRITE:-chandra-build}" +targets=("$@"); [ ${#targets[@]} -gt 0 ] || targets=(host-wasm 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" +mkdir -p build host-wasm/target/release +sp --no-stdin --dir "$ROOT" -- tar cf - build/compositor.wasm build/components host-wasm/target/release/chandra-host \ + | tar xf - +ls -la build/compositor.wasm host-wasm/target/release/chandra-host diff --git a/scripts/sprite-setup.sh b/scripts/sprite-setup.sh new file mode 100755 index 0000000..5f9694b --- /dev/null +++ b/scripts/sprite-setup.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# One-off setup of the build sprite used by scripts/remote-build.sh (Ubuntu sprite): dev libs, pixi, moon, wasm-tools. +# Run on the sprite: sprite exec -s chandra-build --no-stdin --file scripts/sprite-setup.sh:/tmp/sprite-setup.sh -- bash /tmp/sprite-setup.sh +# Then once: sprite exec -s chandra-build --no-stdin -- bash -c '~/.moon/bin/moon update' +set -euo pipefail +sudo mkdir -p /home/nandi/Projects/chandra && sudo chown -R sprite:sprite /home/nandi +sudo apt-get update -qq +sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq libdrm-dev libinput-dev libxkbcommon-dev libudev-dev libseat-dev pkg-config xz-utils unzip >/dev/null +mkdir -p ~/.local/bin +# pixi +curl -fsSL https://pixi.sh/install.sh | PIXI_VERSION=v0.84.2 PIXI_NO_PATH_UPDATE=1 sh >/dev/null 2>&1 || true +# wasm-tools prebuilt +curl -fsSL https://github.com/bytecodealliance/wasm-tools/releases/download/v1.258.0/wasm-tools-1.258.0-x86_64-linux.tar.gz | tar xz -C /tmp +install /tmp/wasm-tools-1.258.0-x86_64-linux/wasm-tools ~/.local/bin/ +# moon +curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash >/dev/null 2>&1 || true +export PATH=$HOME/.pixi/bin:$HOME/.moon/bin:$HOME/.local/bin:$PATH +pixi -V; wasm-tools -V; moon version | head -1; cargo -V; ls /usr/include/libseat.h