Toolchain providers are propagated in the ToolchainContext instance made
available from BuildViewTestCase#getRuleContext
PiperOrigin-RevId: 168231020
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index d8007c1..b797532 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -1056,9 +1056,12 @@
throws EvalException, InvalidConfigurationException,
InterruptedException, InconsistentAspectOrderException {
return skyframeExecutor.getConfiguredTargets(
- eventHandler, ct.getConfiguration(),
+ eventHandler,
+ ct.getConfiguration(),
ImmutableSet.copyOf(
- getDirectPrerequisiteDependenciesForTesting(eventHandler, ct, configurations).values()),
+ getDirectPrerequisiteDependenciesForTesting(
+ eventHandler, ct, configurations, /*toolchainContext=*/ null)
+ .values()),
false);
}
@@ -1066,9 +1069,10 @@
public OrderedSetMultimap<Attribute, Dependency> getDirectPrerequisiteDependenciesForTesting(
final ExtendedEventHandler eventHandler,
final ConfiguredTarget ct,
- BuildConfigurationCollection configurations)
+ BuildConfigurationCollection configurations,
+ ToolchainContext toolchainContext)
throws EvalException, InvalidConfigurationException, InterruptedException,
- InconsistentAspectOrderException {
+ InconsistentAspectOrderException {
if (!(ct.getTarget() instanceof Rule)) {
return OrderedSetMultimap.create();
}
@@ -1128,8 +1132,11 @@
TargetAndConfiguration ctgNode =
new TargetAndConfiguration(ct.getTarget(), ct.getConfiguration());
return dependencyResolver.dependentNodeMap(
- ctgNode, configurations.getHostConfiguration(), /*aspect=*/ null,
- getConfigurableAttributeKeysForTesting(eventHandler, ctgNode));
+ ctgNode,
+ configurations.getHostConfiguration(),
+ /*aspect=*/ null,
+ getConfigurableAttributeKeysForTesting(eventHandler, ctgNode),
+ toolchainContext);
}
/**
@@ -1160,11 +1167,13 @@
private OrderedSetMultimap<Attribute, ConfiguredTarget> getPrerequisiteMapForTesting(
final ExtendedEventHandler eventHandler,
ConfiguredTarget target,
- BuildConfigurationCollection configurations)
- throws EvalException, InvalidConfigurationException,
- InterruptedException, InconsistentAspectOrderException {
+ BuildConfigurationCollection configurations,
+ ToolchainContext toolchainContext)
+ throws EvalException, InvalidConfigurationException, InterruptedException,
+ InconsistentAspectOrderException {
OrderedSetMultimap<Attribute, Dependency> depNodeNames =
- getDirectPrerequisiteDependenciesForTesting(eventHandler, target, configurations);
+ getDirectPrerequisiteDependenciesForTesting(
+ eventHandler, target, configurations, toolchainContext);
ImmutableMultimap<Dependency, ConfiguredTarget> cts = skyframeExecutor.getConfiguredTargetMap(
eventHandler,
@@ -1258,6 +1267,9 @@
ToolchainContext toolchainContext =
skyframeExecutor.getToolchainContextForTesting(
requiredToolchains, targetConfig, eventHandler);
+ OrderedSetMultimap<Attribute, ConfiguredTarget> prerequisiteMap =
+ getPrerequisiteMapForTesting(eventHandler, target, configurations, toolchainContext);
+ toolchainContext.resolveToolchains(prerequisiteMap);
return new RuleContext.Builder(
env,
@@ -1270,7 +1282,8 @@
.setVisibility(
NestedSetBuilder.<PackageSpecification>create(
Order.STABLE_ORDER, PackageSpecification.everything()))
- .setPrerequisites(getPrerequisiteMapForTesting(eventHandler, target, configurations))
+ .setPrerequisites(
+ getPrerequisiteMapForTesting(eventHandler, target, configurations, toolchainContext))
.setConfigConditions(ImmutableMap.<Label, ConfigMatchingProvider>of())
.setUniversalFragment(ruleClassProvider.getUniversalFragment())
.setToolchainContext(toolchainContext)
@@ -1290,7 +1303,9 @@
throws EvalException, InvalidConfigurationException, InterruptedException,
InconsistentAspectOrderException {
Collection<ConfiguredTarget> configuredTargets =
- getPrerequisiteMapForTesting(eventHandler, dependentTarget, configurations).values();
+ getPrerequisiteMapForTesting(
+ eventHandler, dependentTarget, configurations, /*toolchainContext=*/ null)
+ .values();
for (ConfiguredTarget ct : configuredTargets) {
if (ct.getLabel().equals(desiredTarget)) {
return ct;