Forward deps artifacts from FeatureFlagSetterRule.
This is helpful for testing the behavior of rules underneath the flag setter without going around Bazel internals.
RELNOTES: None.
package com.google.devtools.build.lib.rules.config;
-import static com.google.devtools.build.lib.collect.nestedset.Order.STABLE_ORDER;
import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
import static com.google.devtools.build.lib.packages.BuildType.LABEL_KEYED_STRING_DICT;
import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
import com.google.common.collect.ImmutableMap;
-import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException;
import com.google.devtools.build.lib.analysis.BaseRuleClasses;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.PrerequisiteArtifacts;
import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
import com.google.devtools.build.lib.analysis.RuleContext;
@@ -35,11 +34,10 @@ import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
-/** Rule introducing a transition to set feature flags for dependencies. */
+/** Rule introducing a transition to set feature flags for itself and dependencies. */
public final class FeatureFlagSetterRule implements RuleDefinition, RuleConfiguredTargetFactory {
@Override
@@ -48,10 +46,7 @@ public final class FeatureFlagSetterRule implements RuleDefinition, RuleConfigur
.requiresConfigurationFragments(ConfigFeatureFlagConfiguration.class)
.cfg(new ConfigFeatureFlagTransitionFactory("flag_values"))
.add(attr("deps", LABEL_LIST).allowedFileTypes())
- .add(
- attr("exports_setting", LABEL)
- .allowedRuleClasses("config_setting")
- .allowedFileTypes())
+ .add(attr("exports_setting", LABEL).allowedRuleClasses("config_setting").allowedFileTypes())
.add(
attr("exports_flag", LABEL)
.allowedRuleClasses("config_feature_flag")
@@ -89,7 +84,7 @@ public final class FeatureFlagSetterRule implements RuleDefinition, RuleConfigur
RuleConfiguredTargetBuilder builder =
new RuleConfiguredTargetBuilder(ruleContext)
- .setFilesToBuild(NestedSetBuilder.<Artifact>emptySet(STABLE_ORDER))
+ .setFilesToBuild(PrerequisiteArtifacts.nestedSet(ruleContext, "deps", Mode.TARGET))
.addProvider(RunfilesProvider.class, RunfilesProvider.EMPTY);
if (exportedFlagProvider != null) {
builder.addNativeDeclaredProvider(exportedFlagProvider);
