Skip to content

Commit

Permalink
Create builders initialized from the prior stage in dependency analysis.
Browse files Browse the repository at this point in the history
Part of work on toolchain transitions, bazelbuild#10523.
  • Loading branch information
katre committed Jun 10, 2020
1 parent 04028ef commit e2ecef0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ java_library(
deps = [
":aspect_collection",
":config/transitions/configuration_transition",
":dependency",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//third_party:auto_value",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ public static Builder builder() {

/** Returns the aspects that are propagating to the target this dependency points to. */
public abstract AspectCollection getAspects();

public Dependency.Builder getDependencyBuilder() {
return Dependency.builder().setLabel(getLabel());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ static Builder builder() {
return new AutoValue_DependencyResolver_PartiallyResolvedDependency.Builder()
.setPropagatingAspects(ImmutableList.of());
}

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

/**
Expand Down Expand Up @@ -198,8 +203,7 @@ public final OrderedSetMultimap<DependencyKind, DependencyKey> dependentNodeMap(
OrderedSetMultimap<DependencyKind, Label> outgoingLabels = OrderedSetMultimap.create();

// TODO(bazel-team): Figure out a way to implement the below (and partiallyResolveDependencies)
// using
// LabelVisitationUtils.
// using LabelVisitationUtils.
Rule fromRule = null;
ConfiguredAttributeMapper attributeMap = null;
if (target instanceof OutputFile) {
Expand Down Expand Up @@ -366,9 +370,9 @@ private OrderedSetMultimap<DependencyKind, DependencyKey> fullyResolveDependenci

for (Map.Entry<DependencyKind, PartiallyResolvedDependency> entry :
partiallyResolvedDeps.entries()) {
PartiallyResolvedDependency dep = entry.getValue();
PartiallyResolvedDependency partiallyResolvedDependency = entry.getValue();

Target toTarget = targetMap.get(dep.getLabel());
Target toTarget = targetMap.get(partiallyResolvedDependency.getLabel());
if (toTarget == null) {
// Dependency pointing to non-existent target. This error was reported in getTargets(), so
// we can just ignore this dependency.
Expand All @@ -377,15 +381,15 @@ private OrderedSetMultimap<DependencyKind, DependencyKey> fullyResolveDependenci

ConfigurationTransition transition =
TransitionResolver.evaluateTransition(
originalConfiguration, dep.getTransition(), toTarget, trimmingTransitionFactory);
originalConfiguration, partiallyResolvedDependency.getTransition(), toTarget, trimmingTransitionFactory);

AspectCollection requiredAspects =
filterPropagatingAspects(dep.getPropagatingAspects(), toTarget);
filterPropagatingAspects(partiallyResolvedDependency.getPropagatingAspects(), toTarget);

DependencyKey.Builder dependencyKeyBuilder = partiallyResolvedDependency.getDependencyKeyBuilder();
outgoingEdges.put(
entry.getKey(),
DependencyKey.builder()
.setLabel(dep.getLabel())
dependencyKeyBuilder
.setTransition(transition)
.setAspects(requiredAspects)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private ImmutableList<Dependency> resolveConfiguration(
DependencyKind dependencyKind, DependencyKey dependencyKey)
throws DependencyEvaluationException, ValueMissingException, InterruptedException {

Dependency.Builder dependencyBuilder = Dependency.builder().setLabel(dependencyKey.getLabel());
Dependency.Builder dependencyBuilder = dependencyKey.getDependencyBuilder();

ConfigurationTransition transition = dependencyKey.getTransition();
if (transition == NullTransition.INSTANCE) {
Expand Down

0 comments on commit e2ecef0

Please sign in to comment.