diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java index bdd03ea0c0ad4c..e891605c4b8834 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java @@ -322,12 +322,6 @@ private ConfiguredTarget createRule( prerequisiteMap.values())) .build(); - ConfiguredTarget incompatibleTarget = - RuleContextConstraintSemantics.incompatibleConfiguredTarget(ruleContext, prerequisiteMap); - if (incompatibleTarget != null) { - return incompatibleTarget; - } - List> analysisFailures = depAnalysisFailures(ruleContext); if (!analysisFailures.isEmpty()) { return erroredConfiguredTargetWithFailures(ruleContext, analysisFailures); @@ -336,6 +330,12 @@ private ConfiguredTarget createRule( return erroredConfiguredTarget(ruleContext); } + ConfiguredTarget incompatibleTarget = + RuleContextConstraintSemantics.incompatibleConfiguredTarget(ruleContext, prerequisiteMap); + if (incompatibleTarget != null) { + return incompatibleTarget; + } + try { Class missingFragmentClass = null; for (Class fragmentClass : diff --git a/src/test/shell/integration/target_compatible_with_test.sh b/src/test/shell/integration/target_compatible_with_test.sh index d247dc1c5662d3..1c9be212c0835d 100755 --- a/src/test/shell/integration/target_compatible_with_test.sh +++ b/src/test/shell/integration/target_compatible_with_test.sh @@ -192,6 +192,36 @@ function tear_down() { bazel shutdown } +# Validates that we get a good error message when passing a config_setting into +# the target_compatible_with attribute. This is a regression test for +# https://github.com/bazelbuild/bazel/issues/13250. +function test_config_setting_in_target_compatible_with() { + cat >> target_skipping/BUILD < "${TEST_log}" && fail "Bazel succeeded unexpectedly." + + expect_log "'//target_skipping:foo3_config_setting' does not have mandatory providers: 'ConstraintValueInfo'" +} + # Validates that the console log provides useful information to the user for # builds. function test_console_log_for_builds() {