From a12c4dbf12f5dff559abc4464b905842031696da Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 28 Jul 2024 09:53:13 -0400 Subject: build: De-duplicate conditionally-supported flags --- build/flags-if.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'build') 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" -- cgit v1.2.3