aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/xcode/xcrunwrapper
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/xcrunwrapper
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/xcrunwrapper')
-rw-r--r--src/tools/xcode/xcrunwrapper/BUILD11
-rw-r--r--src/tools/xcode/xcrunwrapper/README7
-rwxr-xr-xsrc/tools/xcode/xcrunwrapper/xcrunwrapper.sh57
3 files changed, 75 insertions, 0 deletions
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[@]}"