kick/build.sh

40 lines
1 KiB
Bash
Raw Normal View History

2026-08-09 21:07:51 +10:00
#!/bin/sh
set -e
cd "$(dirname "$0")"
# Rebuild only when a source is newer than the built binary; otherwise
# meson setup/compile would (re)generate everything each run. Sources
# are tracked per program: kick.c only feeds kick, tests/wltest.c only
# feeds wltest, while meson.build and the vendored subprojects feed both.
stale() {
# $1 = binary; $2.. = source paths/dirs it depends on.
bin=$1
shift
[ -x "$bin" ] || return 0
for p in "$@"; do
[ -e "$p" ] || continue
if [ -d "$p" ]; then
if find "$p" -type f -newer "$bin" -print -quit | grep -q .; then
return 0
fi
elif [ "$p" -nt "$bin" ]; then
return 0
fi
done
return 1
}
if stale build/kick kick.c meson.build subprojects wlr-protocols \
|| stale build/wltest tests/wltest.c meson.build subprojects; then
set -x
meson setup build --reconfigure
meson compile -C build
echo "Built: ./build/kick"
else
echo "build: nothing to do (binaries up to date)"
fi