From 90a8d6c04f35a5f2ea1417bc9cf7517c400ecfc8 Mon Sep 17 00:00:00 2001 From: Cal Peyser Date: Fri, 8 Jan 2016 18:15:28 +0000 Subject: Enable objc targets that produce bundles to specify multiple plist files with the "infoplists" attribute. The plists are merged to produce the bundle's Info.plist. This attribute will live alongside the current "infoplist" attribute until the next Blaze release. -- MOS_MIGRATED_REVID=111705709 --- .../devtools/build/lib/rules/objc/Bundling.java | 13 +++- .../build/lib/rules/objc/ObjcRuleClasses.java | 90 ++++++++++++++-------- 2 files changed, 67 insertions(+), 36 deletions(-) (limited to 'src') 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 da4843444f..f7ea2729db 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 @@ -113,9 +113,9 @@ final class Bundling { } /** - * 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). + * Adds any info plists specified in the given rule's {@code infoplist} or {@code infoplists} + * 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", BuildType.LABEL)) { @@ -129,6 +129,13 @@ final class Bundling { if (infoplist != null) { infoplistInputs.add(infoplist); } + + Iterable infoplists = + ruleContext.getPrerequisiteArtifacts("infoplists", Mode.TARGET).list(); + if (infoplists != null) { + infoplistInputs.addAll(infoplists); + } + return this; } 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 2faaf1f2ac..66d4e76c24 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 @@ -811,40 +811,64 @@ public class ObjcRuleClasses { @Override public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { return builder - /* - The infoplist file. This corresponds to appname-Info.plist in Xcode projects. + /* + The infoplist file. This corresponds to appname-Info.plist in Xcode projects. + ${SYNOPSIS} + Blaze will perform variable substitution on the plist file for the following values: + + */ + .add(attr("infoplist", LABEL).allowedFileTypes(PLIST_TYPE)) + /* + Infoplist files to be merged. The merged output corresponds to appname-Info.plist + in Xcode projects. Duplicate keys between infoplist files will cause an error if + and only if the values conflict. If both infoplist and + infoplists are specified, the files defined in both attributes will be used. + ${SYNOPSIS} + Blaze will perform variable substitution on the plist files for the following values: + + */ + .add(attr("infoplists", BuildType.LABEL_LIST).allowedFileTypes(PLIST_TYPE)) + /* + The device families to which this bundle or binary is targeted. ${SYNOPSIS} - Blaze will perform variable substitution on the plist file for the following values: - - */ - .add(attr("infoplist", LABEL) - .allowedFileTypes(PLIST_TYPE)) - /* - The device families to which this bundle or binary is targeted. - ${SYNOPSIS} - - This is known as the TARGETED_DEVICE_FAMILY build setting - in Xcode project files. It is a list of one or more of the strings - "iphone" and "ipad". - -

By default this is set to "iphone", if explicitly specified may not be - empty.

- */ - .add(attr("families", STRING_LIST) - .value(ImmutableList.of(TargetDeviceFamily.IPHONE.getNameInRule()))) - .add(attr("$momcwrapper", LABEL).cfg(HOST).exec() - .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:momcwrapper"))) - .add(attr("$swiftstdlibtoolwrapper", LABEL).cfg(HOST).exec() - .value(env.getLabel( - Constants.TOOLS_REPOSITORY + "//tools/objc:swiftstdlibtoolwrapper"))) - .build(); + + This is known as the TARGETED_DEVICE_FAMILY build setting + in Xcode project files. It is a list of one or more of the strings + "iphone" and "ipad". + +

By default this is set to "iphone", if explicitly specified may not be + empty.

+ */ + .add( + attr("families", STRING_LIST) + .value(ImmutableList.of(TargetDeviceFamily.IPHONE.getNameInRule()))) + .add( + attr("$momcwrapper", LABEL) + .cfg(HOST) + .exec() + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:momcwrapper"))) + .add( + attr("$swiftstdlibtoolwrapper", LABEL) + .cfg(HOST) + .exec() + .value( + env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:swiftstdlibtoolwrapper"))) + .build(); } @Override public Metadata getMetadata() { -- cgit v1.2.3