diff options
author | 2016-10-05 16:07:22 +0000 | |
---|---|---|
committer | 2016-10-05 19:41:34 +0000 | |
commit | 39bb51a47e97f8d3771a282d5a9384fe041a506b (patch) | |
tree | 371e62d85737f2e58ddf45fa8c7326aef65b87e6 /src/tools/xcode | |
parent | 83e7c710153036c4cbf1c6201947aa7911f93cf4 (diff) |
Roll forward of commit deeeb31f8ba0f196fbc9ca2a177d59d57ea50b32.
* Fixed breakage in shell tools with an old bazel binary.
Rollback of commit deeeb31f8ba0f196fbc9ca2a177d59d57ea50b32.
*** Reason for rollback ***
Breaks builds with current blaze
*** Original change description ***
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=135238820
Diffstat (limited to 'src/tools/xcode')
-rwxr-xr-x | src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh b/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh index 7197cdc32e..6e84920dd7 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,59 @@ 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 +CMD_ARGS=("$@") + +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 +if [ -z "${PATH_INSIDE_ZIP:-}" ] && [ -z "${OUTZIP:-}" ]; then + # This is an older bazel binary, massage the arguments to accommodate. + # TODO(b/30478247): Remove this when new bazel binary is available. + PATH_INSIDE_ZIP="${CMD_ARGS[1]}" + OUTZIP=$("${REALPATH}" "${CMD_ARGS[0]}") + TOOL_ARGS=("${TOOL_ARGS[@]:2}") +fi + 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. |