scx-upstream/meson-scripts/build_bpftool
Jordan Rome ffc7b7dc4a Fetch and build bpftool by default
This pairs with the new default behavior to fetch and build libbpf
and is mostly being used so we can use the latest bpftool and libbpf.
2024-03-11 10:00:01 -07:00

29 lines
478 B
Bash

#!/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
cd $3
make_out=$(env CC="$cc" CFLAGS="$cflags" "$2" -j"$4")
exit $?