From 0bb2f0201bda365348f9543d83e53fa90b9134d0 Mon Sep 17 00:00:00 2001 From: Dave MacLachlan Date: Tue, 29 Sep 2015 19:21:29 +0000 Subject: [PATCH] Move actoolzip, momczip and swiftstdlibtoolzip to tools/xcode and convert them to scripts instead of java apps. RELNOTES: actoolzip, momczip and swiftstdlibtoolzip have all been made into bash scripts and have been renamed to actoolwrapper, momcwrapper and swiftstdlibtoolwrapper respectively. The old versions will be deleted in a later change. -- MOS_MIGRATED_REVID=104225062 --- .gitignore | 5 +- compile.sh | 9 +- .../build/lib/rules/objc/BundleSupport.java | 35 +++--- .../build/lib/rules/objc/IosSdkCommands.java | 2 - .../build/lib/rules/objc/ObjcRuleClasses.java | 13 +- .../rules/objc/ReleaseBundlingSupport.java | 30 +++-- src/objc_tools/momczip/BUILD | 11 -- src/objc_tools/momczip/README | 2 - .../devtools/build/xcode/momczip/MomcZip.java | 56 --------- src/test/shell/bazel/BUILD | 6 +- src/test/shell/bazel/test-setup.sh | 8 +- src/test/shell/bazel/testenv.sh | 6 +- src/tools/xcode-common/BUILD | 2 - .../build/xcode/actoolzip/ActoolZip.java | 116 ------------------ .../devtools/build/xcode/actoolzip/BUILD | 17 --- .../devtools/build/xcode/actoolzip/README | 4 - .../build/xcode/swiftstdlibtoolzip/BUILD | 17 --- .../build/xcode/swiftstdlibtoolzip/README | 4 - .../SwiftStdlibToolZip.java | 59 --------- src/tools/xcode/actoolwrapper/BUILD | 12 ++ src/tools/xcode/actoolwrapper/README | 6 + .../xcode/actoolwrapper/actoolwrapper.sh | 72 +++++++++++ .../xcode/ibtoolwrapper/ibtoolwrapper.sh | 18 ++- src/tools/xcode/momcwrapper/BUILD | 12 ++ src/tools/xcode/momcwrapper/README | 6 + src/tools/xcode/momcwrapper/momcwrapper.sh | 40 ++++++ src/tools/xcode/swiftstdlibtoolwrapper/BUILD | 12 ++ src/tools/xcode/swiftstdlibtoolwrapper/README | 6 + .../swiftstdlibtoolwrapper.sh | 40 ++++++ 29 files changed, 277 insertions(+), 349 deletions(-) delete mode 100644 src/objc_tools/momczip/BUILD delete mode 100644 src/objc_tools/momczip/README delete mode 100644 src/objc_tools/momczip/java/com/google/devtools/build/xcode/momczip/MomcZip.java delete mode 100644 src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/ActoolZip.java delete mode 100644 src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/BUILD delete mode 100644 src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/README delete mode 100644 src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/BUILD delete mode 100644 src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/README delete mode 100644 src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/SwiftStdlibToolZip.java create mode 100644 src/tools/xcode/actoolwrapper/BUILD create mode 100644 src/tools/xcode/actoolwrapper/README create mode 100755 src/tools/xcode/actoolwrapper/actoolwrapper.sh create mode 100644 src/tools/xcode/momcwrapper/BUILD create mode 100644 src/tools/xcode/momcwrapper/README create mode 100755 src/tools/xcode/momcwrapper/momcwrapper.sh create mode 100644 src/tools/xcode/swiftstdlibtoolwrapper/BUILD create mode 100644 src/tools/xcode/swiftstdlibtoolwrapper/README create mode 100755 src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh diff --git a/.gitignore b/.gitignore index a9e44e24276e9f..dc60d27e0d3768 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ /tools/jdk/GenClass_deploy.jar /tools/jdk/SingleJar_deploy.jar /tools/objc/*.jar -/tools/objc/ibtoolwrapper +/tools/objc/actoolwrapper.sh +/tools/objc/ibtoolwrapper.sh +/tools/objc/momctoolwrapper.sh /tools/objc/realpath /tools/objc/StdRedirect.dylib +/tools/objc/swiftstdlibtoolwrapper.sh diff --git a/compile.sh b/compile.sh index 4fb77a1a92edcf..dbf75bbe0078f0 100755 --- a/compile.sh +++ b/compile.sh @@ -109,13 +109,10 @@ if [ $DO_TOOLS_COMPILATION ]; then bazel_bootstrap //src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass:GenClass_deploy.jar \ tools/jdk/GenClass_deploy.jar 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/actoolwrapper:actoolwrapper tools/objc/actoolwrapper.sh 0755 bazel_bootstrap //src/tools/xcode/ibtoolwrapper:ibtoolwrapper tools/objc/ibtoolwrapper.sh 0755 - 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 \ - tools/objc/precomp_momczip_deploy.jar + bazel_bootstrap //src/tools/xcode/momcwrapper:momcwrapper tools/objc/momcwrapper.sh 0755 + bazel_bootstrap //src/tools/xcode/swiftstdlibtoolwrapper:swiftstdlibtoolwrapper tools/objc/swiftstdlibtoolzip.sh 0755 bazel_bootstrap //src/objc_tools/bundlemerge:bundlemerge_deploy.jar \ tools/objc/precomp_bundlemerge_deploy.jar bazel_bootstrap //src/objc_tools/plmerge:plmerge_deploy.jar \ 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 df0346feb8387b..cad27e149f2dee 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 @@ -225,7 +225,7 @@ private void registerInterfaceBuilderActions(ObjcProvider objcProvider) { ruleContext.registerAction( ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) .setMnemonic("StoryboardCompile") - .setExecutable(attributes.ibtoolwrapper()) + .setExecutable(attributes.ibtoolWrapper()) .setCommandLine(ibActionsCommandLine(archiveRoot, zipOutput, storyboardInput)) .addOutput(zipOutput) .addInput(storyboardInput) @@ -263,15 +263,17 @@ private void registerMomczipActions(ObjcProvider objcProvider) { for (Xcdatamodel datamodel : xcdatamodels) { Artifact outputZip = datamodel.getOutputZip(); ruleContext.registerAction( - ObjcRuleClasses.spawnJavaOnDarwinActionBuilder(ruleContext, attributes.momczipDeployJar()) + ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) .setMnemonic("MomCompile") + .setExecutable(attributes.momcWrapper()) .addOutput(outputZip) .addInputs(datamodel.getInputs()) + // TODO(dmaclach): Adding realpath here should not be required once + // https://github.com/google/bazel/issues/285 is fixed. + .addInput(attributes.realpath()) .setCommandLine(CustomCommandLine.builder() .addPath(outputZip.getExecPath()) .add(datamodel.archiveRootForMomczip()) - .add(IosSdkCommands.MOMC_PATH) - .add("-XD_MOMC_SDKROOT=" + IosSdkCommands.sdkDir(objcConfiguration)) .add("-XD_MOMC_IOS_TARGET_VERSION=" + bundling.getMinimumOsVersion()) .add("-MOMC_PLATFORMS") @@ -294,7 +296,7 @@ private void registerConvertXibsActions(ObjcProvider objcProvider) { ruleContext.registerAction( ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) .setMnemonic("XibCompile") - .setExecutable(attributes.ibtoolwrapper()) + .setExecutable(attributes.ibtoolWrapper()) .setCommandLine(ibActionsCommandLine(archiveRoot, zipOutput, original)) .addOutput(zipOutput) .addInput(original) @@ -373,11 +375,15 @@ private void registerActoolActionIfNecessary(ObjcProvider objcProvider) { // zip file will be rooted at the bundle root, and we have to prepend the bundle root to each // entry when merging it with the final .ipa file. ruleContext.registerAction( - ObjcRuleClasses.spawnJavaOnDarwinActionBuilder(ruleContext, attributes.actoolzipDeployJar()) + ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) .setMnemonic("AssetCatalogCompile") + .setExecutable(attributes.actoolWrapper()) .addTransitiveInputs(objcProvider.get(ASSET_CATALOG)) .addOutput(zipOutput) .addOutput(actoolPartialInfoplist) + // TODO(dmaclach): Adding realpath here should not be required once + // https://github.com/google/bazel/issues/285 is fixed. + .addInput(attributes.realpath()) .setCommandLine(actoolzipCommandLine( objcProvider, zipOutput, @@ -391,9 +397,6 @@ private CommandLine actoolzipCommandLine(ObjcProvider provider, Artifact zipOutp CustomCommandLine.Builder commandLine = CustomCommandLine.builder() // The next three arguments are positional, i.e. they don't have flags before them. .addPath(zipOutput.getExecPath()) - .add("") // archive root - .add(IosSdkCommands.ACTOOL_PATH) - .add("--platform").add(objcConfiguration.getBundlingPlatform().getLowerCaseNameInPlist()) .addExecPath("--output-partial-info-plist", partialInfoPlist) .add("--minimum-deployment-target").add(bundling.getMinimumOsVersion()); @@ -464,7 +467,7 @@ ImmutableSet families() { /** * Returns the location of the ibtoolwrapper tool. */ - FilesToRunProvider ibtoolwrapper() { + FilesToRunProvider ibtoolWrapper() { return ruleContext.getExecutablePrerequisite("$ibtoolwrapper", Mode.HOST); } @@ -478,17 +481,17 @@ Artifact realpath() { } /** - * Returns the location of the momczip deploy jar. + * Returns the location of the momcwrapper. */ - Artifact momczipDeployJar() { - return ruleContext.getPrerequisiteArtifact("$momczip_deploy", Mode.HOST); + FilesToRunProvider momcWrapper() { + return ruleContext.getExecutablePrerequisite("$momcwrapper", Mode.HOST); } /** - * Returns the location of the actoolzip deploy jar. + * Returns the location of the actoolwrapper. */ - Artifact actoolzipDeployJar() { - return ruleContext.getPrerequisiteArtifact("$actoolzip_deploy", Mode.HOST); + FilesToRunProvider actoolWrapper() { + return ruleContext.getExecutablePrerequisite("$actoolwrapper", 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 3a501487d7a988..e8248b93e826ef 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 @@ -32,8 +32,6 @@ */ 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 MOMC_PATH = DEVELOPER_DIR + "/usr/bin/momc"; // There is a handy reference to many clang warning flags at // http://nshipster.com/clang-diagnostics/ 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 a3ae6b4240e348..e21a9755d5608a 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 SWIFT_STDLIB_TOOL = new PathFragment(BIN_DIR + "/swift-stdlib-tool"); static final PathFragment STRIP = new PathFragment(BIN_DIR + "/strip"); private static final PathFragment JAVA = new PathFragment("/usr/bin/java"); @@ -499,16 +498,14 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { return builder .add(attr("$plmerge", LABEL).cfg(HOST).exec() .value(env.getLabel("//tools/objc:plmerge"))) - .add(attr("$actoolzip_deploy", LABEL).cfg(HOST) - .value(env.getLabel("//tools/objc:actoolzip_deploy.jar"))) + .add(attr("$actoolwrapper", LABEL).cfg(HOST).exec() + .value(env.getLabel("//tools/objc:actoolwrapper"))) .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/bazelbuild/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(); } @Override @@ -892,8 +889,10 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { */ .add(attr("families", STRING_LIST) .value(ImmutableList.of(TargetDeviceFamily.IPHONE.getNameInRule()))) - .add(attr("$momczip_deploy", LABEL).cfg(HOST) - .value(env.getLabel("//tools/objc:momczip_deploy.jar"))) + .add(attr("$momcwrapper", LABEL).cfg(HOST).exec() + .value(env.getLabel("//tools/objc:momcwrapper"))) + .add(attr("$swiftstdlibtoolwrapper", LABEL).cfg(HOST).exec() + .value(env.getLabel("//tools/objc:swiftstdlibtoolwrapper"))) .build(); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java index f68fcbc7bca394..cef5c00cd731a5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java @@ -739,9 +739,7 @@ private void registerEntitlementsVariableSubstitutionAction(Artifact in, Artifac .build(ruleContext)); } - /** - * Registers an action to copy Swift standard library dylibs into app bundle. - */ + /** Registers an action to copy Swift standard library dylibs into app bundle. */ private void registerSwiftStdlibActionsIfNecessary() { if (!objcProvider.is(USES_SWIFT)) { return; @@ -751,18 +749,19 @@ private void registerSwiftStdlibActionsIfNecessary() { CustomCommandLine.Builder commandLine = CustomCommandLine.builder() .addPath(intermediateArtifacts.swiftFrameworksFileZip().getExecPath()) - .add("Frameworks") - .addPath(ObjcRuleClasses.SWIFT_STDLIB_TOOL) .add("--platform").add(IosSdkCommands.swiftPlatform(objcConfiguration)) .addExecPath("--scan-executable", intermediateArtifacts.combinedArchitectureBinary()); ruleContext.registerAction( - ObjcRuleClasses.spawnJavaOnDarwinActionBuilder( - ruleContext, attributes.swiftStdlibToolDeployJar()) + ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) .setMnemonic("SwiftStdlibCopy") + .setExecutable(attributes.swiftStdlibToolWrapper()) .setCommandLine(commandLine.build()) .addOutput(intermediateArtifacts.swiftFrameworksFileZip()) .addInput(intermediateArtifacts.combinedArchitectureBinary()) + // TODO(dmaclach): Adding realpath here should not be required once + // https://github.com/google/bazel/issues/285 is fixed. + .addInput(attributes.realpath()) .build(ruleContext)); } @@ -859,11 +858,18 @@ Artifact runnerScriptTemplate() { ruleContext.getPrerequisiteArtifact("$runner_script_template", Mode.HOST)); } + /** Returns the location of the swiftstdlibtoolwrapper. */ + FilesToRunProvider swiftStdlibToolWrapper() { + return ruleContext.getExecutablePrerequisite("$swiftstdlibtoolwrapper", Mode.HOST); + } + /** - * Returns the location of the swiftstdlibtoolzip deploy jar. + * Returns the location of the realpath tool. + * TODO(dmaclach): Should not be required once https://github.com/google/bazel/issues/285 + * is fixed. */ - Artifact swiftStdlibToolDeployJar() { - return ruleContext.getPrerequisiteArtifact("$swiftstdlibtoolzip_deploy", Mode.HOST); + Artifact realpath() { + return ruleContext.getPrerequisiteArtifact("$realpath", Mode.HOST); } /** @@ -966,9 +972,7 @@ public boolean defaultsToSelf() { return true; } - /** - * Returns the configuration distinguisher for this transition instance. - */ + /** Returns the configuration distinguisher for this transition instance. */ protected ConfigurationDistinguisher getConfigurationDistinguisher() { return ConfigurationDistinguisher.APPLICATION; } diff --git a/src/objc_tools/momczip/BUILD b/src/objc_tools/momczip/BUILD deleted file mode 100644 index a2ae946d60be0b..00000000000000 --- a/src/objc_tools/momczip/BUILD +++ /dev/null @@ -1,11 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -java_binary( - name = "momczip", - srcs = glob(["java/**/*.java"]), - main_class = "com.google.devtools.build.xcode.momczip.MomcZip", - deps = [ - "//src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput", - "//third_party:guava", - ], -) diff --git a/src/objc_tools/momczip/README b/src/objc_tools/momczip/README deleted file mode 100644 index 1c87f43a5c9602..00000000000000 --- a/src/objc_tools/momczip/README +++ /dev/null @@ -1,2 +0,0 @@ -momczip invokes momc ("Managed object model compiler") and zips up the output, -as the number of output files is unpredictable. diff --git a/src/objc_tools/momczip/java/com/google/devtools/build/xcode/momczip/MomcZip.java b/src/objc_tools/momczip/java/com/google/devtools/build/xcode/momczip/MomcZip.java deleted file mode 100644 index 7700cee06bbc90..00000000000000 --- a/src/objc_tools/momczip/java/com/google/devtools/build/xcode/momczip/MomcZip.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 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. - -package com.google.devtools.build.xcode.momczip; - -import com.google.common.collect.ImmutableList; -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 momc, by running momc and zipping its output. See the JavaDoc for - * {@link Wrapper} for more information. - */ -public class MomcZip implements Wrapper { - @Override - public String name() { - return "MomcZip"; - } - - @Override - public String subtoolName() { - return "momc"; - } - - @Override - public Iterable subCommand(Arguments args, String outputDirectory) { - return new ImmutableList.Builder() - .add(args.subtoolCmd()) - .addAll(args.subtoolExtraArgs()) - .add(outputDirectory) - .build(); - } - - public static void main(String[] args) throws IOException, InterruptedException { - Wrappers.executePipingOutput(args, new MomcZip()); - } - - @Override - public boolean outputDirectoryMustExist() { - return false; - } -} diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 7ce57f5696fda3..6d79b7e1de25e4 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -19,15 +19,15 @@ filegroup( srcs = select({ ":darwin": [ "//src/objc_tools/bundlemerge:bundlemerge_deploy.jar", - "//src/objc_tools/momczip:momczip_deploy.jar", "//src/objc_tools/plmerge:plmerge_deploy.jar", "//src/objc_tools/xcodegen:xcodegen_deploy.jar", - "//src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip:actoolzip_deploy.jar", - "//src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip:swiftstdlibtoolzip_deploy.jar", + "//src/tools/xcode/actoolwrapper", "//src/tools/xcode/environment:environment_plist", "//src/tools/xcode/ibtoolwrapper", + "//src/tools/xcode/momcwrapper", "//src/tools/xcode/realpath", "//src/tools/xcode/stdredirect:StdRedirect.dylib", + "//src/tools/xcode/swiftstdlibtoolwrapper", "//third_party/iossim", ], "//conditions:default": [], diff --git a/src/test/shell/bazel/test-setup.sh b/src/test/shell/bazel/test-setup.sh index 088ff6c3f2cba8..fbde4411ac56ed 100755 --- a/src/test/shell/bazel/test-setup.sh +++ b/src/test/shell/bazel/test-setup.sh @@ -316,14 +316,14 @@ EOF # Sets up Objective-C tools. Mac only. function setup_objc_test_support() { mkdir -p tools/objc - [ -e tools/objc/precomp_actoolzip_deploy.jar ] || ln -sv ${actoolzip_path} tools/objc/precomp_actoolzip_deploy.jar + [ -e tools/objc/actoolwrapper.jar ] || ln -sv ${actoolwrapper_path} tools/objc/actoolwrapper.sh [ -e tools/objc/ibtoolwrapper.sh ] || ln -sv ${ibtoolwrapper_path} tools/objc/ibtoolwrapper.sh - [ -e tools/objc/precomp_swiftstdlibtoolzip_deploy.jar ] || ln -sv ${swiftstdlibtoolzip_path} tools/objc/precomp_swiftstdlibtoolzip_deploy.jar - [ -e tools/objc/precomp_momczip_deploy.jar ] || ln -sv ${momczip_path} tools/objc/precomp_momczip_deploy.jar + [ -e tools/objc/momcwrapper.sh ] || ln -sv ${momcwrapper_path} tools/objc/momcwrapper.sh [ -e tools/objc/precomp_bundlemerge_deploy.jar ] || ln -sv ${bundlemerge_path} tools/objc/precomp_bundlemerge_deploy.jar [ -e tools/objc/precomp_plmerge_deploy.jar ] || ln -sv ${plmerge_path} tools/objc/precomp_plmerge_deploy.jar [ -e tools/objc/precomp_xcodegen_deploy.jar ] || ln -sv ${xcodegen_path} tools/objc/precomp_xcodegen_deploy.jar [ -e tools/objc/StdRedirect.dylib ] || ln -sv ${stdredirect_path} tools/objc/StdRedirect.dylib + [ -e tools/objc/swiftstdlibtoolwrapper.sh ] || ln -sv ${swiftstdlibtoolwrapper_path} tools/objc/swiftstdlibtoolwrapper.sh [ -e tools/objc/realpath ] || ln -sv ${realpath_path} tools/objc/realpath [ -e tools/objc/environment_plist.sh ] || ln -sv ${environment_plist_path} tools/objc/environment_plist.sh @@ -413,7 +413,7 @@ function tear_down() { # Simples assert to make the tests more readable # function assert_build() { - bazel build -s $* || fail "Failed to build $*" + bazel build -s --verbose_failures $* || fail "Failed to build $*" } function assert_build_output() { diff --git a/src/test/shell/bazel/testenv.sh b/src/test/shell/bazel/testenv.sh index a3b5569ee060ae..de0269348dfba6 100755 --- a/src/test/shell/bazel/testenv.sh +++ b/src/test/shell/bazel/testenv.sh @@ -53,10 +53,10 @@ incrementaldeployment_path="${TEST_SRCDIR}/src/tools/android/java/com/google/dev # iOS and Objective-C tooling iossim_path="${TEST_SRCDIR}/third_party/iossim/iossim" -actoolzip_path="${TEST_SRCDIR}/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/actoolzip_deploy.jar" +actoolwrapper_path="${TEST_SRCDIR}/src/tools/xcode/actoolwrapper/actoolwrapper.sh" ibtoolwrapper_path="${TEST_SRCDIR}/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh" -swiftstdlibtoolzip_path="${TEST_SRCDIR}/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/swiftstdlibtoolzip_deploy.jar" -momczip_path="${TEST_SRCDIR}/src/objc_tools/momczip/momczip_deploy.jar" +swiftstdlibtoolwrapper_path="${TEST_SRCDIR}/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh" +momcwrapper_path="${TEST_SRCDIR}/src/tools/xcode/momcwrapper/momcwrapper.sh" bundlemerge_path="${TEST_SRCDIR}/src/objc_tools/bundlemerge/bundlemerge_deploy.jar" plmerge_path="${TEST_SRCDIR}/src/objc_tools/plmerge/plmerge_deploy.jar" xcodegen_path="${TEST_SRCDIR}/src/objc_tools/xcodegen/xcodegen_deploy.jar" diff --git a/src/tools/xcode-common/BUILD b/src/tools/xcode-common/BUILD index 639c62167949ea..bfd7849aef156b 100644 --- a/src/tools/xcode-common/BUILD +++ b/src/tools/xcode-common/BUILD @@ -3,9 +3,7 @@ package(default_visibility = ["//src/test:__subpackages__"]) filegroup( name = "srcs", 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/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", "//src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput:srcs", diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/ActoolZip.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/ActoolZip.java deleted file mode 100644 index ddb64e59fb618a..00000000000000 --- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/ActoolZip.java +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2014 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. - -package com.google.devtools.build.xcode.actoolzip; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -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 com.google.devtools.build.xcode.zippingoutput.Wrappers.CommandFailedException; -import com.google.devtools.build.xcode.zippingoutput.Wrappers.OutErr; - -import java.io.File; -import java.io.IOException; -import java.util.Set; - -/** - * A tool which wraps actool by running actool and zipping its output. See the JavaDoc for - * {@link Wrapper} for more information. - */ -public class ActoolZip implements Wrapper { - - @Override - public String name() { - return "ActoolZip"; - } - - @Override - public String subtoolName() { - return "actool"; - } - - @Override - public Iterable subCommand(Arguments args, String outputDirectory) { - return new ImmutableList.Builder() - .add(args.subtoolCmd()) - .add("--output-format").add("human-readable-text") - .add("--notices") - .add("--warnings") - .add("--errors") - .add("--compress-pngs") - .add("--compile") - .add(outputDirectory) - // actool munges paths in some way which doesn't work if one of the directories in the path - // is a symlink. - .addAll(Iterables.transform(args.subtoolExtraArgs(), Wrappers.CANONICALIZE_IF_PATH)) - .build(); - } - - public static void main(String[] args) throws IOException, InterruptedException { - Optional infoPlistPath = replaceInfoPlistPath(args); - try { - OutErr outErr = Wrappers.executeCapturingOutput(args, new ActoolZip()); - if (infoPlistPath.isPresent() && !infoPlistPath.get().exists()) { - outErr.print(); - System.exit(1); - } - } catch (CommandFailedException e) { - Wrappers.handleException(e); - } - } - - /** - * Absolute-ify output partial info plist's path. - * - *

actool occasionally writes the partial info plist file to the wrong directory if a - * non-absolute path is passed as --output-partial-info-plist, so we optimistically try to - * absolute-ify its path. This isn't caught by the "CANONICAL_PATH" transform above, because the - * file doesn't exist at the time of flag parsing. - * - *

Modifies args in-place. - * - * @return new value of the output-partial-info-plist flag. - */ - private static Optional replaceInfoPlistPath(String[] args) { - String flag = "output-partial-info-plist"; - Set flagOptions = ImmutableSet.of( - "-" + flag, - "--" + flag); - Optional newPath = Optional.absent(); - for (int i = 0; i < args.length; ++i) { - for (String flagOption : flagOptions) { - String arg = args[i]; - String flagEquals = flagOption + "="; - if (arg.startsWith(flagEquals)) { - newPath = Optional.of(new File(arg.substring(flagEquals.length()))); - args[i] = flagEquals + newPath.get().getAbsolutePath(); - } - if (arg.equals(flagOption) && i + 1 < args.length) { - newPath = Optional.of(new File(args[i + 1])); - args[i + 1] = newPath.get().getAbsolutePath(); - } - } - } - return newPath; - } - - @Override - public boolean outputDirectoryMustExist() { - return true; - } -} diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/BUILD b/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/BUILD deleted file mode 100644 index 8e08b62c8221db..00000000000000 --- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/BUILD +++ /dev/null @@ -1,17 +0,0 @@ -package(default_visibility = ["//src:__subpackages__"]) - -filegroup( - name = "srcs", - srcs = glob(["**"]), -) - -java_binary( - name = "actoolzip", - srcs = ["ActoolZip.java"], - main_class = "com.google.devtools.build.xcode.actoolzip.ActoolZip", - 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/actoolzip/README b/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/README deleted file mode 100644 index 7aaae168bbb136..00000000000000 --- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/README +++ /dev/null @@ -1,4 +0,0 @@ -actoolzip runs actool, which compiles asset catalog files and zips up the -output, because actool returns an unpredictable number of output files. - -actool only runs on Darwin, so actoolzip only runs on Darwin. diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/BUILD b/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/BUILD deleted file mode 100644 index b42968804a9911..00000000000000 --- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/BUILD +++ /dev/null @@ -1,17 +0,0 @@ -package(default_visibility = ["//src:__subpackages__"]) - -filegroup( - name = "srcs", - srcs = glob(["**"]), -) - -java_binary( - name = "swiftstdlibtoolzip", - srcs = ["SwiftStdlibToolZip.java"], - main_class = "com.google.devtools.build.xcode.swiftstdlibtoolzip.SwiftStdlibToolZip", - 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/swiftstdlibtoolzip/README b/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/README deleted file mode 100644 index 0c8b3f082d0bd3..00000000000000 --- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/README +++ /dev/null @@ -1,4 +0,0 @@ -swiftstdlibtoolzip runs swift-stdlib-tool, which scans executables and copies required Swift -framework dylibs to the specified path, then zips up the output for further bundle merging. - -swift-stdlib-tool only runs on Darwin, so swiftstdlibtoolzip only runs on Darwin. diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/SwiftStdlibToolZip.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/SwiftStdlibToolZip.java deleted file mode 100644 index 9c8239789841be..00000000000000 --- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/swiftstdlibtoolzip/SwiftStdlibToolZip.java +++ /dev/null @@ -1,59 +0,0 @@ -// 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. - -package com.google.devtools.build.xcode.swiftstdlibtoolzip; - -import com.google.common.collect.ImmutableList; -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 swift-stdlib-tool by running and zipping its output. See {@link Wrapper} for - * more information. - */ -public class SwiftStdlibToolZip implements Wrapper { - - @Override - public String name() { - return "SwiftStdlibToolZip"; - } - - @Override - public String subtoolName() { - return "swift-stdlib-tool"; - } - - @Override - public Iterable subCommand(Arguments arguments, String outputDirectory) { - return new ImmutableList.Builder() - .add(arguments.subtoolCmd()) - .addAll(arguments.subtoolExtraArgs()) - .add("--copy") - .add("--verbose") - .add("--destination").add(outputDirectory) - .build(); - } - - @Override - public boolean outputDirectoryMustExist() { - return true; - } - - public static void main(String[] args) throws IOException, InterruptedException { - Wrappers.executePipingOutput(args, new SwiftStdlibToolZip()); - } -} diff --git a/src/tools/xcode/actoolwrapper/BUILD b/src/tools/xcode/actoolwrapper/BUILD new file mode 100644 index 00000000000000..79bfdd6edae373 --- /dev/null +++ b/src/tools/xcode/actoolwrapper/BUILD @@ -0,0 +1,12 @@ +package(default_visibility = ["//src/test:__subpackages__"]) + +filegroup( + name = "srcs", + srcs = glob(["**"]), +) + +sh_binary( + name = "actoolwrapper", + srcs = ["actoolwrapper.sh"], + data = ["//src/tools/xcode/realpath:realpath_genrule"], +) diff --git a/src/tools/xcode/actoolwrapper/README b/src/tools/xcode/actoolwrapper/README new file mode 100644 index 00000000000000..d274e63ec16e77 --- /dev/null +++ b/src/tools/xcode/actoolwrapper/README @@ -0,0 +1,6 @@ +actoolwrapper runs actool, which compiles asset catalog files. +actoolwrapper then zips up the output, because actool returns an unpredictable +number of output files. + +actool only runs on Darwin, so actoolwrapper only runs on Darwin. + diff --git a/src/tools/xcode/actoolwrapper/actoolwrapper.sh b/src/tools/xcode/actoolwrapper/actoolwrapper.sh new file mode 100755 index 00000000000000..21fb17fc933c2b --- /dev/null +++ b/src/tools/xcode/actoolwrapper/actoolwrapper.sh @@ -0,0 +1,72 @@ +#!/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. +# +# actoolwrapper runs actool 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. + +set -eu + +OUTZIP=$(tools/objc/realpath "$1") +shift 1 +TEMPDIR=$(mktemp -d -t actoolZippingOutput) +trap "rm -rf \"$TEMPDIR\"" EXIT + +# actool needs to have absolute paths sent to it, so we call realpaths on +# on all arguments seeing if we can expand them. +# The argument for --output-partial-info-plist doesn't actually exist at the +# time of flag parsing, so we create it so that we can call realpaths on it +# to make the path absolute. +# actool and ibtool appear to depend on the same code base. +# Radar 21045660 ibtool has difficulty dealing with relative paths. + +TOOLARGS=() +LASTARG="" +for i in $@; do + if [ "$LASTARG" = "--output-partial-info-plist" ]; then + touch "$i" + fi + if [ -e "$i" ]; then + ARG=$(tools/objc/realpath "$i") + TOOLARGS+=("$ARG") + else + TOOLARGS+=("$i") + fi + LASTARG="$i" +done + +# 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= +# IBToolDebugLogLevel=4 +# you may also see if +# IBToolNeverDeque=1 +# 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 \ + --compress-pngs --output-format human-readable-text \ + --compile "$TEMPDIR" "${TOOLARGS[@]}" + +# 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 +# Reset all dates to Zip Epoch so that two identical zips created at different +# times appear the exact same for comparison purposes. +find . -exec touch -h -t 198001010000 {} \; +zip --symlinks --recurse-paths --quiet "$OUTZIP" . +popd > /dev/null diff --git a/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh b/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh index 4418dd6153074a..b8252ac01b2792 100755 --- a/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh +++ b/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh @@ -1,4 +1,5 @@ #!/bin/bash +# # Copyright 2015 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,8 +28,9 @@ set -eu OUTZIP=$(tools/objc/realpath "$1") ARCHIVEROOT="$2" shift 2 -TEMPDIR=$(mktemp -d -t ZippingOutput) +TEMPDIR=$(mktemp -d -t ibtoolZippingOutput) trap "rm -rf \"$TEMPDIR\"" EXIT + FULLPATH="$TEMPDIR/$ARCHIVEROOT" PARENTDIR=$(dirname "$FULLPATH") mkdir -p "$PARENTDIR" @@ -37,12 +39,13 @@ 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=() +TOOLARGS=() for i in $@; do if [ -e "$i" ]; then - IBTOOLARGS+=($(tools/objc/realpath "$i")) + ARG=$(tools/objc/realpath "$i") + TOOLARGS+=("$ARG") else - IBTOOLARGS+=($i) + TOOLARGS+=("$i") fi done @@ -55,10 +58,13 @@ done # helps. /usr/bin/xcrun ibtool --errors --warnings --notices \ --auto-activate-custom-fonts --output-format human-readable-text \ - --compile "$FULLPATH" ${IBTOOLARGS[@]} + --compile "$FULLPATH" "${TOOLARGS[@]}" # 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" . +# Reset all dates to Zip Epoch so that two identical zips created at different +# times appear the exact same for comparison purposes. +find . -exec touch -h -t 198001010000 {} \; +zip --symlinks --recurse-paths --quiet "$OUTZIP" . popd > /dev/null diff --git a/src/tools/xcode/momcwrapper/BUILD b/src/tools/xcode/momcwrapper/BUILD new file mode 100644 index 00000000000000..61acf80960d1c9 --- /dev/null +++ b/src/tools/xcode/momcwrapper/BUILD @@ -0,0 +1,12 @@ +package(default_visibility = ["//src/test:__subpackages__"]) + +filegroup( + name = "srcs", + srcs = glob(["**"]), +) + +sh_binary( + name = "momcwrapper", + srcs = ["momcwrapper.sh"], + data = ["//src/tools/xcode/realpath:realpath_genrule"], +) diff --git a/src/tools/xcode/momcwrapper/README b/src/tools/xcode/momcwrapper/README new file mode 100644 index 00000000000000..37654de4297eed --- /dev/null +++ b/src/tools/xcode/momcwrapper/README @@ -0,0 +1,6 @@ +momcwrapper runs momc, which compiles xcdatamodels. +momcwrapper then zips up the output, because momc returns an unpredictable +number of output files. + +momc only runs on Darwin, so momcwrapper only runs on Darwin. + diff --git a/src/tools/xcode/momcwrapper/momcwrapper.sh b/src/tools/xcode/momcwrapper/momcwrapper.sh new file mode 100755 index 00000000000000..43c03695f4685d --- /dev/null +++ b/src/tools/xcode/momcwrapper/momcwrapper.sh @@ -0,0 +1,40 @@ +#!/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. +# +# momcwrapper runs momc 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 NAME - output file name + +set -eu + +OUTZIP=$(tools/objc/realpath "$1") +NAME="$2" +shift 2 +TEMPDIR=$(mktemp -d -t momcZippingOutput) +trap "rm -rf \"$TEMPDIR\"" EXIT + +/usr/bin/xcrun momc "$@" "$TEMPDIR/$NAME" + +# 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 +# Reset all dates to Zip Epoch so that two identical zips created at different +# times appear the exact same for comparison purposes. +find . -exec touch -h -t 198001010000 {} \; +zip --symlinks --recurse-paths --quiet "$OUTZIP" . +popd > /dev/null diff --git a/src/tools/xcode/swiftstdlibtoolwrapper/BUILD b/src/tools/xcode/swiftstdlibtoolwrapper/BUILD new file mode 100644 index 00000000000000..1a98848a4bcf89 --- /dev/null +++ b/src/tools/xcode/swiftstdlibtoolwrapper/BUILD @@ -0,0 +1,12 @@ +package(default_visibility = ["//src/test:__subpackages__"]) + +filegroup( + name = "srcs", + srcs = glob(["**"]), +) + +sh_binary( + name = "swiftstdlibtoolwrapper", + srcs = ["swiftstdlibtoolwrapper.sh"], + data = ["//src/tools/xcode/realpath:realpath_genrule"], +) diff --git a/src/tools/xcode/swiftstdlibtoolwrapper/README b/src/tools/xcode/swiftstdlibtoolwrapper/README new file mode 100644 index 00000000000000..e99ff4ed02aaf6 --- /dev/null +++ b/src/tools/xcode/swiftstdlibtoolwrapper/README @@ -0,0 +1,6 @@ +swiftstdlibtoolwrapper runs swift-stdlib-tool, which scans executables and +copies required Swift framework dylibs to the specified path, then zips up +the output for further bundle merging. + +swift-stdlib-tool only runs on Darwin, so swiftstdlibtoolwrapper only runs on +Darwin. diff --git a/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh b/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh new file mode 100755 index 00000000000000..208f22e35ed0c5 --- /dev/null +++ b/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh @@ -0,0 +1,40 @@ +#!/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. +# +# 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. + +set -eu + +OUTZIP=$(tools/objc/realpath "$1") +shift 1 +TEMPDIR=$(mktemp -d -t swiftstdlibtoolZippingOutput) +trap "rm -rf \"$TEMPDIR\"" EXIT + +FULLPATH="$TEMPDIR/Frameworks" + +/usr/bin/xcrun 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. +pushd "$TEMPDIR" > /dev/null +# Reset all dates to Zip Epoch so that two identical zips created at different +# times appear the exact same for comparison purposes. +find . -exec touch -h -t 198001010000 {} \; +zip --symlinks --recurse-paths --quiet "$OUTZIP" . +popd > /dev/null