From 1575652972d80f224fb3f7398eef3439e4f5a5dd Mon Sep 17 00:00:00 2001 From: Dmitry Lomov Date: Fri, 16 Dec 2016 16:52:37 +0000 Subject: Names of extra-action protos now take into account all aspect names. If an Aspect registered an action that an extra-action is shadowing, its name is used when creating the extra-action's ID and name. Since recently, an aspect can see other aspects applied to the same target. This CL record the names of other aspects applied to the target as well, disambiguating the action owners. -- PiperOrigin-RevId: 142264153 MOS_MIGRATED_REVID=142264153 --- .../devtools/build/lib/analysis/RuleContext.java | 45 ++++++++-------------- 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java') 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 202be7b633..937cf74c45 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 @@ -53,7 +53,7 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.Location; -import com.google.devtools.build.lib.packages.AspectParameters; +import com.google.devtools.build.lib.packages.AspectDescriptor; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition; import com.google.devtools.build.lib.packages.Attribute.SplitTransition; @@ -151,8 +151,7 @@ public final class RuleContext extends TargetContext private static final String HOST_CONFIGURATION_PROGRESS_TAG = "for host"; private final Rule rule; - @Nullable private final String aspectName; - @Nullable private final AspectParameters aspectParameters; + private final ImmutableList aspectDescriptors; private final ListMultimap targetMap; private final ListMultimap filesetEntryMap; private final ImmutableMap configConditions; @@ -183,8 +182,7 @@ public final class RuleContext extends TargetContext super(builder.env, builder.rule, builder.configuration, builder.prerequisiteMap.get(null), builder.visibility); this.rule = builder.rule; - this.aspectName = builder.getAspectName(); - this.aspectParameters = builder.getAspectParameters(); + this.aspectDescriptors = builder.aspectDescriptors; this.configurationFragmentPolicy = builder.configurationFragmentPolicy; this.universalFragment = universalFragment; this.targetMap = targetMap; @@ -334,7 +332,7 @@ public final class RuleContext extends TargetContext @Override public ActionOwner getActionOwner() { if (actionOwner == null) { - actionOwner = createActionOwner(rule, aspectName, aspectParameters, getConfiguration()); + actionOwner = createActionOwner(rule, aspectDescriptors, getConfiguration()); } return actionOwner; } @@ -412,13 +410,11 @@ public final class RuleContext extends TargetContext @VisibleForTesting public static ActionOwner createActionOwner( Rule rule, - @Nullable String aspectName, - @Nullable AspectParameters aspectParameters, + ImmutableList aspectDescriptors, BuildConfiguration configuration) { return ActionOwner.create( rule.getLabel(), - aspectName, - aspectParameters, + aspectDescriptors, rule.getLocation(), configuration.getMnemonic(), rule.getTargetKind(), @@ -1434,28 +1430,25 @@ public final class RuleContext extends TargetContext private final BuildConfiguration configuration; private final BuildConfiguration hostConfiguration; private final PrerequisiteValidator prerequisiteValidator; - @Nullable private final String aspectName; - @Nullable private final AspectParameters aspectParameters; private final ErrorReporter reporter; private OrderedSetMultimap prerequisiteMap; private ImmutableMap configConditions; private NestedSet visibility; private ImmutableMap aspectAttributes; private ImmutableBiMap> skylarkProviderRegistry; + private ImmutableList aspectDescriptors; Builder( AnalysisEnvironment env, Rule rule, - @Nullable String aspectName, - @Nullable AspectParameters aspectParameters, + ImmutableList aspectDescriptors, BuildConfiguration configuration, BuildConfiguration hostConfiguration, PrerequisiteValidator prerequisiteValidator, ConfigurationFragmentPolicy configurationFragmentPolicy) { this.env = Preconditions.checkNotNull(env); this.rule = Preconditions.checkNotNull(rule); - this.aspectName = aspectName; - this.aspectParameters = aspectParameters; + this.aspectDescriptors = aspectDescriptors; this.configurationFragmentPolicy = Preconditions.checkNotNull(configurationFragmentPolicy); this.configuration = Preconditions.checkNotNull(configuration); this.hostConfiguration = Preconditions.checkNotNull(hostConfiguration); @@ -1736,7 +1729,7 @@ public final class RuleContext extends TargetContext /** Returns whether the context being constructed is for the evaluation of an aspect. */ public boolean forAspect() { - return aspectName != null; + return !aspectDescriptors.isEmpty(); } public Rule getRule() { @@ -1747,9 +1740,11 @@ public final class RuleContext extends TargetContext * Returns a rule class name suitable for log messages, including an aspect name if applicable. */ public String getRuleClassNameForLogging() { - return aspectName != null - ? aspectName + " aspect on " + rule.getRuleClass() - : rule.getRuleClass(); + if (aspectDescriptors.isEmpty()) { + return rule.getRuleClass(); + } + + return Joiner.on(",").join(aspectDescriptors) + " aspect on " + rule.getRuleClass(); } public BuildConfiguration getConfiguration() { @@ -1959,16 +1954,6 @@ public final class RuleContext extends TargetContext prerequisiteValidator.validate(this, prerequisite, attribute); } } - - @Nullable - public AspectParameters getAspectParameters() { - return aspectParameters; - } - - @Nullable - public String getAspectName() { - return aspectName; - } } /** -- cgit v1.2.3