aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java
diff options
context:
space:
mode:
authorGravatar gregce <gregce@google.com>2018-08-08 10:43:59 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-08 10:45:57 -0700
commitf2a07a7336445b9b427c144c95663c2f2649a307 (patch)
treef4408c5b57fa270456deef047f512e6fb59ffa17 /src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java
parent8ed7d9670e619b6c0d2ef35ace61ede1562b9d56 (diff)
Improve error messaging for constraints violations.
1) Break up dense lines with clearer pretty-printing. 2) When a violation happens because of a select(), mention both the target with the select (as before) *and* the dep that the select() chose. 3) Integrate this messaging into --target_environment violations, which currently provide no info about the root cause. Examples: ------------------------------------- select() + compatible_with violation: ------------------------------------- Before: ERROR: /workspace/testapp/BUILD:41:1: in cc_binary rule //testapp:top: the current command-line flags disqualify all supported environments because of incompatible select() paths: environment: //constraints:p removed by: //testapp:midlib (/workspace/testapp/BUILD:28:1) After: ERROR: /workspace/testapp/BUILD:41:1: in cc_binary rule //testapp:top: the current command line flags disqualify all supported environments because of incompatible select() paths: environment: //constraints:p removed by: //testapp:midlib (/workspace/testapp/BUILD:28:1) which has a select() that chooses dep: //testapp:glib which lacks: //constraints:p. ------------------------------------- select() + --target_environment=//constraints:p violation: ------------------------------------- Before: ERROR: This is a restricted-environment build. - //testapp:top does not support required environment //constraints:p After: ERROR: This is a restricted-environment build. //testapp:top does not support: environment: //constraints:p removed by: //testapp:midlib (/workspace/testapp/BUILD:28:1) which has a select() that chooses dep: //testapp:g which lacks: //constraints:p Fixes: #5795 PiperOrigin-RevId: 207910308
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java
index ddc1ad6746..09b989f751 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java
@@ -29,6 +29,7 @@ import com.google.devtools.build.lib.analysis.constraints.ConstraintSemantics;
import com.google.devtools.build.lib.analysis.constraints.EnvironmentCollection;
import com.google.devtools.build.lib.analysis.constraints.SupportedEnvironments;
import com.google.devtools.build.lib.analysis.constraints.SupportedEnvironmentsProvider;
+import com.google.devtools.build.lib.analysis.constraints.SupportedEnvironmentsProvider.RemovedEnvironmentCulprit;
import com.google.devtools.build.lib.analysis.test.ExecutionInfo;
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesProvider;
import com.google.devtools.build.lib.analysis.test.TestActionBuilder;
@@ -183,7 +184,7 @@ public final class RuleConfiguredTargetBuilder {
constraintSemantics.getSupportedEnvironments(ruleContext);
if (supportedEnvironments != null) {
EnvironmentCollection.Builder refinedEnvironments = new EnvironmentCollection.Builder();
- Map<Label, LabelAndLocation> removedEnvironmentCulprits = new LinkedHashMap<>();
+ Map<Label, RemovedEnvironmentCulprit> removedEnvironmentCulprits = new LinkedHashMap<>();
constraintSemantics.checkConstraints(ruleContext, supportedEnvironments, refinedEnvironments,
removedEnvironmentCulprits);
add(SupportedEnvironmentsProvider.class,