scx/meson-scripts/build_libbpf
Tejun Heo 069c390ef2 meson-scripts/build_libbpf: Accommodate meson setting CC to "ccache $COMPILER"
Otherwise, we end up passing CC=ccache to libbpf's Makefile which triggers
an error as ccache invoked on its own can't act as a stand-in for the
compiler.
2024-03-04 10:04:25 -10:00

28 lines
480 B
Bash
Executable File

#!/bin/bash
set -e
out=$("$1" 'map(select(.["file"] | contains ("cc_cflags_probe.c"))) | first | .["command"]' < compile_commands.json)
out=${out#\"}
out=${out%\"}
args=($out)
idx=0
cc=${args[idx]}
if [ "$cc" = "ccache" ]; then
idx=$((idx+1))
cc="$cc ${args[idx]}"
fi
declare -a cflags=()
for arg in ${args[@]:(idx+1)}; do
case $arg in
-I*|-M*|-o|-c) ;;
-*) cflags+="$arg ";;
esac
done
make_out=$(env CC="$cc" CFLAGS="$cflags" "$2" -C "$3" -j"$4")
exit $?