diff options
author | Dmitry Shevchenko <dmishe@google.com> | 2016-10-03 22:12:28 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-10-04 08:55:09 +0000 |
commit | deeeb31f8ba0f196fbc9ca2a177d59d57ea50b32 (patch) | |
tree | 999abbd9c868be741495a0fc63a3ac77b7d31deb /src/tools/xcode | |
parent | 169e68f4f3fcc000cc4fedebf15a9ea9373784e4 (diff) |
Add a way to select non-default Xcode toolchain
* Adds a flag --xcode_toolchain which sets TOOLCHAINS env variable for xcrun.
* Updates swift_library to work with this flag when selecting Swift runtime location.
* By default the flag has a null value and is not set in env.
--
MOS_MIGRATED_REVID=135033093
Diffstat (limited to 'src/tools/xcode')
-rwxr-xr-x | src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh b/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh index 7197cdc32e..d4f2f4fc60 100755 --- a/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh +++ b/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh @@ -17,7 +17,9 @@ # swiftstdlibtoolwrapper runs swift-stdlib-tool and zips up the output. # This script only runs on darwin and you must have Xcode installed. # -# $1 OUTZIP - the path to place the output zip file. +# --output_zip_path - the path to place the output zip file. +# --bundle_path - the path inside of the archive to where libs will be copied. +# --toolchain - toolchain identifier to use with xcrun. set -eu @@ -25,15 +27,50 @@ MY_LOCATION=${MY_LOCATION:-"$0.runfiles/bazel_tools/tools/objc"} REALPATH="${MY_LOCATION}/realpath" WRAPPER="${MY_LOCATION}/xcrunwrapper.sh" -OUTZIP=$("${REALPATH}" "$1") -PATH_INSIDE_ZIP="$2" -shift 2 +TOOL_ARGS=() +while [[ $# -gt 0 ]]; do + ARG="$1" + shift + case "${ARG}" in + --output_zip_path) + ARG="$1" + shift + OUTZIP=$("${REALPATH}" "${ARG}") + ;; + --bundle_path) + ARG="$1" + shift + PATH_INSIDE_ZIP="$ARG" + ;; + --toolchain) + ARG="$1" + shift + TOOLCHAIN=${ARG} + ;; + # Remaining args are swift-stdlib-tool args + *) + TOOL_ARGS+=("$ARG") + ;; + esac +done + + TEMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/swiftstdlibtoolZippingOutput.XXXXXX") trap "rm -rf \"$TEMPDIR\"" EXIT FULLPATH="$TEMPDIR/$PATH_INSIDE_ZIP" -$WRAPPER swift-stdlib-tool --copy --verbose --destination "$FULLPATH" "$@" +XCRUN_ARGS=() + +if [ -n "${TOOLCHAIN:-}" ]; then + XCRUN_ARGS+=(--toolchain "$TOOLCHAIN") +fi + +XCRUN_ARGS+=(swift-stdlib-tool --copy --verbose ) +XCRUN_ARGS+=(--destination "$FULLPATH") +XCRUN_ARGS+=( "${TOOL_ARGS[@]}" ) + +$WRAPPER "${XCRUN_ARGS[@]}" # Need to push/pop tempdir so it isn't the current working directory # when we remove it via the EXIT trap. |