diff options
author | 2017-05-02 16:26:39 +0200 | |
---|---|---|
committer | 2017-05-03 10:44:40 +0200 | |
commit | f969734be768e7e941bbc3a7ed98c30908e2b261 (patch) | |
tree | 016fa1af773e260ca63a2f28f5b696e1116d8959 /src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java | |
parent | 430aca72c4e52f51d530df027ee2a4c0cfb6da40 (diff) |
Implement OutputGroupInfo provider.
Work towards #2894.
RELNOTES: None.
PiperOrigin-RevId: 154829065
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java index 7657427885..922d87e7dc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java @@ -39,6 +39,8 @@ import com.google.devtools.build.lib.packages.AggregatingAttributeMapper; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.Rule; +import com.google.devtools.build.lib.packages.SkylarkClassObject; +import com.google.devtools.build.lib.packages.SkylarkClassObjectConstructor; import com.google.devtools.build.lib.rules.android.ResourceContainer.ResourceType; import com.google.devtools.build.lib.rules.cpp.CcLinkParams; import com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider; @@ -95,6 +97,20 @@ public class AndroidCommon { return builder.build(); } + public static final <T extends SkylarkClassObject> Iterable<T> getTransitivePrerequisites( + RuleContext ruleContext, Mode mode, SkylarkClassObjectConstructor.Key key, + final Class<T> classType) { + IterablesChain.Builder<T> builder = IterablesChain.builder(); + AttributeMap attributes = ruleContext.attributes(); + for (String attr : TRANSITIVE_ATTRIBUTES) { + if (attributes.has(attr, BuildType.LABEL_LIST)) { + builder.add(ruleContext.getPrerequisites(attr, mode, key, classType)); + } + } + return builder.build(); + } + + public static final Iterable<TransitiveInfoCollection> collectTransitiveInfo( RuleContext ruleContext, Mode mode) { ImmutableList.Builder<TransitiveInfoCollection> builder = ImmutableList.builder(); @@ -894,7 +910,9 @@ public class AndroidCommon { private NestedSet<Artifact> collectHiddenTopLevelArtifacts(RuleContext ruleContext) { NestedSetBuilder<Artifact> builder = NestedSetBuilder.stableOrder(); for (OutputGroupProvider provider : - getTransitivePrerequisites(ruleContext, Mode.TARGET, OutputGroupProvider.class)) { + getTransitivePrerequisites(ruleContext, Mode.TARGET, + OutputGroupProvider.SKYLARK_CONSTRUCTOR.getKey(), + OutputGroupProvider.class)) { builder.addTransitive(provider.getOutputGroup(OutputGroupProvider.HIDDEN_TOP_LEVEL)); } return builder.build(); |