aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/xcode
diff options
context:
space:
mode:
authorGravatar Dave MacLachlan <dmaclach@google.com>2015-11-06 21:04:42 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-11-06 22:54:13 +0000
commit7fdbd784e82a388a158aa10dde3e3d5ceddefeee (patch)
treee582f072b0edc6df373098786549787c16670959 /src/tools/xcode
parent69a3f3621ea5c96edab39fde29fa1eb76d83006c (diff)
Add xcrunwrapper to deal with DEVELOPER_DIR and SDKROOT.
Replace uses of $SDKROOT and $DEVELOPER_DIR values in compile paths with __DEVELOPER_DIR__ and __SDKROOT__ to that xcrunwrapper can deal with them appropriately. RELNOTES:none -- MOS_MIGRATED_REVID=107259512
Diffstat (limited to 'src/tools/xcode')
-rwxr-xr-xsrc/tools/xcode/actoolwrapper/actoolwrapper.sh9
-rwxr-xr-xsrc/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh9
-rwxr-xr-xsrc/tools/xcode/momcwrapper/momcwrapper.sh9
-rwxr-xr-xsrc/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh9
-rw-r--r--src/tools/xcode/xcrunwrapper/BUILD11
-rw-r--r--src/tools/xcode/xcrunwrapper/README7
-rwxr-xr-xsrc/tools/xcode/xcrunwrapper/xcrunwrapper.sh57
7 files changed, 103 insertions, 8 deletions
diff --git a/src/tools/xcode/actoolwrapper/actoolwrapper.sh b/src/tools/xcode/actoolwrapper/actoolwrapper.sh
index 1a05fd7b69..28aef05474 100755
--- a/src/tools/xcode/actoolwrapper/actoolwrapper.sh
+++ b/src/tools/xcode/actoolwrapper/actoolwrapper.sh
@@ -21,7 +21,7 @@
set -eu
-REALPATH=$0.runfiles/external/bazel_tools/tools/objc/realpath
+REALPATH="$0.runfiles/external/bazel_tools/tools/objc/realpath"
if [ ! -e $REALPATH ]; then
REALPATH=tools/objc/realpath
fi
@@ -54,6 +54,11 @@ for i in $@; do
LASTARG="$i"
done
+WRAPPER="$0.runfiles/external/bazel_tools/tools/objc/xcrunwrapper.sh"
+if [ ! -e $WRAPPER ]; then
+ WRAPPER=tools/objc/xcrunwrapper.sh
+fi
+
# If we are running into problems figuring out actool issues, there are a couple
# of env variables that may help. Both of the following must be set to work.
# IBToolDebugLogFile=<OUTPUT FILE PATH>
@@ -63,7 +68,7 @@ done
# helps.
# Yes IBTOOL appears to be correct here due to actool and ibtool being based
# on the same codebase.
-/usr/bin/xcrun actool --errors --warnings --notices \
+$WRAPPER actool --errors --warnings --notices \
--compress-pngs --output-format human-readable-text \
--compile "$TEMPDIR" "${TOOLARGS[@]}"
diff --git a/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh b/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh
index 89faeded2f..346744f3d7 100755
--- a/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh
+++ b/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh
@@ -25,7 +25,7 @@
set -eu
-REALPATH=$0.runfiles/external/bazel_tools/tools/objc/realpath
+REALPATH="$0.runfiles/external/bazel_tools/tools/objc/realpath"
if [ ! -e $REALPATH ]; then
REALPATH=tools/objc/realpath
fi
@@ -54,6 +54,11 @@ for i in $@; do
fi
done
+WRAPPER="$0.runfiles/external/bazel_tools/tools/objc/xcrunwrapper.sh"
+if [ ! -e $WRAPPER ]; then
+ WRAPPER=tools/objc/xcrunwrapper.sh
+fi
+
# If we are running into problems figuring out ibtool issues, there are a couple
# of env variables that may help. Both of the following must be set to work.
# IBToolDebugLogFile=<OUTPUT FILE PATH>
@@ -61,7 +66,7 @@ done
# you may also see if
# IBToolNeverDeque=1
# helps.
-/usr/bin/xcrun ibtool --errors --warnings --notices \
+$WRAPPER ibtool --errors --warnings --notices \
--auto-activate-custom-fonts --output-format human-readable-text \
--compile "$FULLPATH" "${TOOLARGS[@]}"
diff --git a/src/tools/xcode/momcwrapper/momcwrapper.sh b/src/tools/xcode/momcwrapper/momcwrapper.sh
index 29c39d0b69..fc846637e0 100755
--- a/src/tools/xcode/momcwrapper/momcwrapper.sh
+++ b/src/tools/xcode/momcwrapper/momcwrapper.sh
@@ -22,7 +22,7 @@
set -eu
-REALPATH=$0.runfiles/external/bazel_tools/tools/objc/realpath
+REALPATH="$0.runfiles/external/bazel_tools/tools/objc/realpath"
if [ ! -e $REALPATH ]; then
REALPATH=tools/objc/realpath
fi
@@ -33,7 +33,12 @@ shift 2
TEMPDIR=$(mktemp -d -t momcZippingOutput)
trap "rm -rf \"$TEMPDIR\"" EXIT
-/usr/bin/xcrun momc "$@" "$TEMPDIR/$NAME"
+WRAPPER="$0.runfiles/external/bazel_tools/tools/objc/xcrunwrapper.sh"
+if [ ! -e $WRAPPER ]; then
+ WRAPPER=tools/objc/xcrunwrapper.sh
+fi
+
+$WRAPPER momc "$@" "$TEMPDIR/$NAME"
# Need to push/pop tempdir so it isn't the current working directory
# when we remove it via the EXIT trap.
diff --git a/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh b/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh
index 90520b5d2b..ed7d47122d 100755
--- a/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh
+++ b/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh
@@ -21,7 +21,7 @@
set -eu
-REALPATH=$0.runfiles/external/bazel_tools/tools/objc/realpath
+REALPATH="$0.runfiles/external/bazel_tools/tools/objc/realpath"
if [ ! -e $REALPATH ]; then
REALPATH=tools/objc/realpath
fi
@@ -33,7 +33,12 @@ trap "rm -rf \"$TEMPDIR\"" EXIT
FULLPATH="$TEMPDIR/Frameworks"
-/usr/bin/xcrun swift-stdlib-tool --copy --verbose --destination "$FULLPATH" "$@"
+WRAPPER="$0.runfiles/external/bazel_tools/tools/objc/xcrunwrapper.sh"
+if [ ! -e $WRAPPER ]; then
+ WRAPPER=tools/objc/xcrunwrapper.sh
+fi
+
+$WRAPPER swift-stdlib-tool --copy --verbose --destination "$FULLPATH" "$@"
# Need to push/pop tempdir so it isn't the current working directory
# when we remove it via the EXIT trap.
diff --git a/src/tools/xcode/xcrunwrapper/BUILD b/src/tools/xcode/xcrunwrapper/BUILD
new file mode 100644
index 0000000000..e8ea8594a8
--- /dev/null
+++ b/src/tools/xcode/xcrunwrapper/BUILD
@@ -0,0 +1,11 @@
+package(default_visibility = ["//src/test:__subpackages__"])
+
+filegroup(
+ name = "srcs",
+ srcs = glob(["**"]),
+)
+
+sh_binary(
+ name = "xcrunwrapper",
+ srcs = ["xcrunwrapper.sh"],
+)
diff --git a/src/tools/xcode/xcrunwrapper/README b/src/tools/xcode/xcrunwrapper/README
new file mode 100644
index 0000000000..d76642186e
--- /dev/null
+++ b/src/tools/xcode/xcrunwrapper/README
@@ -0,0 +1,7 @@
+xcrunwrapper runs the command passed to it using xcrun.
+
+It replaces __DEVELOPER_DIR__ with $DEVELOPER_DIR (or reasonable default)
+and __SDKROOT__ with a valid path based on SDKROOT (or reasonable default).
+
+xcrun only runs on Darwin, so xcrunwrapper only runs on Darwin.
+
diff --git a/src/tools/xcode/xcrunwrapper/xcrunwrapper.sh b/src/tools/xcode/xcrunwrapper/xcrunwrapper.sh
new file mode 100755
index 0000000000..dfb36aa4ef
--- /dev/null
+++ b/src/tools/xcode/xcrunwrapper/xcrunwrapper.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# Copyright 2015 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# xcrunwrapper runs the command passed to it using xcrun.
+# It replaces __BAZEL_XCODE_DEVELOPER_DIR__ with $DEVELOPER_DIR (or reasonable
+# default) and __BAZEL_XCODE_SDKROOT__ with a valid path based on SDKROOT (or
+# reasonable default).
+# These values (__BAZEL_XCODE_*) are a shared secret withIosSdkCommands.java.
+
+set -eu
+
+# Pick values for DEVELOPER_DIR and SDKROOT as appropriate (if they weren't set)
+
+WRAPPER_DEVDIR="${DEVELOPER_DIR:-}"
+if [[ -z "${WRAPPER_DEVDIR}" ]] ; then
+ WRAPPER_DEVDIR="$(xcode-select -p)"
+fi
+
+# TODO(blaze-team): Remove this once all build environments are setting SDKROOT
+# for us.
+WRAPPER_SDKROOT="${SDKROOT:-}"
+if [[ -z "${WRAPPER_SDKROOT:-}" ]] ; then
+ WRAPPER_SDK=iphonesimulator
+ for ARG in "$@" ; do
+ case "${ARG}" in
+ armv6|armv7|armv7s|arm64)
+ WRAPPER_SDK=iphoneos
+ ;;
+ i386|x86_64)
+ WRAPPER_SDK=iphonesimulator
+ ;;
+ esac
+ done
+ WRAPPER_SDKROOT="$(/usr/bin/xcrun --show-sdk-path --sdk ${WRAPPER_SDK})"
+fi
+
+UPDATEDARGS=()
+for ARG in "$@" ; do
+ ARG="${ARG//__BAZEL_XCODE_DEVELOPER_DIR__/${WRAPPER_DEVDIR}}"
+ ARG="${ARG//__BAZEL_XCODE_SDKROOT__/${WRAPPER_SDKROOT}}"
+ UPDATEDARGS+=("${ARG}")
+done
+
+/usr/bin/xcrun "${UPDATEDARGS[@]}"