93 lines
3 KiB
Bash
93 lines
3 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# p2-60 Lens Switcher proof renderer.
|
||
|
|
#
|
||
|
|
# Runs ON apricot. Drives flatpak Godot under a weston-headless Wayland host
|
||
|
|
# pointed at `res://engine/scenes/tests/lens_switcher_proof.tscn`. The scene
|
||
|
|
# instantiates the lens switcher widget, cycles through every loaded lens,
|
||
|
|
# and writes one PNG per lens to `user://screenshots/lens_<id>_<ts>.png`,
|
||
|
|
# printing `SCREENSHOT_PATH:<abs>` per shot.
|
||
|
|
#
|
||
|
|
# Caller-side (plum) entry point: scripts/p2-60-lens-proof-run.sh — that one
|
||
|
|
# pushes via the canonical fetch / worktree path used by apricot-run.sh, then
|
||
|
|
# invokes this script inside the scratch worktree.
|
||
|
|
#
|
||
|
|
# Env:
|
||
|
|
# SCRATCH_DIR worktree path containing src/game (required)
|
||
|
|
# LOG_FILE log destination (default /tmp/p2-60-lens-proof.log)
|
||
|
|
# TIMEOUT_SEC Godot timeout in seconds (default 90)
|
||
|
|
|
||
|
|
set -uo pipefail
|
||
|
|
|
||
|
|
SCRATCH_DIR="${SCRATCH_DIR:?SCRATCH_DIR is required}"
|
||
|
|
LOG_FILE="${LOG_FILE:-/tmp/p2-60-lens-proof.log}"
|
||
|
|
TIMEOUT_SEC="${TIMEOUT_SEC:-90}"
|
||
|
|
|
||
|
|
GODOT_USERDATA="$HOME/.var/app/org.godotengine.Godot/data/godot/app_userdata/Magic Civilization"
|
||
|
|
SHOT_DIR="$GODOT_USERDATA/screenshots"
|
||
|
|
|
||
|
|
echo "=== p2-60 Lens Switcher proof ==="
|
||
|
|
echo "SCRATCH_DIR: $SCRATCH_DIR"
|
||
|
|
echo "LOG: $LOG_FILE"
|
||
|
|
echo "Sandbox screenshot dir: $SHOT_DIR"
|
||
|
|
|
||
|
|
# Wipe prior lens screenshots so we only fetch this run's outputs.
|
||
|
|
mkdir -p "$SHOT_DIR"
|
||
|
|
rm -f "$SHOT_DIR"/lens_*.png 2>/dev/null || true
|
||
|
|
|
||
|
|
if ! command -v weston >/dev/null 2>&1; then
|
||
|
|
echo "ERROR: weston not installed" >&2
|
||
|
|
exit 2
|
||
|
|
fi
|
||
|
|
|
||
|
|
WESTON_SOCKET="p2-60-lens-$$"
|
||
|
|
WESTON_LOG="/tmp/p2-60-lens-weston.log"
|
||
|
|
echo "Starting weston (headless, socket=$WESTON_SOCKET)..."
|
||
|
|
weston --backend=headless --no-config --socket="$WESTON_SOCKET" \
|
||
|
|
--width=1920 --height=360 \
|
||
|
|
>"$WESTON_LOG" 2>&1 &
|
||
|
|
WESTON_PID=$!
|
||
|
|
sleep 1.5
|
||
|
|
if ! kill -0 "$WESTON_PID" 2>/dev/null; then
|
||
|
|
echo "ERROR: weston failed to launch — see $WESTON_LOG" >&2
|
||
|
|
tail -20 "$WESTON_LOG" >&2
|
||
|
|
exit 3
|
||
|
|
fi
|
||
|
|
trap 'kill $WESTON_PID 2>/dev/null; wait $WESTON_PID 2>/dev/null' EXIT
|
||
|
|
|
||
|
|
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \
|
||
|
|
timeout "$TIMEOUT_SEC" flatpak run --user \
|
||
|
|
--filesystem=home \
|
||
|
|
--socket=wayland \
|
||
|
|
--unset-env=DISPLAY \
|
||
|
|
--env=WAYLAND_DISPLAY="$WESTON_SOCKET" \
|
||
|
|
--filesystem=xdg-run/${WESTON_SOCKET} \
|
||
|
|
--env=SCREENSHOT_NAME="lens" \
|
||
|
|
org.godotengine.Godot \
|
||
|
|
--path "$SCRATCH_DIR/src/game" \
|
||
|
|
--display-driver wayland \
|
||
|
|
--rendering-driver opengl3 \
|
||
|
|
--rendering-method gl_compatibility \
|
||
|
|
res://engine/scenes/tests/lens_switcher_proof.tscn \
|
||
|
|
>"$LOG_FILE" 2>&1
|
||
|
|
RC=$?
|
||
|
|
|
||
|
|
echo "--- Godot exit rc=$RC ---"
|
||
|
|
echo "--- Tail of log ---"
|
||
|
|
tail -40 "$LOG_FILE"
|
||
|
|
echo "-------------------"
|
||
|
|
echo "--- SCREENSHOT_PATH lines ---"
|
||
|
|
grep "SCREENSHOT_PATH:" "$LOG_FILE" || echo "(none)"
|
||
|
|
echo "-----------------------------"
|
||
|
|
|
||
|
|
SHOTS=( "$SHOT_DIR"/lens_*.png )
|
||
|
|
if [ ! -f "${SHOTS[0]}" ]; then
|
||
|
|
echo "ERROR: no lens_*.png produced under $SHOT_DIR" >&2
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "Captured ${#SHOTS[@]} shots:"
|
||
|
|
ls -la "$SHOT_DIR"/lens_*.png
|
||
|
|
|
||
|
|
echo "=== Done ==="
|
||
|
|
exit 0
|