aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Greg Estren <gregce@google.com>2015-04-22 17:33:50 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2015-04-23 09:17:48 +0000
commitcbe694de412cb2c8ac64fdf11152acc5a54e91bd (patch)
treed71d126fb17a4243f3da518f1a14de9d5493de25 /src/main
parent3c65191130fa842bf9d3e6b1879f7cec6f56e764 (diff)
Constraints: don't check constraints on implicit or latebound
dependencies. -- MOS_MIGRATED_REVID=91801043
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/constraints/ConstraintSemantics.java45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/constraints/ConstraintSemantics.java b/src/main/java/com/google/devtools/build/lib/analysis/constraints/ConstraintSemantics.java
index 707b688387..7bc1f19b42 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/constraints/ConstraintSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/constraints/ConstraintSemantics.java
@@ -25,6 +25,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.constraints.EnvironmentCollection.EnvironmentWithGroup;
+import com.google.devtools.build.lib.packages.Attribute;
import com.google.devtools.build.lib.packages.AttributeMap;
import com.google.devtools.build.lib.packages.EnvironmentGroup;
import com.google.devtools.build.lib.packages.Rule;
@@ -518,27 +519,31 @@ public class ConstraintSemantics {
AttributeMap attributes = ruleContext.attributes();
for (String attr : attributes.getAttributeNames()) {
+ Attribute attrDef = attributes.getAttributeDefinition(attr);
Type<?> attrType = attributes.getAttributeType(attr);
- if ((attrType == Type.LABEL || attrType == Type.LABEL_LIST)
- && !RuleClass.isConstraintAttribute(attr)
- && !attr.equals("visibility")) {
-
- for (TransitiveInfoCollection dep :
- ruleContext.getPrerequisites(attr, RuleConfiguredTarget.Mode.DONT_CHECK)) {
- // Output files inherit the environment spec of their generating rule.
- if (dep instanceof OutputFileConfiguredTarget) {
- // Note this reassignment means constraint violation errors reference the generating
- // rule, not the file. This makes the source of the environmental mismatch more clear.
- dep = ((OutputFileConfiguredTarget) dep).getGeneratingRule();
- }
- // Input files don't support environments. We may subsequently opt them into constraint
- // checking, but for now just pass them by. Otherwise, we opt in anything that's not
- // a host dependency.
- // TODO(bazel-team): support choosing which attributes are subject to constraint checking
- if (dep.getProvider(SupportedEnvironmentsProvider.class) != null
- && !Verify.verifyNotNull(dep.getConfiguration()).isHostConfiguration()) {
- depsToCheck.add(dep);
- }
+ if ((attrType != Type.LABEL && attrType != Type.LABEL_LIST)
+ || RuleClass.isConstraintAttribute(attr)
+ || attr.equals("visibility")
+ || attrDef.isImplicit()
+ || attrDef.isLateBound()) {
+ continue;
+ }
+
+ for (TransitiveInfoCollection dep :
+ ruleContext.getPrerequisites(attr, RuleConfiguredTarget.Mode.DONT_CHECK)) {
+ // Output files inherit the environment spec of their generating rule.
+ if (dep instanceof OutputFileConfiguredTarget) {
+ // Note this reassignment means constraint violation errors reference the generating
+ // rule, not the file. This makes the source of the environmental mismatch more clear.
+ dep = ((OutputFileConfiguredTarget) dep).getGeneratingRule();
+ }
+ // Input files don't support environments. We may subsequently opt them into constraint
+ // checking, but for now just pass them by. Otherwise, we opt in anything that's not
+ // a host dependency.
+ // TODO(bazel-team): support choosing which attributes are subject to constraint checking
+ if (dep.getProvider(SupportedEnvironmentsProvider.class) != null
+ && !Verify.verifyNotNull(dep.getConfiguration()).isHostConfiguration()) {
+ depsToCheck.add(dep);
}
}
}