Skip to content

Commit

Permalink
Rollback of commit da3cb80.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breaking builds. []

*** Original change description ***

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=99742398
  • Loading branch information
Googler authored and damienmg committed Aug 4, 2015
1 parent 5245510 commit 46e8057
Show file tree
Hide file tree
Showing 29 changed files with 348 additions and 271 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
/tools/jdk/GenClass_deploy.jar
/tools/jdk/SingleJar_deploy.jar
/tools/objc/*.jar
/tools/objc/actoolwrapper.sh
/tools/objc/ibtoolwrapper.sh
/tools/objc/momctoolwrapper.sh
/tools/objc/ibtoolwrapper
/tools/objc/realpath
/tools/objc/StdRedirect.dylib
/tools/objc/swiftstdlibtoolwrapper.sh
11 changes: 7 additions & 4 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ 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/actoolwrapper:actoolwrapper tools/objc/actoolwrapper.sh 0755
bazel_bootstrap //src/tools/xcode/ibtoolwrapper:ibtoolwrapper tools/objc/ibtoolwrapper.sh 0755
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/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip:actoolzip_deploy.jar \
tools/objc/precomp_actoolzip_deploy.jar
bazel_bootstrap //src/tools/xcode/ibtoolwrapper:ibtoolwrapper tools/objc/ibtoolwrapper 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/objc_tools/bundlemerge:bundlemerge_deploy.jar \
tools/objc/precomp_bundlemerge_deploy.jar
bazel_bootstrap //src/objc_tools/plmerge:plmerge_deploy.jar \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void registerInterfaceBuilderActions(ObjcProvider objcProvider) {
ruleContext.registerAction(
ObjcRuleClasses.spawnOnDarwinActionBuilder()
.setMnemonic("StoryboardCompile")
.setExecutable(attributes.ibtoolWrapper())
.setExecutable(attributes.ibtoolwrapper())
.setCommandLine(ibActionsCommandLine(archiveRoot, zipOutput, storyboardInput))
.addOutput(zipOutput)
.addInput(storyboardInput)
Expand Down Expand Up @@ -238,17 +238,15 @@ private void registerMomczipActions(ObjcProvider objcProvider) {
for (Xcdatamodel datamodel : xcdatamodels) {
Artifact outputZip = datamodel.getOutputZip();
ruleContext.registerAction(
ObjcRuleClasses.spawnOnDarwinActionBuilder()
ObjcRuleClasses.spawnJavaOnDarwinActionBuilder(attributes.momczipDeployJar())
.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")
Expand All @@ -271,7 +269,7 @@ private void registerConvertXibsActions(ObjcProvider objcProvider) {
ruleContext.registerAction(
ObjcRuleClasses.spawnOnDarwinActionBuilder()
.setMnemonic("XibCompile")
.setExecutable(attributes.ibtoolWrapper())
.setExecutable(attributes.ibtoolwrapper())
.setCommandLine(ibActionsCommandLine(archiveRoot, zipOutput, original))
.addOutput(zipOutput)
.addInput(original)
Expand Down Expand Up @@ -350,15 +348,11 @@ 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.spawnOnDarwinActionBuilder()
ObjcRuleClasses.spawnJavaOnDarwinActionBuilder(attributes.actoolzipDeployJar())
.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,
Expand All @@ -372,6 +366,9 @@ 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());
Expand Down Expand Up @@ -442,7 +439,7 @@ ImmutableSet<TargetDeviceFamily> families() {
/**
* Returns the location of the ibtoolwrapper tool.
*/
FilesToRunProvider ibtoolWrapper() {
FilesToRunProvider ibtoolwrapper() {
return ruleContext.getExecutablePrerequisite("$ibtoolwrapper", Mode.HOST);
}

Expand All @@ -456,17 +453,17 @@ Artifact realpath() {
}

/**
* Returns the location of the momcwrapper.
* Returns the location of the momczip deploy jar.
*/
FilesToRunProvider momcWrapper() {
return ruleContext.getExecutablePrerequisite("$momcwrapper", Mode.HOST);
Artifact momczipDeployJar() {
return ruleContext.getPrerequisiteArtifact("$momczip_deploy", Mode.HOST);
}

/**
* Returns the location of the actoolwrapper.
* Returns the location of the actoolzip deploy jar.
*/
FilesToRunProvider actoolWrapper() {
return ruleContext.getExecutablePrerequisite("$actoolwrapper", Mode.HOST);
Artifact actoolzipDeployJar() {
return ruleContext.getPrerequisiteArtifact("$actoolzip_deploy", Mode.HOST);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*/
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/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ 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");
Expand Down Expand Up @@ -454,14 +455,16 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
return builder
.add(attr("$plmerge", LABEL).cfg(HOST).exec()
.value(env.getLabel("//tools/objc:plmerge")))
.add(attr("$actoolwrapper", LABEL).cfg(HOST).exec()
.value(env.getLabel("//tools/objc:actoolwrapper")))
.add(attr("$actoolzip_deploy", LABEL).cfg(HOST)
.value(env.getLabel("//tools/objc:actoolzip_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();
}
@Override
Expand Down Expand Up @@ -808,10 +811,8 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
<!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
.add(attr("families", STRING_LIST)
.value(ImmutableList.of(TargetDeviceFamily.IPHONE.getNameInRule())))
.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")))
.add(attr("$momczip_deploy", LABEL).cfg(HOST)
.value(env.getLabel("//tools/objc:momczip_deploy.jar")))
.build();
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ 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;
Expand All @@ -723,19 +725,17 @@ 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.strippedSingleArchitectureBinary());

ruleContext.registerAction(
ObjcRuleClasses.spawnOnDarwinActionBuilder()
ObjcRuleClasses.spawnJavaOnDarwinActionBuilder(attributes.swiftStdlibToolDeployJar())
.setMnemonic("SwiftStdlibCopy")
.setExecutable(attributes.swiftStdlibToolWrapper())
.setCommandLine(commandLine.build())
.addOutput(intermediateArtifacts.swiftFrameworksFileZip())
.addInput(intermediateArtifacts.strippedSingleArchitectureBinary())
// TODO(dmaclach): Adding realpath here should not be required once
// https://github.com/google/bazel/issues/285 is fixed.
.addInput(attributes.realpath())
.build(ruleContext));
}

Expand Down Expand Up @@ -832,18 +832,11 @@ 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 realpath tool.
* TODO(dmaclach): Should not be required once https://github.com/google/bazel/issues/285
* is fixed.
* Returns the location of the swiftstdlibtoolzip deploy jar.
*/
Artifact realpath() {
return ruleContext.getPrerequisiteArtifact("$realpath", Mode.HOST);
Artifact swiftStdlibToolDeployJar() {
return ruleContext.getPrerequisiteArtifact("$swiftstdlibtoolzip_deploy", Mode.HOST);
}

String bundleId() {
Expand Down Expand Up @@ -938,7 +931,9 @@ 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;
}
Expand Down
11 changes: 11 additions & 0 deletions src/objc_tools/momczip/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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",
],
)
2 changes: 2 additions & 0 deletions src/objc_tools/momczip/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
momczip invokes momc ("Managed object model compiler") and zips up the output,
as the number of output files is unpredictable.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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.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<String> subCommand(Arguments args, String outputDirectory) {
return new ImmutableList.Builder<String>()
.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;
}
}
6 changes: 3 additions & 3 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ 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/actoolwrapper",
"//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/ibtoolwrapper",
"//src/tools/xcode/momcwrapper",
"//src/tools/xcode/realpath",
"//src/tools/xcode/stdredirect:StdRedirect.dylib",
"//src/tools/xcode/swiftstdlibtoolwrapper",
"//third_party/iossim",
],
"//conditions:default": [],
Expand Down
8 changes: 4 additions & 4 deletions src/test/shell/bazel/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ EOF
# Sets up Objective-C tools. Mac only.
function setup_objc_test_support() {
mkdir -p tools/objc
[ -e tools/objc/actoolwrapper.jar ] || ln -sv ${actoolwrapper_path} tools/objc/actoolwrapper.sh
[ -e tools/objc/precomp_actoolzip_deploy.jar ] || ln -sv ${actoolzip_path} tools/objc/precomp_actoolzip_deploy.jar
[ -e tools/objc/ibtoolwrapper.sh ] || ln -sv ${ibtoolwrapper_path} tools/objc/ibtoolwrapper.sh
[ -e tools/objc/momcwrapper.sh ] || ln -sv ${momcwrapper_path} tools/objc/momcwrapper.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/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

mkdir -p third_party/iossim
Expand Down Expand Up @@ -294,7 +294,7 @@ function tear_down() {
# Simples assert to make the tests more readable
#
function assert_build() {
bazel build -s --verbose_failures $* || fail "Failed to build $*"
bazel build -s $* || fail "Failed to build $*"
}

function assert_build_output() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/shell/bazel/testenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ ijar_path="${TEST_SRCDIR}/third_party/ijar/ijar"

# iOS and Objective-C tooling
iossim_path="${TEST_SRCDIR}/third_party/iossim/iossim"
actoolwrapper_path="${TEST_SRCDIR}/src/tools/xcode/actoolwrapper/actoolwrapper.sh"
actoolzip_path="${TEST_SRCDIR}/src/tools/xcode-common/java/com/google/devtools/build/xcode/actoolzip/actoolzip_deploy.jar"
ibtoolwrapper_path="${TEST_SRCDIR}/src/tools/xcode/ibtoolwrapper/ibtoolwrapper.sh"
swiftstdlibtoolwrapper_path="${TEST_SRCDIR}/src/tools/xcode/swiftstdlibtoolwrapper/swiftstdlibtoolwrapper.sh"
momcwrapper_path="${TEST_SRCDIR}/src/tools/xcode/momcwrapper/momcwrapper.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"
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"
Expand Down
2 changes: 2 additions & 0 deletions src/tools/xcode-common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ 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",
Expand Down
Loading

0 comments on commit 46e8057

Please sign in to comment.