diff --git a/cc/private/toolchain/osx_cc_wrapper.sh b/cc/private/toolchain/osx_cc_wrapper.sh index 207bcefd..8c9c111a 100755 --- a/cc/private/toolchain/osx_cc_wrapper.sh +++ b/cc/private/toolchain/osx_cc_wrapper.sh @@ -34,20 +34,33 @@ LIBS= 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 @@ -101,4 +114,3 @@ for rpath in ${RPATHS}; do fi done done - diff --git a/cc/private/toolchain/osx_cc_wrapper.sh.tpl b/cc/private/toolchain/osx_cc_wrapper.sh.tpl index 4c85cd9b..28bd47ba 100644 --- a/cc/private/toolchain/osx_cc_wrapper.sh.tpl +++ b/cc/private/toolchain/osx_cc_wrapper.sh.tpl @@ -33,20 +33,33 @@ LIBS= 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 # Set-up the environment