The previous indirect method was more complicated and still error prone.
v2:
* Use "grep -E" (Eric Engestrom)
* Exclude spaces and slashes in the grep pattern, to avoid accidentally
matching across unrelated compiler arguments.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22438>
CCACHE=
fi
-if [ "$(ps -p $(ps -p $PPID -o ppid --no-headers) -o comm --no-headers)" != ninja ]; then
- # Not invoked by ninja (e.g. for a meson feature check)
+if echo "$@" | grep -E 'meson-private/tmp[^ /]*/testfile.c' >/dev/null; then
+ # Invoked for meson feature check
exec $CCACHE $_COMPILER "$@"
fi