diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-07-28 09:53:13 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-07-28 09:53:13 -0400 |
commit | a12c4dbf12f5dff559abc4464b905842031696da (patch) | |
tree | 1452bc74db8dc454f1d126aa6e16873a363ff91b /build | |
parent | 3d76e707633b66e01791a0a09e38e91213b963c2 (diff) | |
download | bfs-a12c4dbf12f5dff559abc4464b905842031696da.tar.xz |
build: De-duplicate conditionally-supported flags
Diffstat (limited to 'build')
-rwxr-xr-x | build/flags-if.sh | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/build/flags-if.sh b/build/flags-if.sh index 098b2d3..7de7bbd 100755 --- a/build/flags-if.sh +++ b/build/flags-if.sh @@ -7,10 +7,18 @@ set -eu -FLAGS=$(sed -n '\|^///|{s|^/// ||; s|[^=]*= ||; p}' "$1") +OLD_FLAGS="$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS $XLDLIBS" +NEW_FLAGS=$(sed -n '\|^///|{s|^/// ||; s|[^=]*= ||; p}' "$1") +build/cc.sh "$@" $NEW_FLAGS || exit 1 -if build/cc.sh "$@" $FLAGS; then - sed -n 's|^/// \(.*=.*\)|\1|p' "$1" -else - exit 1 -fi +# De-duplicate against the existing flags +while IFS="" read -r line; do + case "$line" in + ///*=*) + flag="${line#*= }" + if [ "${OLD_FLAGS#*"$flag"}" = "$OLD_FLAGS" ]; then + printf '%s\n' "${line#/// }" + fi + ;; + esac +done <"$1" |