aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar Peter Schmitt <schmitt@google.com>2015-05-18 21:39:57 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-05-19 09:31:57 +0000
commitdd51966ba6bcecb786cb86d3532ab6cf1775ec63 (patch)
tree1ea7165b0fce6b47ce77767e88c8adc3f1ef05ab /src/main/java/com/google/devtools/build/lib/rules
parent158bd1f681aa61153a9154f6ac65914dc89815e0 (diff)
Simplify bundle merging information.
Moves the bundle merging action logic into BundleSupport and eliminates the need for InfoplistMerging.java. -- MOS_MIGRATED_REVID=93926774
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java94
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/Bundling.java123
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/InfoplistMerging.java164
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibrary.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/XcodeProvider.java19
7 files changed, 153 insertions, 264 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java
index a90e23b8e6..b526c60499 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java
@@ -64,8 +64,11 @@ final class BundleMergeControlBytes extends ByteSource {
BundleMergeProtos.Control.Builder control = BundleMergeProtos.Control.newBuilder()
.addAllBundleFile(BundleableFile.toBundleFiles(bundling.getExtraBundleFiles()))
.addAllBundleFile(BundleableFile.toBundleFiles(objcProvider.get(BUNDLE_FILE)))
- .addAllSourcePlistFile(Artifact.toExecPaths(
- bundling.getInfoplistMerging().getPlistWithEverything().asSet()))
+ // TODO(bazel-team): This should really be bundling.getBundleInfoplistInputs since (most of)
+ // those are editable, whereas this is usually the programatically merged plist. If we pass
+ // the sources here though, any synthetic data (generated plists with blaze-derived values)
+ // should be passed as well.
+ .addAllSourcePlistFile(Artifact.toExecPaths(bundling.getBundleInfoplist().asSet()))
// TODO(bazel-team): Add rule attribute for specifying targeted device family
.setMinimumOsVersion(bundling.getMinimumOsVersion())
.setSdkVersion(objcConfiguration.getIosSdkVersion())
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 28962d8c51..fbd2092fb0 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
@@ -28,7 +28,6 @@ import com.google.devtools.build.lib.analysis.RuleContext;
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;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.rules.objc.TargetDeviceFamily.InvalidFamilyNameException;
import com.google.devtools.build.lib.rules.objc.TargetDeviceFamily.RepeatedFamilyNameException;
@@ -52,15 +51,6 @@ import java.util.Objects;
final class BundleSupport {
/**
- * Iterable wrapper used to strongly type plists for merging into a bundle's {@code Info.plist}.
- */
- static class ExtraMergePlists extends IterableWrapper<Artifact> {
- ExtraMergePlists(Artifact... inputs) {
- super(inputs);
- }
- }
-
- /**
* Iterable wrapper used to strongly type arguments eventually passed to {@code actool}.
*/
static final class ExtraActoolArgs extends IterableWrapper<String> {
@@ -79,52 +69,6 @@ final class BundleSupport {
private final Attributes attributes;
/**
- * Returns merging instructions for a bundle's {@code Info.plist}.
- *
- * @param ruleContext context this bundle is constructed in
- * @param objcProvider provider containing all dependencies' information as well as some of this
- * rule's
- * @param primaryBundleId used to set the bundle identifier or override the existing one from
- * plist file, can be null
- * @param fallbackBundleId used to set the bundle identifier if it is not set by plist file or
- * primary identifier, can be null
- * @param extraMergePlists additional plist files to merge
- */
- static InfoplistMerging infoPlistMerging(
- RuleContext ruleContext,
- ObjcProvider objcProvider,
- String primaryBundleId,
- String fallbackBundleId,
- ExtraMergePlists extraMergePlists) {
- IntermediateArtifacts intermediateArtifacts =
- ObjcRuleClasses.intermediateArtifacts(ruleContext);
-
- NestedSetBuilder<Artifact> infoPlists = NestedSetBuilder.stableOrder();
- if (ruleContext.attributes().has("options", Type.LABEL)) {
- OptionsProvider optionsProvider = ruleContext
- .getPrerequisite("options", Mode.TARGET, OptionsProvider.class);
- if (optionsProvider != null) {
- infoPlists.addAll(optionsProvider.getInfoplists());
- }
- }
- Artifact infoplist = ruleContext.getPrerequisiteArtifact("infoplist", Mode.TARGET);
- if (infoplist != null) {
- infoPlists.add(infoplist);
- }
-
- return new InfoplistMerging.Builder(ruleContext)
- .setIntermediateArtifacts(intermediateArtifacts)
- .setInputPlists(NestedSetBuilder.<Artifact>stableOrder()
- .addTransitive(infoPlists.build())
- .addAll(actoolPartialInfoplist(ruleContext, objcProvider).asSet())
- .addAll(extraMergePlists)
- .build())
- .setPlmerge(ruleContext.getExecutablePrerequisite("$plmerge", Mode.HOST))
- .setBundleIdentifiers(primaryBundleId, fallbackBundleId)
- .build();
- }
-
- /**
* Creates a new bundle support with no special {@code actool} arguments.
*
* @param ruleContext context this bundle is constructed in
@@ -173,7 +117,9 @@ final class BundleSupport {
* @return this bundle support
*/
BundleSupport addXcodeSettings(Builder xcodeProviderBuilder) {
- xcodeProviderBuilder.setInfoplistMerging(bundling.getInfoplistMerging());
+ if (bundling.getBundleInfoplist().isPresent()) {
+ xcodeProviderBuilder.setBundleInfoplist(bundling.getBundleInfoplist().get());
+ }
return this;
}
@@ -336,9 +282,39 @@ final class BundleSupport {
}
}
+ /**
+ * Creates action to merge multiple Info.plist files of a bundle into a single Info.plist. The
+ * 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() {
- // TODO(bazel-team): Move action implementation from InfoplistMerging to this class.
- ruleContext.registerAction(bundling.getInfoplistMerging().getMergeAction());
+ if (!bundling.needsToMergeInfoplist()) {
+ return; // Nothing to do here.
+ }
+
+ 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());
+ }
+
+ return argBuilder.build();
}
private void registerActoolActionIfNecessary(ObjcProvider objcProvider) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/Bundling.java b/src/main/java/com/google/devtools/build/lib/rules/objc/Bundling.java
index 1ddc16a749..6240990812 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/Bundling.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/Bundling.java
@@ -31,9 +31,12 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
+import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.HashSet;
@@ -48,10 +51,9 @@ final class Bundling {
static final class Builder {
private String name;
private String bundleDirFormat;
- private ImmutableList.Builder<BundleableFile> extraBundleFilesBuilder =
- new ImmutableList.Builder<>();
+ private ImmutableList.Builder<BundleableFile> extraBundleFilesBuilder = ImmutableList.builder();
private ObjcProvider objcProvider;
- private InfoplistMerging infoplistMerging;
+ private NestedSetBuilder<Artifact> infoplists = NestedSetBuilder.stableOrder();
private IntermediateArtifacts intermediateArtifacts;
private String primaryBundleId;
private String fallbackBundleId;
@@ -87,8 +89,33 @@ final class Bundling {
return this;
}
- public Builder setInfoplistMerging(InfoplistMerging infoplistMerging) {
- this.infoplistMerging = infoplistMerging;
+ /**
+ * Adds an artifact representing an {@code Info.plist} as an input to this bundle's
+ * {@code Info.plist} (which is merged from any such added plists plus some additional
+ * information).
+ */
+ public Builder addInfoplistInput(Artifact infoplist) {
+ this.infoplists.add(infoplist);
+ return this;
+ }
+
+ /**
+ * Adds any info plists specified in the given rule's {@code infoplist} attribute as well as
+ * from its {@code options} as inputs to this bundle's {@code Info.plist} (which is merged from
+ * any such added plists plus some additional information).
+ */
+ public Builder addInfoplistInputFromRule(RuleContext ruleContext) {
+ if (ruleContext.attributes().has("options", Type.LABEL)) {
+ OptionsProvider optionsProvider = ruleContext
+ .getPrerequisite("options", Mode.TARGET, OptionsProvider.class);
+ if (optionsProvider != null) {
+ infoplists.addAll(optionsProvider.getInfoplists());
+ }
+ }
+ Artifact infoplist = ruleContext.getPrerequisiteArtifact("infoplist", Mode.TARGET);
+ if (infoplist != null) {
+ infoplists.add(infoplist);
+ }
return this;
}
@@ -139,27 +166,55 @@ final class Bundling {
return mergeZipBuilder.build();
}
- public Bundling build() {
- Preconditions.checkNotNull(intermediateArtifacts, "intermediateArtifacts");
+ private NestedSet<Artifact> bundleInfoplistInputs() {
+ if (objcProvider.hasAssetCatalogs()) {
+ infoplists.add(intermediateArtifacts.actoolPartialInfoplist());
+ }
+ return infoplists.build();
+ }
- Optional<Artifact> actoolzipOutput = Optional.absent();
- if (!Iterables.isEmpty(objcProvider.get(ASSET_CATALOG))) {
- actoolzipOutput = Optional.of(intermediateArtifacts.actoolzipOutput());
+ private Optional<Artifact> bundleInfoplist(NestedSet<Artifact> bundleInfoplistInputs) {
+ if (bundleInfoplistInputs.isEmpty()) {
+ return Optional.absent();
+ }
+ if (needsToMerge(bundleInfoplistInputs, primaryBundleId, fallbackBundleId)) {
+ return Optional.of(intermediateArtifacts.mergedInfoplist());
}
+ return Optional.of(Iterables.getOnlyElement(bundleInfoplistInputs));
+ }
+ private Optional<Artifact> combinedArchitectureBinary() {
Optional<Artifact> combinedArchitectureBinary = Optional.absent();
if (!Iterables.isEmpty(objcProvider.get(LIBRARY))
|| !Iterables.isEmpty(objcProvider.get(IMPORTED_LIBRARY))) {
combinedArchitectureBinary =
Optional.of(intermediateArtifacts.combinedArchitectureBinary());
}
+ return combinedArchitectureBinary;
+ }
+
+ private Optional<Artifact> actoolzipOutput() {
+ Optional<Artifact> actoolzipOutput = Optional.absent();
+ if (!Iterables.isEmpty(objcProvider.get(ASSET_CATALOG))) {
+ actoolzipOutput = Optional.of(intermediateArtifacts.actoolzipOutput());
+ }
+ return actoolzipOutput;
+ }
+
+ public Bundling build() {
+ Preconditions.checkNotNull(intermediateArtifacts, "intermediateArtifacts");
+
+ NestedSet<Artifact> bundleInfoplistInputs = bundleInfoplistInputs();
+ Optional<Artifact> bundleInfoplist = bundleInfoplist(bundleInfoplistInputs);
+ Optional<Artifact> actoolzipOutput = actoolzipOutput();
+ Optional<Artifact> combinedArchitectureBinary = combinedArchitectureBinary();
NestedSet<Artifact> mergeZips = getMergeZips(actoolzipOutput);
NestedSetBuilder<Artifact> bundleContentArtifactsBuilder =
NestedSetBuilder.<Artifact>stableOrder()
.addTransitive(nestedBundleContentArtifacts(objcProvider.get(NESTED_BUNDLE)))
.addAll(combinedArchitectureBinary.asSet())
- .addAll(infoplistMerging.getPlistWithEverything().asSet())
+ .addAll(bundleInfoplist.asSet())
.addTransitive(mergeZips)
.addAll(BundleableFile.toArtifacts(objcProvider.get(BUNDLE_FILE)));
@@ -183,24 +238,32 @@ final class Bundling {
bundleContentArtifactsBuilder.addAll(BundleableFile.toArtifacts(extraBundleFiles));
return new Bundling(name, bundleDirFormat, combinedArchitectureBinary, extraBundleFiles,
- objcProvider, infoplistMerging, actoolzipOutput, bundleContentArtifactsBuilder.build(),
- mergeZips, primaryBundleId, fallbackBundleId, architecture, minimumOsVersion);
+ objcProvider, bundleInfoplist, actoolzipOutput, bundleContentArtifactsBuilder.build(),
+ mergeZips, primaryBundleId, fallbackBundleId, architecture, minimumOsVersion,
+ bundleInfoplistInputs);
}
}
+ private static boolean needsToMerge(
+ NestedSet<Artifact> bundleInfoplistInputs, String primaryBundleId, String fallbackBundleId) {
+ return primaryBundleId != null || fallbackBundleId != null
+ || Iterables.size(bundleInfoplistInputs) > 1;
+ }
+
private final String name;
private final String architecture;
private final String bundleDirFormat;
private final Optional<Artifact> combinedArchitectureBinary;
private final ImmutableList<BundleableFile> extraBundleFiles;
private final ObjcProvider objcProvider;
- private final InfoplistMerging infoplistMerging;
+ private final Optional<Artifact> bundleInfoplist;
private final Optional<Artifact> actoolzipOutput;
private final NestedSet<Artifact> bundleContentArtifacts;
private final NestedSet<Artifact> mergeZips;
private final String primaryBundleId;
private final String fallbackBundleId;
private final String minimumOsVersion;
+ private final NestedSet<Artifact> bundleInfoplistInputs;
private Bundling(
String name,
@@ -208,20 +271,21 @@ final class Bundling {
Optional<Artifact> combinedArchitectureBinary,
ImmutableList<BundleableFile> extraBundleFiles,
ObjcProvider objcProvider,
- InfoplistMerging infoplistMerging,
+ Optional<Artifact> bundleInfoplist,
Optional<Artifact> actoolzipOutput,
NestedSet<Artifact> bundleContentArtifacts,
NestedSet<Artifact> mergeZips,
String primaryBundleId,
String fallbackBundleId,
String architecture,
- String minimumOsVersion) {
+ String minimumOsVersion,
+ NestedSet<Artifact> bundleInfoplistInputs) {
this.name = Preconditions.checkNotNull(name);
this.bundleDirFormat = Preconditions.checkNotNull(bundleDirFormat);
this.combinedArchitectureBinary = Preconditions.checkNotNull(combinedArchitectureBinary);
this.extraBundleFiles = Preconditions.checkNotNull(extraBundleFiles);
this.objcProvider = Preconditions.checkNotNull(objcProvider);
- this.infoplistMerging = Preconditions.checkNotNull(infoplistMerging);
+ this.bundleInfoplist = Preconditions.checkNotNull(bundleInfoplist);
this.actoolzipOutput = Preconditions.checkNotNull(actoolzipOutput);
this.bundleContentArtifacts = Preconditions.checkNotNull(bundleContentArtifacts);
this.mergeZips = Preconditions.checkNotNull(mergeZips);
@@ -229,6 +293,7 @@ final class Bundling {
this.primaryBundleId = primaryBundleId;
this.architecture = Preconditions.checkNotNull(architecture);
this.minimumOsVersion = Preconditions.checkNotNull(minimumOsVersion);
+ this.bundleInfoplistInputs = Preconditions.checkNotNull(bundleInfoplistInputs);
}
/**
@@ -273,11 +338,27 @@ final class Bundling {
}
/**
- * Information on the Info.plist and its merge inputs for this bundle. Note that an infoplist is
- * only included in the bundle if it has one or more merge inputs.
+ * Returns an artifact representing this bundle's {@code Info.plist} or {@link Optional#absent()}
+ * if this bundle has no info plist inputs.
+ */
+ public Optional<Artifact> getBundleInfoplist() {
+ return bundleInfoplist;
+ }
+
+ /**
+ * Returns all info plists that need to be merged into this bundle's {@link #getBundleInfoplist()
+ * info plist}.
+ */
+ public NestedSet<Artifact> getBundleInfoplistInputs() {
+ return bundleInfoplistInputs;
+ }
+
+ /**
+ * Returns {@code true} if this bundle requires merging of its {@link #getBundleInfoplist() info
+ * plist}.
*/
- public InfoplistMerging getInfoplistMerging() {
- return infoplistMerging;
+ public boolean needsToMergeInfoplist() {
+ return needsToMerge(bundleInfoplistInputs, primaryBundleId, fallbackBundleId);
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/InfoplistMerging.java b/src/main/java/com/google/devtools/build/lib/rules/objc/InfoplistMerging.java
deleted file mode 100644
index 3caf1b266c..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/InfoplistMerging.java
+++ /dev/null
@@ -1,164 +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.lib.rules.objc;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
-import com.google.devtools.build.lib.actions.Action;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.FilesToRunProvider;
-import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext;
-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;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-
-/**
- * Supplies information regarding Infoplist merging for a particular binary. This includes:
- * <ul>
- * <li>the Info.plist which contains the fields from every source. If there is only one source
- * plist, this is that plist.
- * <li>the action to merge all the Infoplists into a single one and stamp the bundle ID on it.
- * This action is present if there is more than one plist file or there is a non-null bundle
- * ID to stamp on the merged plist file.
- * </ul>
- */
-class InfoplistMerging {
- static class Builder {
- private final ActionConstructionContext context;
- private NestedSet<Artifact> inputPlists;
- private FilesToRunProvider plmerge;
- private IntermediateArtifacts intermediateArtifacts;
- private String primaryBundleId;
- private String fallbackBundleId;
-
- public Builder(ActionConstructionContext context) {
- this.context = Preconditions.checkNotNull(context);
- }
-
- public Builder setInputPlists(NestedSet<Artifact> inputPlists) {
- Preconditions.checkState(this.inputPlists == null);
- this.inputPlists = inputPlists;
- return this;
- }
-
- public Builder setPlmerge(FilesToRunProvider plmerge) {
- Preconditions.checkState(this.plmerge == null);
- this.plmerge = plmerge;
- return this;
- }
-
- public Builder setIntermediateArtifacts(IntermediateArtifacts intermediateArtifacts) {
- this.intermediateArtifacts = intermediateArtifacts;
- return this;
- }
-
- /**
- * Sets the potential bundle identifiers to stamp on the merged plist file.
- *
- * @param primaryBundleId used to set the bundle identifier or override the existing one from
- * plist file, can be null
- * @param fallbackBundleId used to set the bundle identifier if it is not set by plist file or
- * primary identifier, can be null
- */
- public Builder setBundleIdentifiers(String primaryBundleId, String fallbackBundleId) {
- this.primaryBundleId = primaryBundleId;
- this.fallbackBundleId = fallbackBundleId;
- return this;
- }
-
- /**
- * This static factory method prevents retention of the outer {@link Builder} class reference by
- * the anonymous {@link CommandLine} instance.
- */
- private static CommandLine mergeCommandLine(NestedSet<Artifact> inputPlists,
- Artifact mergedInfoplist, String primaryBundleId, String fallbackBundleId) {
- CustomCommandLine.Builder argBuilder = CustomCommandLine.builder()
- .addBeforeEachExecPath("--source_file", inputPlists)
- .addExecPath("--out_file", mergedInfoplist);
-
- if (primaryBundleId != null) {
- argBuilder.add("--primary_bundle_id").add(primaryBundleId);
- }
-
- if (fallbackBundleId != null) {
- argBuilder.add("--fallback_bundle_id").add(fallbackBundleId);
- }
-
- return argBuilder.build();
- }
-
- public InfoplistMerging build() {
- Preconditions.checkNotNull(intermediateArtifacts, "intermediateArtifacts");
-
- Optional<Artifact> plistWithEverything = Optional.absent();
- Action[] mergeActions = new Action[0];
-
- if (!inputPlists.isEmpty()) {
- int inputs = Iterables.size(inputPlists);
- if (inputs == 1 && primaryBundleId == null && fallbackBundleId == null) {
- plistWithEverything = Optional.of(Iterables.getOnlyElement(inputPlists));
- } else {
- Artifact merged = intermediateArtifacts.mergedInfoplist();
-
- plistWithEverything = Optional.of(merged);
- mergeActions = new SpawnAction.Builder()
- .setMnemonic("MergeInfoPlistFiles")
- .setExecutable(plmerge)
- .setCommandLine(
- mergeCommandLine(inputPlists, merged, primaryBundleId, fallbackBundleId))
- .addTransitiveInputs(inputPlists)
- .addOutput(merged)
- .build(context);
- }
- }
-
- return new InfoplistMerging(plistWithEverything, mergeActions, inputPlists);
- }
- }
-
- private final Optional<Artifact> plistWithEverything;
- private final Action[] mergeActions;
- private final NestedSet<Artifact> inputPlists;
-
- private InfoplistMerging(Optional<Artifact> plistWithEverything, Action[] mergeActions,
- NestedSet<Artifact> inputPlists) {
- this.plistWithEverything = plistWithEverything;
- this.mergeActions = mergeActions;
- this.inputPlists = inputPlists;
- }
-
- /**
- * Creates action to merge multiple Info.plist files of a binary into a single Info.plist. The
- * 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.
- */
- public Action[] getMergeAction() {
- return mergeActions;
- }
-
- /**
- * An {@link Optional} with the merged infoplist, or {@link Optional#absent()} if there are no
- * merge inputs and it should not be included in the bundle.
- */
- public Optional<Artifact> getPlistWithEverything() {
- return plistWithEverything;
- }
-
- public NestedSet<Artifact> getInputPlists() {
- return inputPlists;
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibrary.java
index c13086401a..a6a28a85ce 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibrary.java
@@ -73,10 +73,7 @@ public class ObjcBundleLibrary implements RuleConfiguredTargetFactory {
.setArchitecture(objcConfiguration.getIosCpu())
.setBundleDirFormat("%s.bundle")
.setObjcProvider(common.getObjcProvider())
- .setInfoplistMerging(
- BundleSupport.infoPlistMerging(ruleContext, common.getObjcProvider(),
- /*primaryBundleId=*/null, /*fallbackBundleId=*/null,
- new BundleSupport.ExtraMergePlists()))
+ .addInfoplistInputFromRule(ruleContext)
.setIntermediateArtifacts(intermediateArtifacts)
.setMinimumOsVersion(objcConfiguration.getMinimumOs())
.build();
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 1b70682707..289b3b9379 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
@@ -415,9 +415,8 @@ public final class ReleaseBundlingSupport {
.setBundleDirFormat(bundleDirFormat)
.addExtraBundleFiles(extraBundleFiles)
.setObjcProvider(objcProvider)
- .setInfoplistMerging(
- BundleSupport.infoPlistMerging(ruleContext, objcProvider, primaryBundleId,
- fallbackBundleId, new BundleSupport.ExtraMergePlists(getGeneratedVersionPlist())))
+ .addInfoplistInputFromRule(ruleContext)
+ .addInfoplistInput(getGeneratedVersionPlist())
.setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext))
.setPrimaryBundleId(primaryBundleId)
.setFallbackBundleId(fallbackBundleId)
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeProvider.java
index 696e1f42f8..30176c75d4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeProvider.java
@@ -78,7 +78,7 @@ public final class XcodeProvider implements TransitiveInfoProvider {
NestedSetBuilder.stableOrder();
private final NestedSetBuilder<String> nonPropagatedHeaderSearchPaths =
NestedSetBuilder.stableOrder();
- private Optional<InfoplistMerging> infoplistMerging = Optional.absent();
+ private Optional<Artifact> bundleInfoplist = Optional.absent();
// Dependencies must be in link order because XCode observes the dependency ordering for
// binary linking.
private final NestedSetBuilder<XcodeProvider> propagatedDependencies =
@@ -132,11 +132,10 @@ public final class XcodeProvider implements TransitiveInfoProvider {
}
/**
- * Sets the Info.plist merging information. Used for applications. May be
- * absent for other bundles.
+ * Sets the Info.plist for the bundle represented by this provider.
*/
- public Builder setInfoplistMerging(InfoplistMerging infoplistMerging) {
- this.infoplistMerging = Optional.of(infoplistMerging);
+ public Builder setBundleInfoplist(Artifact bundleInfoplist) {
+ this.bundleInfoplist = Optional.of(bundleInfoplist);
return this;
}
@@ -404,7 +403,7 @@ public final class XcodeProvider implements TransitiveInfoProvider {
private final NestedSet<String> nonPropagatedUserHeaderSearchPaths;
private final NestedSet<String> propagatedHeaderSearchPaths;
private final NestedSet<String> nonPropagatedHeaderSearchPaths;
- private final Optional<InfoplistMerging> infoplistMerging;
+ private final Optional<Artifact> bundleInfoplist;
private final NestedSet<XcodeProvider> propagatedDependencies;
private final NestedSet<XcodeProvider> nonPropagatedDependencies;
private final ImmutableList<XcodeprojBuildSetting> xcodeprojBuildSettings;
@@ -430,7 +429,7 @@ public final class XcodeProvider implements TransitiveInfoProvider {
this.nonPropagatedUserHeaderSearchPaths = builder.nonPropagatedUserHeaderSearchPaths.build();
this.propagatedHeaderSearchPaths = builder.propagatedHeaderSearchPaths.build();
this.nonPropagatedHeaderSearchPaths = builder.nonPropagatedHeaderSearchPaths.build();
- this.infoplistMerging = builder.infoplistMerging;
+ this.bundleInfoplist = builder.bundleInfoplist;
this.propagatedDependencies = builder.propagatedDependencies.build();
this.nonPropagatedDependencies = builder.nonPropagatedDependencies.build();
this.xcodeprojBuildSettings = builder.xcodeprojBuildSettings.build();
@@ -591,10 +590,8 @@ public final class XcodeProvider implements TransitiveInfoProvider {
.build());
}
- for (InfoplistMerging merging : infoplistMerging.asSet()) {
- for (Artifact infoplist : merging.getPlistWithEverything().asSet()) {
- targetControl.setInfoplist(infoplist.getExecPathString());
- }
+ if (bundleInfoplist.isPresent()) {
+ targetControl.setInfoplist(bundleInfoplist.get().getExecPathString());
}
for (CompilationArtifacts artifacts : compilationArtifacts.asSet()) {
targetControl