Skip to content

Commit

Permalink
Consolidate creation of the ConfiguredAttributeMap and clean up casts in
Browse files Browse the repository at this point in the history
DependencyResolver.

Work towards toolchain transition, #10523.

PiperOrigin-RevId: 293187791
  • Loading branch information
katre authored and Copybara-Service committed Feb 4, 2020
1 parent dd41ff0 commit b0f47b2
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ public final OrderedSetMultimap<DependencyKind, Dependency> dependentNodeMap(
BuildConfiguration config = node.getConfiguration();
OrderedSetMultimap<DependencyKind, Label> outgoingLabels = OrderedSetMultimap.create();

// TODO(bazel-team): Figure out a way to implement the below using LabelVisitationUtils.
// TODO(bazel-team): Figure out a way to implement the below (and partiallyResolveDependencies)
// using
// LabelVisitationUtils.
Rule fromRule = null;
ConfiguredAttributeMapper attributeMap = null;
if (target instanceof OutputFile) {
Preconditions.checkNotNull(config);
visitTargetVisibility(node, outgoingLabels);
Expand All @@ -273,17 +277,15 @@ public final OrderedSetMultimap<DependencyKind, Dependency> dependentNodeMap(
} else if (target instanceof EnvironmentGroup) {
visitTargetVisibility(node, outgoingLabels);
} else if (target instanceof Rule) {
visitRule(node, hostConfig, aspects, configConditions, toolchainContext, outgoingLabels);
fromRule = (Rule) target;
attributeMap = ConfiguredAttributeMapper.of(fromRule, configConditions);
visitRule(node, hostConfig, aspects, attributeMap, toolchainContext, outgoingLabels);
} else if (target instanceof PackageGroup) {
outgoingLabels.putAll(VISIBILITY_DEPENDENCY, ((PackageGroup) target).getIncludes());
} else {
throw new IllegalStateException(target.getLabel().toString());
}

Rule fromRule = target instanceof Rule ? (Rule) target : null;
ConfiguredAttributeMapper attributeMap =
fromRule == null ? null : ConfiguredAttributeMapper.of(fromRule, configConditions);

Map<Label, Target> targetMap = getTargets(outgoingLabels, target, rootCauses);
if (targetMap == null) {
// Dependencies could not be resolved. Try again when they are loaded by Skyframe.
Expand Down Expand Up @@ -312,7 +314,7 @@ public final OrderedSetMultimap<DependencyKind, Dependency> dependentNodeMap(
private OrderedSetMultimap<DependencyKind, PartiallyResolvedDependency>
partiallyResolveDependencies(
OrderedSetMultimap<DependencyKind, Label> outgoingLabels,
Rule fromRule,
@Nullable Rule fromRule,
ConfiguredAttributeMapper attributeMap,
@Nullable ToolchainContext toolchainContext,
Iterable<Aspect> aspects) {
Expand Down Expand Up @@ -423,15 +425,14 @@ private void visitRule(
TargetAndConfiguration node,
BuildConfiguration hostConfig,
Iterable<Aspect> aspects,
ImmutableMap<Label, ConfigMatchingProvider> configConditions,
ConfiguredAttributeMapper attributeMap,
@Nullable ToolchainContext toolchainContext,
OrderedSetMultimap<DependencyKind, Label> outgoingLabels)
throws EvalException {
Preconditions.checkArgument(node.getTarget() instanceof Rule, node);
BuildConfiguration ruleConfig = Preconditions.checkNotNull(node.getConfiguration(), node);
Rule rule = (Rule) node.getTarget();

ConfiguredAttributeMapper attributeMap = ConfiguredAttributeMapper.of(rule, configConditions);
attributeMap.validateAttributes();

visitTargetVisibility(node, outgoingLabels);
Expand Down

0 comments on commit b0f47b2

Please sign in to comment.