aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-07-07 23:40:10 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-07-08 11:42:04 +0000
commit9cac1635f82e85765ec6e7e859cf5e270301f892 (patch)
treeefe2f82e9675384f2a3cc31aa519577891da60b7
parent766e96f76a9c62fd1b6779588874a6329080c2c1 (diff)
Moves ibtoolzip from src/tools/xcode-common/j/c/g/devtools/ to src/tools/xcode.
Moves ibtoolzip from being java based to being bash based for easier dev/testing. Changes the name of ibtoolzip to ibtoolwrapper to avoid conflicts with currently deployed bazel depending on the ibtoolzip name. Updates realpath Cleans up update_binaries.sh -- MOS_MIGRATED_REVID=97724252
-rwxr-xr-xcompile.sh6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java29
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java9
-rw-r--r--src/tools/xcode-common/BUILD1
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/BUILD17
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/IbtoolZip.java75
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/README4
-rw-r--r--src/tools/xcode/ibtoolwrapper/BUILD12
-rw-r--r--src/tools/xcode/ibtoolwrapper/README6
-rwxr-xr-xsrc/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh64
11 files changed, 113 insertions, 111 deletions
diff --git a/compile.sh b/compile.sh
index da1667abc7..30b97d0fac 100755
--- a/compile.sh
+++ b/compile.sh
@@ -109,8 +109,7 @@ if [ $DO_TOOLS_COMPILATION ]; then
if [[ $PLATFORM == "darwin" ]]; then
bazel_bootstrap //src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip:actoolzip_deploy.jar \
tools/objc/precomp_actoolzip_deploy.jar
- bazel_bootstrap //src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip:ibtoolzip_deploy.jar \
- tools/objc/precomp_ibtoolzip_deploy.jar
+ bazel_bootstrap //src/tools/xcode/ibtoolwrapper:ibtoolwrapper tools/objc/ibtoolwrapper
bazel_bootstrap //src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip:swiftstdlibtoolzip_deploy.jar \
tools/objc/precomp_swiftstdlibtoolzip_deploy.jar
bazel_bootstrap //src/objc_tools/momczip:momczip_deploy.jar \
@@ -123,8 +122,7 @@ if [ $DO_TOOLS_COMPILATION ]; then
tools/objc/precomp_xcodegen_deploy.jar
bazel_bootstrap //src/tools/xcode/stdredirect:StdRedirect.dylib \
tools/objc/StdRedirect.dylib
- bazel_bootstrap //src/tools/xcode/realpath:realpath \
- tools/objc/realpath
+ bazel_bootstrap //src/tools/xcode/realpath:realpath tools/objc/realpath
fi
fi
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
index 92a34708eb..9ace1d304e 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
@@ -198,11 +198,15 @@ final class BundleSupport {
Artifact zipOutput = intermediateArtifacts.compiledStoryboardZip(storyboardInput);
ruleContext.registerAction(
- ObjcRuleClasses.spawnJavaOnDarwinActionBuilder(attributes.ibtoolzipDeployJar())
+ ObjcRuleClasses.spawnOnDarwinActionBuilder()
.setMnemonic("StoryboardCompile")
+ .setExecutable(attributes.ibtoolwrapper())
.setCommandLine(ibActionsCommandLine(archiveRoot, zipOutput, storyboardInput))
.addOutput(zipOutput)
.addInput(storyboardInput)
+ // TODO(dmaclach): Adding realpath here should not be required once
+ // https://github.com/google/bazel/issues/285 is fixed.
+ .addInput(attributes.realpath())
.build(ruleContext));
}
}
@@ -213,7 +217,6 @@ final class BundleSupport {
// The next three arguments are positional, i.e. they don't have flags before them.
.addPath(zipOutput.getExecPath())
.add(archiveRoot)
- .addPath(ObjcRuleClasses.IBTOOL)
.add("--minimum-deployment-target").add(bundling.getMinimumOsVersion())
.add("--module").add(ruleContext.getLabel().getName());
@@ -262,12 +265,17 @@ final class BundleSupport {
Artifact zipOutput = intermediateArtifacts.compiledXibFileZip(original);
String archiveRoot = BundleableFile.flatBundlePath(
FileSystemUtils.replaceExtension(original.getExecPath(), ".nib"));
+
ruleContext.registerAction(
- ObjcRuleClasses.spawnJavaOnDarwinActionBuilder(attributes.ibtoolzipDeployJar())
+ ObjcRuleClasses.spawnOnDarwinActionBuilder()
.setMnemonic("XibCompile")
+ .setExecutable(attributes.ibtoolwrapper())
.setCommandLine(ibActionsCommandLine(archiveRoot, zipOutput, original))
.addOutput(zipOutput)
.addInput(original)
+ // TODO(dmaclach): Adding realpath here should not be required once
+ // https://github.com/google/bazel/issues/285 is fixed.
+ .addInput(attributes.realpath())
.build(ruleContext));
}
}
@@ -429,10 +437,19 @@ final class BundleSupport {
}
/**
- * Returns the location of the ibtoolzip deploy jar.
+ * Returns the location of the ibtoolwrapper tool.
+ */
+ FilesToRunProvider ibtoolwrapper() {
+ return ruleContext.getExecutablePrerequisite("$ibtoolwrapper", Mode.HOST);
+ }
+
+ /**
+ * Returns the location of the realpath tool.
+ * TODO(dmaclach): Should not be required once https://github.com/google/bazel/issues/285
+ * is fixed.
*/
- Artifact ibtoolzipDeployJar() {
- return ruleContext.getPrerequisiteArtifact("$ibtoolzip_deploy", Mode.HOST);
+ Artifact realpath() {
+ return ruleContext.getPrerequisiteArtifact("$realpath", Mode.HOST);
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java
index b788f7c0e0..7d0c2337a3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java
@@ -33,7 +33,6 @@ import java.util.List;
public class IosSdkCommands {
public static final String DEVELOPER_DIR = "/Applications/Xcode.app/Contents/Developer";
public static final String ACTOOL_PATH = DEVELOPER_DIR + "/usr/bin/actool";
- public static final String IBTOOL_PATH = DEVELOPER_DIR + "/usr/bin/ibtool";
public static final String MOMC_PATH = DEVELOPER_DIR + "/usr/bin/momc";
// There is a handy reference to many clang warning flags at
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
index 787decdbac..02d3566135 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
@@ -66,7 +66,6 @@ public class ObjcRuleClasses {
static final PathFragment LIBTOOL = new PathFragment(BIN_DIR + "/libtool");
static final PathFragment DSYMUTIL = new PathFragment(BIN_DIR + "/dsymutil");
static final PathFragment LIPO = new PathFragment(BIN_DIR + "/lipo");
- static final PathFragment IBTOOL = new PathFragment(IosSdkCommands.IBTOOL_PATH);
static final PathFragment SWIFT_STDLIB_TOOL = new PathFragment(BIN_DIR + "/swift-stdlib-tool");
static final PathFragment STRIP = new PathFragment(BIN_DIR + "/strip");
@@ -472,8 +471,12 @@ public class ObjcRuleClasses {
.value(env.getLabel("//tools/objc:plmerge")))
.add(attr("$actoolzip_deploy", LABEL).cfg(HOST)
.value(env.getLabel("//tools/objc:actoolzip_deploy.jar")))
- .add(attr("$ibtoolzip_deploy", LABEL).cfg(HOST)
- .value(env.getLabel("//tools/objc:ibtoolzip_deploy.jar")))
+ .add(attr("$ibtoolwrapper", LABEL).cfg(HOST).exec()
+ .value(env.getLabel("//tools/objc:ibtoolwrapper")))
+ // TODO(dmaclach): Adding realpath here should not be required once
+ // https://github.com/google/bazel/issues/285 is fixed.
+ .add(attr("$realpath", LABEL).cfg(HOST).exec()
+ .value(env.getLabel("//tools/objc:realpath")))
.add(attr("$swiftstdlibtoolzip_deploy", LABEL).cfg(HOST)
.value(env.getLabel("//tools/objc:swiftstdlibtoolzip_deploy.jar")))
.build();
diff --git a/src/tools/xcode-common/BUILD b/src/tools/xcode-common/BUILD
index 187e8c1dfe..639c621679 100644
--- a/src/tools/xcode-common/BUILD
+++ b/src/tools/xcode-common/BUILD
@@ -5,7 +5,6 @@ filegroup(
srcs = [
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip:srcs",
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/common:srcs",
- "//src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip:srcs",
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip:srcs",
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/util:srcs",
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/zip:srcs",
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/BUILD b/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/BUILD
deleted file mode 100644
index 7a9eab4da3..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/BUILD
+++ /dev/null
@@ -1,17 +0,0 @@
-package(default_visibility = ["//src:__subpackages__"])
-
-filegroup(
- name = "srcs",
- srcs = glob(["**"]),
-)
-
-java_binary(
- name = "ibtoolzip",
- srcs = ["IbtoolZip.java"],
- main_class = "com.google.devtools.build.xcode.ibtoolzip.IbtoolZip",
- visibility = ["//visibility:public"],
- deps = [
- "//src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput",
- "//third_party:guava",
- ],
-)
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/IbtoolZip.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/IbtoolZip.java
deleted file mode 100644
index 180f541bc8..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/IbtoolZip.java
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2014 Google Inc. 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.
-
-package com.google.devtools.build.xcode.ibtoolzip;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.devtools.build.xcode.zippingoutput.Arguments;
-import com.google.devtools.build.xcode.zippingoutput.Wrapper;
-import com.google.devtools.build.xcode.zippingoutput.Wrappers;
-
-import java.io.IOException;
-
-/**
- * A tool which wraps ibtool by running ibtool and zipping its output. See the JavaDoc for
- * {@link Wrapper} for more information.
- */
-public class IbtoolZip implements Wrapper {
-
- @Override
- public String name() {
- return "IbtoolZip";
- }
-
- @Override
- public String subtoolName() {
- return "ibtool";
- }
-
- @Override
- public Iterable<String> subCommand(Arguments args, String outputDirectory) {
- // 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>
- // IBToolDebugLogLevel=4
- // you may also see if
- // IBToolNeverDeque=1
- // helps.
-
- // IBTool needs to have absolute paths sent to it, so we call CANONICALIZE_IF_PATH
- // on all of them.
- // Radar 21045660 ibtool has difficulty dealing with relative paths.
- return new ImmutableList.Builder<String>()
- .add(args.subtoolCmd())
- .add("--errors")
- .add("--warnings")
- .add("--notices")
- .add("--auto-activate-custom-fonts")
- .add("--output-format").add("human-readable-text")
- .add("--compile")
- .add(Wrappers.CANONICALIZE_IF_PATH.apply(outputDirectory))
- .addAll(Iterables.transform(args.subtoolExtraArgs(), Wrappers.CANONICALIZE_IF_PATH))
- .build();
- }
-
- public static void main(String[] args) throws IOException, InterruptedException {
- Wrappers.executePipingOutput(args, new IbtoolZip());
- }
-
- @Override
- public boolean outputDirectoryMustExist() {
- return true;
- }
-}
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/README b/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/README
deleted file mode 100644
index a439bc4024..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/ibtoolzip/README
+++ /dev/null
@@ -1,4 +0,0 @@
-ibtoolzip runs ibtool, which compiles storyboards, and zips up the output,
-because ibtool returns an unpredictable number of output files.
-
-ibtool only runs on Darwin, so ibtoolzip only runs on Darwin.
diff --git a/src/tools/xcode/ibtoolwrapper/BUILD b/src/tools/xcode/ibtoolwrapper/BUILD
new file mode 100644
index 0000000000..434132b366
--- /dev/null
+++ b/src/tools/xcode/ibtoolwrapper/BUILD
@@ -0,0 +1,12 @@
+package(default_visibility = ["//src/test:__subpackages__"])
+
+filegroup(
+ name = "srcs",
+ srcs = glob(["**"]),
+)
+
+sh_binary(
+ name = "ibtoolwrapper",
+ srcs = ["ibtoolwrapper.sh"],
+ data = ["//src/tools/xcode/realpath:realpath_genrule"],
+)
diff --git a/src/tools/xcode/ibtoolwrapper/README b/src/tools/xcode/ibtoolwrapper/README
new file mode 100644
index 0000000000..46b88f1e99
--- /dev/null
+++ b/src/tools/xcode/ibtoolwrapper/README
@@ -0,0 +1,6 @@
+ibtoolwrapper runs ibtool, which compiles storyboards and xibs etc.
+ibtoolwrapper then zips up the output,
+because ibtool returns an unpredictable number of output files.
+
+ibtool only runs on Darwin, so ibtoolwrapper only runs on Darwin.
+
diff --git a/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh b/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh
new file mode 100755
index 0000000000..7cc4be3201
--- /dev/null
+++ b/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+# Copyright 2015 Google Inc. 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.
+#
+# ibtoolwrapper runs ibtool 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.
+# $2 ARCHIVEROOT - the path in the zip to place the output, or an empty
+# string for the root of the zip. e.g. 'Payload/foo.app'. If
+# this tool outputs a single file, ARCHIVEROOT is the name of
+# the only file in the zip file.
+
+set -eu
+
+OUTZIP=$(tools/objc/realpath "$1")
+ARCHIVEROOT="$2"
+shift 2
+TEMPDIR=$(mktemp -d -t ZippingOutput)
+trap "rm -rf \"$TEMPDIR\"" EXIT
+FULLPATH="$TEMPDIR/$ARCHIVEROOT"
+PARENTDIR=$(dirname "$FULLPATH")
+mkdir -p "$PARENTDIR"
+FULLPATH=$(tools/objc/realpath "$FULLPATH")
+
+# IBTool needs to have absolute paths sent to it, so we call realpaths on
+# on all arguments seeing if we can expand them.
+# Radar 21045660 ibtool has difficulty dealing with relative paths.
+IBTOOLARGS=()
+for i in $@; do
+ if [ -e "$i" ]; then
+ IBTOOLARGS+=($(tools/objc/realpath "$i"))
+ else
+ IBTOOLARGS+=($i)
+ fi
+done
+
+# 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>
+# IBToolDebugLogLevel=4
+# you may also see if
+# IBToolNeverDeque=1
+# helps.
+/usr/bin/xcrun ibtool --errors --warnings --notices \
+ --auto-activate-custom-fonts --output-format human-readable-text \
+ --compile "$FULLPATH" ${IBTOOLARGS[@]}
+
+# Need to push/pop tempdir so it isn't the current working directory
+# when we remove it via the EXIT trap.
+pushd "$TEMPDIR" > /dev/null
+zip -y -r -q "$OUTZIP" .
+popd > /dev/null