From 73f2a45d3a601b43e72c866e44f4ba3eaa782aeb Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 22 Mar 2016 18:23:03 +0000 Subject: Introduce ReleaseBundling class to contain all application specific information required for creating a release bundle. -- MOS_MIGRATED_REVID=117843546 --- .../devtools/build/lib/rules/objc/Bundling.java | 71 +++++++++++++++++++--- 1 file changed, 64 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/Bundling.java') 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 ec9da712c7..c9b83efdae 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 @@ -30,6 +30,7 @@ import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.BundlingR import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode; @@ -63,6 +64,8 @@ final class Bundling { private String fallbackBundleId; private String architecture; private DottedVersion minimumOsVersion; + private ImmutableSet families; + private String artifactPrefix; public Builder setName(String name) { this.name = name; @@ -103,6 +106,15 @@ final class Bundling { return this; } + /** + * Adds the given list of artifacts representing {@code Info.plist}s that are to be merged into + * this bundle's {@code Info.plist}. + */ + public Builder addInfoplistInputs(Iterable infoplists) { + this.infoplistInputs.addAll(infoplists); + return this; + } + /** * Adds an artifact representing an {@code Info.plist} that contains automatic entries * generated by xcode. @@ -137,12 +149,12 @@ final class Bundling { this.intermediateArtifacts = intermediateArtifacts; return this; } - + public Builder setPrimaryBundleId(String primaryId) { this.primaryBundleId = primaryId; return this; } - + public Builder setFallbackBundleId(String fallbackId) { this.fallbackBundleId = fallbackId; return this; @@ -157,6 +169,16 @@ final class Bundling { return this; } + public Builder setTargetDeviceFamilies(ImmutableSet families) { + this.families = families; + return this; + } + + public Builder setArtifactPrefix(String artifactPrefix) { + this.artifactPrefix = artifactPrefix; + return this; + } + private static NestedSet nestedBundleContentArtifacts(Iterable bundles) { NestedSetBuilder artifacts = NestedSetBuilder.stableOrder(); for (Bundling bundle : bundles) { @@ -259,7 +281,7 @@ final class Bundling { public Bundling build() { Preconditions.checkNotNull(intermediateArtifacts, "intermediateArtifacts"); - + Preconditions.checkNotNull(families, "families"); NestedSet bundleInfoplistInputs = bundleInfoplistInputs(); Optional bundleInfoplist = bundleInfoplist(bundleInfoplistInputs); Optional actoolzipOutput = actoolzipOutput(); @@ -295,7 +317,10 @@ final class Bundling { minimumOsVersion, bundleInfoplistInputs, automaticEntriesInfoplistInput, - objcProvider.get(NESTED_BUNDLE)); + objcProvider.get(NESTED_BUNDLE), + families, + intermediateArtifacts, + artifactPrefix); } } @@ -320,6 +345,9 @@ final class Bundling { private final NestedSet infoplistInputs; private final NestedSet nestedBundlings; private Artifact automaticEntriesInfoplistInput; + private final ImmutableSet families; + private final IntermediateArtifacts intermediateArtifacts; + private final String artifactPrefix; private Bundling( String name, @@ -336,7 +364,10 @@ final class Bundling { DottedVersion minimumOsVersion, NestedSet infoplistInputs, Artifact automaticEntriesInfoplistInput, - NestedSet nestedBundlings) { + NestedSet nestedBundlings, + ImmutableSet families, + IntermediateArtifacts intermediateArtifacts, + String artifactPrefix) { this.nestedBundlings = Preconditions.checkNotNull(nestedBundlings); this.name = Preconditions.checkNotNull(name); this.bundleDirFormat = Preconditions.checkNotNull(bundleDirFormat); @@ -352,6 +383,9 @@ final class Bundling { this.minimumOsVersion = Preconditions.checkNotNull(minimumOsVersion); this.infoplistInputs = Preconditions.checkNotNull(infoplistInputs); this.automaticEntriesInfoplistInput = automaticEntriesInfoplistInput; + this.families = Preconditions.checkNotNull(families); + this.intermediateArtifacts = intermediateArtifacts; + this.artifactPrefix = artifactPrefix; } /** @@ -401,7 +435,7 @@ final class Bundling { public Optional getBundleInfoplist() { return bundleInfoplist; } - + /** * Returns all info plists that need to be merged into this bundle's {@link #getBundleInfoplist() * info plist}, other than that plist that contains blaze-generated automatic entires. @@ -428,7 +462,7 @@ final class Bundling { } return result.build(); } - + /** * Returns {@code true} if this bundle requires merging of its {@link #getBundleInfoplist() info * plist}. @@ -505,4 +539,27 @@ final class Bundling { public DottedVersion getMinimumOsVersion() { return minimumOsVersion; } + + /** + * Returns the list of {@link TargetDeviceFamily} values this bundle is targeting. + * If empty, the default values specified by "families" attribute will be used. + */ + public ImmutableSet getTargetDeviceFamilies() { + return families; + } + + /** + * Returns {@link IntermediateArtifacts} required to create this bundle. + */ + public IntermediateArtifacts getIntermediateArtifacts() { + return intermediateArtifacts; + } + + /** + * Returns the prefix to be added to all generated artifact names, can be null. This is useful + * to disambiguate artifacts for multiple bundles created with different names withing same rule. + */ + public String getArtifactPrefix() { + return artifactPrefix; + } } -- cgit v1.2.3