diff options
author | Dmitry Lomov <dslomov@google.com> | 2016-01-21 22:34:14 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-01-22 15:54:30 +0000 |
commit | 940ea0770483ac477fa2d0e36dc660acbd168d89 (patch) | |
tree | b60a4f5cf1103f7107dfd7945a89c011f8c33a9e /src/main/java/com/google/devtools/build/lib/query2/LabelVisitor.java | |
parent | cb14c5e7e0a0f623aaf0911295f19caf9dcd6a8e (diff) |
Properly filter out Aspect attributes when `blaze query` requests --noimplicit_deps and/or --nohost_deps.
RELNOTES: --noimplicit_deps and --nohost_deps work correctly for Aspect attributes.
--
MOS_MIGRATED_REVID=112724917
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2/LabelVisitor.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/query2/LabelVisitor.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/LabelVisitor.java b/src/main/java/com/google/devtools/build/lib/query2/LabelVisitor.java index d2015c988e..f0dd92fbf3 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/LabelVisitor.java +++ b/src/main/java/com/google/devtools/build/lib/query2/LabelVisitor.java @@ -326,10 +326,6 @@ final class LabelVisitor { // Don't perform the targetProvider lookup if at the maximum depth already. if (depth >= maxDepth) { return; - } else if (attr != null && from instanceof Rule) { - if (!edgeFilter.apply((Rule) from, attr)) { - return; - } } // Avoid thread-related overhead when not crossing packages. @@ -366,11 +362,15 @@ final class LabelVisitor { private void visitTargetVisibility(Target target, int depth, int count) { Attribute attribute = null; if (target instanceof Rule) { - RuleClass ruleClass = ((Rule) target).getRuleClassObject(); + Rule rule = (Rule) target; + RuleClass ruleClass = rule.getRuleClassObject(); if (!ruleClass.hasAttr("visibility", BuildType.NODEP_LABEL_LIST)) { return; } attribute = ruleClass.getAttributeByName("visibility"); + if (!edgeFilter.apply(rule, attribute)) { + return; + } } for (Label label : target.getVisibility().getDependencyLabels()) { @@ -391,6 +391,9 @@ final class LabelVisitor { AggregatingAttributeMapper.of(rule).visitLabels(new AttributeMap.AcceptsLabelAttribute() { @Override public void acceptLabelAttribute(Label label, Attribute attribute) { + if (!edgeFilter.apply(rule, attribute)) { + return; + } enqueueTarget(rule, attribute, label, depth, count); } }); @@ -427,7 +430,7 @@ final class LabelVisitor { private void visitAspectsIfRequired( Target from, Attribute attribute, final Target to, int depth, int count) { ImmutableMultimap<Attribute, Label> labelsFromAspects = - AspectDefinition.visitAspectsIfRequired(from, attribute, to); + AspectDefinition.visitAspectsIfRequired(from, attribute, to, edgeFilter); // Create an edge from target to the attribute value. for (Entry<Attribute, Label> entry : labelsFromAspects.entries()) { enqueueTarget(from, entry.getKey(), entry.getValue(), depth, count); |