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, bazelbuild#10523.
GOOGLE:
RELNOTES: None.
  • Loading branch information
katre committed Feb 4, 2020
1 parent 1a5ec8b commit ba660ed
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ 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 +276,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 +313,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 +424,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 ba660ed

Please sign in to comment.