aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
diff options
context:
space:
mode:
authorGravatar Cal Peyser <cpeyser@google.com>2015-12-30 14:55:09 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-01-04 12:58:27 +0000
commit4bd593aaad907f4266ad510fb395638f2126a4ea (patch)
tree47a69dc822595fb2b270147531a17ac458dc8b19 /src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java
parenteffa572812043181d05f8d7375f89bddbb4d9ee0 (diff)
Ensure that the plist inside an .ipa bundle produced by blaze and the adjacent plist read by xcode are identical.
To do this, we use the output of plmerge as the single plist for the bundle. Automatic entries and variable substitutions are both computed in blaze and passed into plmerge. The output of plmerge is passed into bundlemerge to be placed directly into the final bundle. -- MOS_MIGRATED_REVID=111129433
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java53
1 files changed, 28 insertions, 25 deletions
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 11ec5e59a4..9e1d8e0bb5 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
@@ -27,6 +27,7 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.FilesToRunProvider;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
+import com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.CommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
@@ -98,7 +99,7 @@ final class BundleSupport {
this.bundling = bundling;
this.attributes = new Attributes(ruleContext);
}
-
+
/**
* Registers actions required for constructing this bundle, namely merging all involved {@code
* Info.plist} files and generating asset catalogues.
@@ -111,9 +112,14 @@ final class BundleSupport {
registerConvertXibsActions(objcProvider);
registerMomczipActions(objcProvider);
registerInterfaceBuilderActions(objcProvider);
- registerMergeInfoplistAction();
registerActoolActionIfNecessary(objcProvider);
+ if (bundling.needsToMergeInfoplist()) {
+ NestedSet<Artifact> mergingContentArtifacts = bundling.getMergingContentArtifacts();
+ Artifact mergedPlist = bundling.getBundleInfoplist().get();
+ PlMergeControlBytes plMergeControlBytes = new PlMergeControlBytes(bundling, mergedPlist);
+ registerMergeInfoplistAction(mergingContentArtifacts, plMergeControlBytes);
+ }
return this;
}
@@ -342,34 +348,31 @@ final class BundleSupport {
* merge action is necessary if there are more than one input plist files or we have a bundle ID
* to stamp on the merged plist.
*/
- private void registerMergeInfoplistAction() {
+ private void registerMergeInfoplistAction(
+ NestedSet<Artifact> mergingContentArtifacts, PlMergeControlBytes controlBytes) {
if (!bundling.needsToMergeInfoplist()) {
return; // Nothing to do here.
}
+
+ Artifact plMergeControlArtifact =
+ ObjcRuleClasses.artifactByAppendingToBaseName(ruleContext, ".plmerge-control");
- ruleContext.registerAction(new SpawnAction.Builder()
- .setMnemonic("MergeInfoPlistFiles")
- .setExecutable(attributes.plmerge())
- .setCommandLine(mergeCommandLine())
- .addInputs(bundling.getBundleInfoplistInputs())
- .addOutput(ObjcRuleClasses.intermediateArtifacts(ruleContext).mergedInfoplist())
- .build(ruleContext));
- }
-
- private CommandLine mergeCommandLine() {
- CustomCommandLine.Builder argBuilder = CustomCommandLine.builder()
- .addBeforeEachExecPath("--source_file", bundling.getBundleInfoplistInputs())
- .addExecPath(
- "--out_file", ObjcRuleClasses.intermediateArtifacts(ruleContext).mergedInfoplist());
-
- if (bundling.getPrimaryBundleId() != null) {
- argBuilder.add("--primary_bundle_id").add(bundling.getPrimaryBundleId());
- }
- if (bundling.getFallbackBundleId() != null) {
- argBuilder.add("--fallback_bundle_id").add(bundling.getFallbackBundleId());
- }
+ ruleContext.registerAction(
+ new BinaryFileWriteAction(
+ ruleContext.getActionOwner(),
+ plMergeControlArtifact,
+ controlBytes,
+ /*makeExecutable=*/ false));
- return argBuilder.build();
+ ruleContext.registerAction(
+ new SpawnAction.Builder()
+ .setMnemonic("MergeInfoPlistFiles")
+ .setExecutable(attributes.plmerge())
+ .addArgument("--control")
+ .addInputArgument(plMergeControlArtifact)
+ .addTransitiveInputs(mergingContentArtifacts)
+ .addOutput(ObjcRuleClasses.intermediateArtifacts(ruleContext).mergedInfoplist())
+ .build(ruleContext));
}
private void registerActoolActionIfNecessary(ObjcProvider objcProvider) {