kick/build.sh
Andrew Hamilton 658b553840 fix build.sh: exclude .wraplock from stale-source check
meson setup --reconfigure touches subprojects/.wraplock every run,
making it newer than build/kick and triggering an infinite rebuild
loop.  The file is meson housekeeping, not a real source dependency.
2026-08-27 09:25:11 +10:00

39 lines
1 KiB
Bash
Executable file

#!/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" ! -name '.wraplock' -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