iris: run-headless.sh --bin, for screenshotting a real binary not just an example
desktop-app (RUST.md's E4) is a real crate binary a person runs, not a demo under examples/, and it needs its own argv (--ca, --link) to start at all -- neither of which the script had a way to express. --bin swaps `cargo build --example`/`target/debug/examples/NAME` for the `--bin` equivalents; $RUN_HEADLESS_ARGS is word-split into the launched binary's own argv, since no example ever needed one before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
73ee63bc1b
commit
ba6817fee5
1 file changed
+21
-2
+21
-2
@@ -4,6 +4,16 @@
|
||||
# ./run-headless.sh tabs [-- cargo args]
|
||||
# ./run-headless.sh tabs --shot /tmp/tabs.png --seconds 4
|
||||
#
|
||||
# `--bin` runs a real crate binary instead of an example (E4's
|
||||
# `desktop-app`, which is a window a person runs, not a demo) --
|
||||
# `cargo build --bin NAME` instead of `--example NAME`, and
|
||||
# `target/debug/NAME` instead of `target/debug/examples/NAME`. Its own
|
||||
# argv (the CLI flags a real binary takes, as opposed to `cargo build`'s
|
||||
# own flags after `--`) comes through `$RUN_HEADLESS_ARGS`, word-split on
|
||||
# purpose -- an example never needed one, so there was nowhere to plumb it
|
||||
# through positionally without disturbing the existing `-- cargo args`
|
||||
# convention above.
|
||||
#
|
||||
# The VM has a virtio-gpu render node (Vulkan 1.4 through Venus, GL 4.6
|
||||
# through virgl), so wgpu runs on the host's real GPU -- what is missing is
|
||||
# only a compositor to give winit a surface. So: a headless sway, the same
|
||||
@@ -20,16 +30,18 @@ run="${XDG_RUNTIME_DIR:-/tmp}/iris-headless"
|
||||
seconds=3
|
||||
shot=""
|
||||
example=""
|
||||
kind=example
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--shot) shot=$2; shift 2 ;;
|
||||
--seconds) seconds=$2; shift 2 ;;
|
||||
--bin) kind=bin; shift ;;
|
||||
--) shift; break ;;
|
||||
*) example=$1; shift ;;
|
||||
esac
|
||||
done
|
||||
[ -n "$example" ] || { echo "usage: $0 EXAMPLE [--shot PNG] [--seconds N] [-- cargo args]" >&2; exit 2; }
|
||||
[ -n "$example" ] || { echo "usage: $0 NAME [--bin] [--shot PNG] [--seconds N] [-- cargo args]" >&2; exit 2; }
|
||||
|
||||
mkdir -p "$run"
|
||||
export SWAYSOCK="$run/sway.sock"
|
||||
@@ -67,10 +79,17 @@ export WAYLAND_DISPLAY
|
||||
echo "run-headless: $WAYLAND_DISPLAY (sway $(swaymsg -t get_version --raw | sed -n 's/.*"human_readable":"\([^"]*\)".*/\1/p'))" >&2
|
||||
|
||||
cd "$here"
|
||||
if [ "$kind" = bin ]; then
|
||||
cargo build --bin "$example" "$@" >&2
|
||||
bin="$here/target/debug/$example"
|
||||
else
|
||||
cargo build --example "$example" "$@" >&2
|
||||
bin="$here/target/debug/examples/$example"
|
||||
fi
|
||||
|
||||
"$bin" >"$run/$example.log" 2>&1 &
|
||||
# shellcheck disable=SC2086 -- deliberately word-split: this is the
|
||||
# binary's own argv, not a single path.
|
||||
"$bin" ${RUN_HEADLESS_ARGS:-} >"$run/$example.log" 2>&1 &
|
||||
pid=$!
|
||||
trap 'kill "$pid" 2>/dev/null || true' EXIT INT TERM
|
||||
|
||||
|
||||
Reference in new issue
Block a user