Add the ToolchainContextKey to dependency chain classes.
TODOs mark where this will be set and used.
Part of work on toolchain transitions, #10523.
Closes #11575.
PiperOrigin-RevId: 315766282
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Dependency.java b/src/main/java/com/google/devtools/build/lib/analysis/Dependency.java
index 449a425..0b07692 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/Dependency.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/Dependency.java
@@ -21,6 +21,7 @@
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.AspectDescriptor;
import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey;
+import com.google.devtools.build.lib.skyframe.ToolchainContextKey;
import javax.annotation.Nullable;
/**
@@ -68,6 +69,13 @@
/** Sets the keys of a configuration transition. */
public abstract Builder setTransitionKeys(ImmutableList<String> keys);
+ /**
+ * Sets the {@link ToolchainContextKey} that this dependency should use for toolchain
+ * resolution.
+ */
+ @Nullable
+ public abstract Builder setToolchainContextKey(ToolchainContextKey toolchainContextKey);
+
// Not public.
abstract Dependency autoBuild();
@@ -141,11 +149,20 @@
*/
public abstract ImmutableList<String> getTransitionKeys();
+ /**
+ * Returns the {@link ToolchainContextKey} that this dependency should use for toolchain
+ * resolution.
+ */
+ @Nullable
+ public abstract ToolchainContextKey getToolchainContextKey();
+
/** Returns the ConfiguredTargetKey needed to fetch this dependency. */
public ConfiguredTargetKey getConfiguredTargetKey() {
- return ConfiguredTargetKey.builder()
- .setLabel(getLabel())
- .setConfiguration(getConfiguration())
- .build();
+ ConfiguredTargetKey.Builder configuredTargetKeyBuilder =
+ ConfiguredTargetKey.builder().setLabel(getLabel()).setConfiguration(getConfiguration());
+ if (getToolchainContextKey() != null) {
+ configuredTargetKeyBuilder.setToolchainContextKey(getToolchainContextKey());
+ }
+ return configuredTargetKeyBuilder.build();
}
}