Skip to content

Commit

Permalink
Add the ToolchainContextKey to dependency chain classes.
Browse files Browse the repository at this point in the history
TODOs mark where this will be set and used.

Part of work on toolchain transitions, bazelbuild#10523.
  • Loading branch information
katre committed Jun 10, 2020
1 parent e2ecef0 commit 65c208e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/skyframe:package_value",
"//src/main/java/com/google/devtools/build/lib/skyframe:precomputed_value",
"//src/main/java/com/google/devtools/build/lib/skyframe:sane_analysis_exception",
"//src/main/java/com/google/devtools/build/lib/skyframe:toolchain_context_key",
"//src/main/java/com/google/devtools/build/lib/skyframe:transitive_target_key",
"//src/main/java/com/google/devtools/build/lib/skyframe:transitive_target_value",
"//src/main/java/com/google/devtools/build/lib/skyframe:workspace_status_value",
Expand Down Expand Up @@ -701,6 +702,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_key",
"//src/main/java/com/google/devtools/build/lib/skyframe:toolchain_context_key",
"//third_party:auto_value",
"//third_party:guava",
"//third_party:jsr305",
Expand All @@ -715,7 +717,9 @@ java_library(
":config/transitions/configuration_transition",
":dependency",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/skyframe:toolchain_context_key",
"//third_party:auto_value",
"//third_party:jsr305",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -68,6 +69,10 @@ public Builder setTransitionKey(String key) {
/** 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();

Expand Down Expand Up @@ -141,11 +146,19 @@ public BuildConfiguration getAspectConfiguration(AspectDescriptor aspect) {
*/
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()
ConfiguredTargetKey.Builder configuredTargetKeyBuilder = ConfiguredTargetKey.builder()
.setLabel(getLabel())
.setConfiguration(getConfiguration())
.setConfiguration(getConfiguration());
if (getToolchainContextKey() != null) {
configuredTargetKeyBuilder.setToolchainContextKey(getToolchainContextKey());
}
return configuredTargetKeyBuilder
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.analysis.config.transitions.ConfigurationTransition;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.skyframe.ToolchainContextKey;
import javax.annotation.Nullable;

/**
* Information about a dependency, including the label and configuration transition. This will be
Expand All @@ -36,6 +38,10 @@ public interface Builder {
/** Sets the aspects that are propagating to the target this dependency points to. */
Builder setAspects(AspectCollection aspectCollection);

/** Sets the {@link ToolchainContextKey} that this dependency should use for toolchain resolution. */
@Nullable
Builder setToolchainContextKey(ToolchainContextKey toolchainContextKey);

/** Returns the new instance. */
DependencyKey build();
}
Expand All @@ -54,7 +60,13 @@ public static Builder builder() {
/** Returns the aspects that are propagating to the target this dependency points to. */
public abstract AspectCollection getAspects();

/** Returns the {@link ToolchainContextKey} that this dependency should use for toolchain resolution. */
@Nullable
public abstract ToolchainContextKey getToolchainContextKey();

public Dependency.Builder getDependencyBuilder() {
return Dependency.builder().setLabel(getLabel());
return Dependency.builder()
.setLabel(getLabel())
.setToolchainContextKey(getToolchainContextKey());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.skyframe.ToolchainContextKey;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.util.OrderedSetMultimap;
import java.util.ArrayList;
Expand Down Expand Up @@ -83,6 +84,9 @@ abstract static class PartiallyResolvedDependency {

abstract ImmutableList<Aspect> getPropagatingAspects();

@Nullable
abstract ToolchainContextKey getToolchainContextKey();

/** A Builder to create instances of PartiallyResolvedDependency. */
@AutoValue.Builder
abstract static class Builder {
Expand All @@ -92,6 +96,9 @@ abstract static class Builder {

abstract Builder setPropagatingAspects(List<Aspect> propagatingAspects);

@Nullable
abstract Builder setToolchainContextKey(ToolchainContextKey toolchainContextKey);

abstract PartiallyResolvedDependency build();
}

Expand All @@ -102,7 +109,8 @@ static Builder builder() {

public DependencyKey.Builder getDependencyKeyBuilder() {
return DependencyKey.builder()
.setLabel(getLabel());
.setLabel(getLabel())
.setToolchainContextKey(getToolchainContextKey());
}
}

Expand Down Expand Up @@ -274,8 +282,9 @@ public final OrderedSetMultimap<DependencyKind, DependencyKey> dependentNodeMap(
TOOLCHAIN_DEPENDENCY,
PartiallyResolvedDependency.builder()
.setLabel(toLabel)
// TODO(jcater): Replace this with a proper transition for the execution platform.
// TODO(#10523): Replace this with a proper transition for the execution platform.
.setTransition(HostTransition.INSTANCE)
// TODO(#10523): Set the toolchainContextKey from ToolchainCollection.
.setPropagatingAspects(ImmutableList.of())
.build());
continue;
Expand Down

0 comments on commit 65c208e

Please sign in to comment.