diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index 9c85ce9949..faa4f2c441 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; @@ -151,7 +152,9 @@ public final class RuleContext extends TargetContext private final ConfigurationFragmentPolicy configurationFragmentPolicy; private final Class<? extends BuildConfiguration.Fragment> universalFragment; private final ErrorReporter reporter; - + private final ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>> + skylarkProviderRegistry; + private ActionOwner actionOwner; /* lazily computed cache for Make variables, computed from the above. See get... method */ @@ -178,6 +181,7 @@ public final class RuleContext extends TargetContext this.features = getEnabledFeatures(); this.ruleClassNameForLogging = ruleClassNameForLogging; this.aspectAttributes = aspectAttributes; + this.skylarkProviderRegistry = builder.skylarkProviderRegistry; this.hostConfiguration = builder.hostConfiguration; reporter = builder.reporter; } @@ -269,6 +273,15 @@ public final class RuleContext extends TargetContext } /** + * Returns a map that indicates which providers should be exported to skylark under the key + * (map key). These provider types will also be exportable by skylark rules under (map key). + */ + public ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>> + getSkylarkProviderRegistry() { + return skylarkProviderRegistry; + } + + /** * Returns whether this instance is known to have errors at this point during analysis. Do not * call this method after the initializationHook has returned. */ @@ -1307,6 +1320,7 @@ public final class RuleContext extends TargetContext private Set<ConfigMatchingProvider> configConditions; private NestedSet<PackageSpecification> visibility; private ImmutableMap<String, Attribute> aspectAttributes; + private ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>> skylarkProviderRegistry; Builder( AnalysisEnvironment env, @@ -1393,6 +1407,16 @@ public final class RuleContext extends TargetContext return this; } + /** + * Sets a map that indicates which providers should be exported to skylark under the key + * (map key). These provider types will also be exportable by skylark rules under (map key). + */ + Builder setSkylarkProvidersRegistry( + ImmutableBiMap<String, Class<? extends TransitiveInfoProvider>> skylarkProviderRegistry) { + this.skylarkProviderRegistry = skylarkProviderRegistry; + return this; + } + private boolean validateFilesetEntry(FilesetEntry filesetEntry, ConfiguredTarget src) { if (src.getProvider(FilesetProvider.class) != null) { return true; |