Use two configurations for AspectKeys.
In order for Aspects to support dynamic configuration, they need to have two
configurations: one to instantiate the Aspect with, containing all the fragment
dependencies of the Aspect itself, and one to create the ConfiguredTargetValue.key
with, containing only the dependencies of the Rule. This expands AspectKey to
have a second configuration, although it currently does not populate that key with
anything different.
--
MOS_MIGRATED_REVID=115997454
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
index 4917d28..400aba7 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
@@ -159,7 +159,7 @@
try {
configuredTargetValue =
(ConfiguredTargetValue) env.getValueOrThrow(
- ConfiguredTargetValue.key(key.getLabel(), key.getConfiguration()),
+ ConfiguredTargetValue.key(key.getLabel(), key.getBaseConfiguration()),
ConfiguredValueCreationException.class);
} catch (ConfiguredValueCreationException e) {
throw new AspectFunctionException(new AspectCreationException(e.getRootCauses()));
@@ -179,12 +179,19 @@
SkyframeDependencyResolver resolver = view.createDependencyResolver(env);
- TargetAndConfiguration ctgValue =
- new TargetAndConfiguration(target, key.getConfiguration());
+ // When getting the dependencies of this hybrid aspect+base target, use the aspect's
+ // configuration. The configuration of the aspect will always be a superset of the target's
+ // (dynamic configuration mode: target is part of the aspect's config fragment requirements;
+ // static configuration mode: target is the same configuration as the aspect), so the fragments
+ // required by all dependencies (both those of the aspect and those of the base target)
+ // will be present this way.
+ TargetAndConfiguration originalTargetAndAspectConfiguration =
+ new TargetAndConfiguration(target, key.getAspectConfiguration());
try {
// Get the configuration targets that trigger this rule's configurable attributes.
Set<ConfigMatchingProvider> configConditions = ConfiguredTargetFunction.getConfigConditions(
- target, env, resolver, ctgValue, transitivePackages, transitiveRootCauses);
+ target, env, resolver, originalTargetAndAspectConfiguration,
+ transitivePackages, transitiveRootCauses);
if (configConditions == null) {
// Those targets haven't yet been resolved.
return null;
@@ -194,11 +201,11 @@
ConfiguredTargetFunction.computeDependencies(
env,
resolver,
- ctgValue,
+ originalTargetAndAspectConfiguration,
key.getAspect(),
configConditions,
ruleClassProvider,
- view.getHostConfiguration(ctgValue.getConfiguration()),
+ view.getHostConfiguration(originalTargetAndAspectConfiguration.getConfiguration()),
transitivePackages,
transitiveRootCauses);
if (depValueMap == null) {
@@ -214,6 +221,7 @@
key,
aspectFactory,
associatedTarget,
+ key.getAspectConfiguration(),
configConditions,
depValueMap,
transitivePackages);
@@ -239,17 +247,17 @@
AspectKey key,
ConfiguredAspectFactory aspectFactory,
RuleConfiguredTarget associatedTarget,
+ BuildConfiguration aspectConfiguration,
Set<ConfigMatchingProvider> configConditions,
ListMultimap<Attribute, ConfiguredTarget> directDeps,
NestedSetBuilder<Package> transitivePackages)
throws AspectFunctionException, InterruptedException {
SkyframeBuildView view = buildViewProvider.getSkyframeBuildView();
- BuildConfiguration configuration = associatedTarget.getConfiguration();
StoredEventHandler events = new StoredEventHandler();
CachingAnalysisEnvironment analysisEnvironment = view.createAnalysisEnvironment(
- key, false, events, env, configuration);
+ key, false, events, env, aspectConfiguration);
if (env.valuesMissing()) {
return null;
}
@@ -262,7 +270,8 @@
key.getAspect(),
directDeps,
configConditions,
- view.getHostConfiguration(associatedTarget.getConfiguration()));
+ aspectConfiguration,
+ view.getHostConfiguration(aspectConfiguration));
events.replayOn(env.getListener());
if (events.hasErrors()) {