Save information about transitive packages in ConfiguredTargetValue and AspectValue.
--
MOS_MIGRATED_REVID=102643564
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
index 77153f8..8067e60 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
@@ -42,6 +42,7 @@
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.analysis.config.PatchTransition;
+import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.StoredEventHandler;
import com.google.devtools.build.lib.packages.AspectDefinition;
@@ -52,6 +53,7 @@
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.NoSuchThingException;
+import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.packages.PackageGroup;
import com.google.devtools.build.lib.packages.RawAttributeMapper;
import com.google.devtools.build.lib.packages.Rule;
@@ -135,7 +137,7 @@
public SkyValue compute(SkyKey key, Environment env) throws ConfiguredTargetFunctionException,
InterruptedException {
SkyframeBuildView view = buildViewProvider.getSkyframeBuildView();
-
+ NestedSetBuilder<Package> transitivePackages = NestedSetBuilder.stableOrder();
ConfiguredTargetKey configuredTargetKey = (ConfiguredTargetKey) key.argument();
LabelAndConfiguration lc = LabelAndConfiguration.of(
configuredTargetKey.getLabel(), configuredTargetKey.getConfiguration());
@@ -155,6 +157,7 @@
throw new ConfiguredTargetFunctionException(new NoSuchTargetException(lc.getLabel(),
"No such target"));
}
+ transitivePackages.add(packageValue.getPackage());
// TODO(bazel-team): This is problematic - we create the right key, but then end up with a value
// that doesn't match; we can even have the same value multiple times. However, I think it's
// only triggered in tests (i.e., in normal operation, the configuration passed in is already
@@ -177,16 +180,16 @@
try {
// Get the configuration targets that trigger this rule's configurable attributes.
Set<ConfigMatchingProvider> configConditions =
- getConfigConditions(ctgValue.getTarget(), env, resolver, ctgValue);
+ getConfigConditions(ctgValue.getTarget(), env, resolver, ctgValue, transitivePackages);
if (env.valuesMissing()) {
return null;
}
ListMultimap<Attribute, ConfiguredTarget> depValueMap = computeDependencies(env, resolver,
ctgValue, null, AspectParameters.EMPTY, configConditions, ruleClassProvider,
- view.getHostConfiguration(configuration));
+ view.getHostConfiguration(configuration), transitivePackages);
ConfiguredTargetValue ans = createConfiguredTarget(
- view, env, target, configuration, depValueMap, configConditions);
+ view, env, target, configuration, depValueMap, configConditions, transitivePackages);
return ans;
} catch (DependencyEvaluationException e) {
throw new ConfiguredTargetFunctionException(e.getRootCauseSkyKey(), e.getCause());
@@ -220,7 +223,7 @@
Environment env, SkyframeDependencyResolver resolver, TargetAndConfiguration ctgValue,
AspectDefinition aspectDefinition, AspectParameters aspectParameters,
Set<ConfigMatchingProvider> configConditions, RuleClassProvider ruleClassProvider,
- BuildConfiguration hostConfiguration)
+ BuildConfiguration hostConfiguration, NestedSetBuilder<Package> transitivePackages)
throws DependencyEvaluationException {
// Create the map from attributes to list of (target, configuration) pairs.
@@ -245,15 +248,15 @@
}
// Resolve configured target dependencies and handle errors.
- Map<SkyKey, ConfiguredTarget> depValues =
- resolveConfiguredTargetDependencies(env, depValueNames.values(), ctgValue.getTarget());
+ Map<SkyKey, ConfiguredTarget> depValues = resolveConfiguredTargetDependencies(env,
+ depValueNames.values(), ctgValue.getTarget(), transitivePackages);
if (depValues == null) {
return null;
}
// Resolve required aspects.
ListMultimap<SkyKey, Aspect> depAspects = resolveAspectDependencies(
- env, depValues, depValueNames.values());
+ env, depValues, depValueNames.values(), transitivePackages);
if (depAspects == null) {
return null;
}
@@ -478,7 +481,8 @@
*/
@Nullable
private static ListMultimap<SkyKey, Aspect> resolveAspectDependencies(Environment env,
- Map<SkyKey, ConfiguredTarget> configuredTargetMap, Iterable<Dependency> deps)
+ Map<SkyKey, ConfiguredTarget> configuredTargetMap, Iterable<Dependency> deps,
+ NestedSetBuilder<Package> transitivePackages)
throws DependencyEvaluationException {
ListMultimap<SkyKey, Aspect> result = ArrayListMultimap.create();
Set<SkyKey> aspectKeys = new HashSet<>();
@@ -526,6 +530,7 @@
return null;
}
result.put(depKey, aspectValue.getAspect());
+ transitivePackages.addTransitive(aspectValue.getTransitivePackages());
}
}
return result;
@@ -547,7 +552,6 @@
return false;
}
}
-
return true;
}
@@ -560,7 +564,8 @@
*/
@Nullable
static Set<ConfigMatchingProvider> getConfigConditions(Target target, Environment env,
- SkyframeDependencyResolver resolver, TargetAndConfiguration ctgValue)
+ SkyframeDependencyResolver resolver, TargetAndConfiguration ctgValue,
+ NestedSetBuilder<Package> transitivePackages)
throws DependencyEvaluationException {
if (!(target instanceof Rule)) {
return ImmutableSet.of();
@@ -601,7 +606,7 @@
}
Map<SkyKey, ConfiguredTarget> configValues =
- resolveConfiguredTargetDependencies(env, configValueNames, target);
+ resolveConfiguredTargetDependencies(env, configValueNames, target, transitivePackages);
if (configValues == null) {
return null;
}
@@ -634,7 +639,8 @@
*/
@Nullable
private static Map<SkyKey, ConfiguredTarget> resolveConfiguredTargetDependencies(
- Environment env, Collection<Dependency> deps, Target target)
+ Environment env, Collection<Dependency> deps, Target target,
+ NestedSetBuilder<Package> transitivePackages)
throws DependencyEvaluationException {
boolean ok = !env.valuesMissing();
String message = null;
@@ -682,6 +688,7 @@
ok = false;
} else {
depValues.put(entry.getKey(), depValue.getConfiguredTarget());
+ transitivePackages.addTransitive(depValue.getTransitivePackages());
}
}
if (message != null) {
@@ -707,7 +714,8 @@
private ConfiguredTargetValue createConfiguredTarget(SkyframeBuildView view,
Environment env, Target target, BuildConfiguration configuration,
ListMultimap<Attribute, ConfiguredTarget> depValueMap,
- Set<ConfigMatchingProvider> configConditions)
+ Set<ConfigMatchingProvider> configConditions,
+ NestedSetBuilder<Package> transitivePackages)
throws ConfiguredTargetFunctionException, InterruptedException {
StoredEventHandler events = new StoredEventHandler();
BuildConfiguration ownerConfig = (configuration == null)
@@ -739,7 +747,8 @@
try {
return new ConfiguredTargetValue(configuredTarget,
- filterSharedActionsAndThrowIfConflict(analysisEnvironment.getRegisteredActions()));
+ filterSharedActionsAndThrowIfConflict(analysisEnvironment.getRegisteredActions()),
+ transitivePackages.build());
} catch (ActionConflictException e) {
throw new ConfiguredTargetFunctionException(e);
}