Add support for params files for darwin
Clang has supported params files for a while now. This updates the cc
toolchain for darwin to use them.
The logic for processing response files is mostly copied from
rules_swift where similar processing is done.
Closes #12265.
PiperOrigin-RevId: 342013390
diff --git a/tools/cpp/osx_cc_wrapper.sh b/tools/cpp/osx_cc_wrapper.sh
index bbb5d7e..8c9c111 100755
--- a/tools/cpp/osx_cc_wrapper.sh
+++ b/tools/cpp/osx_cc_wrapper.sh
@@ -34,20 +34,33 @@
LIB_DIRS=
RPATHS=
OUTPUT=
-# let parse the option list
-for i in "$@"; do
+
+function parse_option() {
+ local -r opt="$1"
if [[ "${OUTPUT}" = "1" ]]; then
- OUTPUT=$i
- elif [[ "$i" =~ ^-l(.*)$ ]]; then
+ OUTPUT=$opt
+ elif [[ "$opt" =~ ^-l(.*)$ ]]; then
LIBS="${BASH_REMATCH[1]} $LIBS"
- elif [[ "$i" =~ ^-L(.*)$ ]]; then
+ elif [[ "$opt" =~ ^-L(.*)$ ]]; then
LIB_DIRS="${BASH_REMATCH[1]} $LIB_DIRS"
- elif [[ "$i" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
+ elif [[ "$opt" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
RPATHS="${BASH_REMATCH[1]} ${RPATHS}"
- elif [[ "$i" = "-o" ]]; then
+ elif [[ "$opt" = "-o" ]]; then
# output is coming
OUTPUT=1
fi
+}
+
+# let parse the option list
+for i in "$@"; do
+ if [[ "$i" = @* ]]; then
+ while IFS= read -r opt
+ do
+ parse_option "$opt"
+ done < "${i:1}" || exit 1
+ else
+ parse_option "$i"
+ fi
done
# Call gcc