From 654dc8e6d3679a7934288a8750c03f7c57ecc371 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 25 Oct 2022 12:37:20 -0700 Subject: [PATCH] Make constraint_setting / constraint_value non_configurable. The concept of allowing what is fundamentally a constant to vary by target we are building for is too much to reason about, let along get the code correct. PiperOrigin-RevId: 483748098 Change-Id: I966b7d21ad8d38de9867c870a0669e2123063809 --- .../com/google/devtools/build/lib/packages/RuleClass.java | 8 -------- .../build/lib/rules/platform/ConstraintSettingRule.java | 4 +++- .../build/lib/rules/platform/ConstraintValueRule.java | 3 ++- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java index c2b622168e7018..2b9b245c592c95 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java @@ -2725,14 +2725,6 @@ public boolean isPackageMetadataRule() { // not building it today because the exact needs are not clear. return true; } - // BEGIN-INTERNAL - // TODO(aiuto): This is a Google-ism, remove from Bazel. - String packageName = ruleDefinitionEnvironmentLabel.getPackageName(); - if (packageName.startsWith("tools/build_defs/license") - || packageName.startsWith("third_party/rules_license")) { - return true; - } - // END-INTERNAL return false; } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java index fe47d8f1974af1..7449ece8e92c3b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java @@ -43,7 +43,9 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) constraint list (such as for a config_setting) that requires a particular value for that setting. */ - .add(attr(DEFAULT_CONSTRAINT_VALUE_ATTR, BuildType.NODEP_LABEL)) + .add( + attr(DEFAULT_CONSTRAINT_VALUE_ATTR, BuildType.NODEP_LABEL) + .nonconfigurable("constants must be consistent across configurations")) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java index 1a34bff1929781..b716a0aa86bbf0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java @@ -42,7 +42,8 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) .mandatory() .allowedRuleClasses(ConstraintSettingRule.RULE_NAME) .allowedFileTypes(FileTypeSet.NO_FILE) - .mandatoryProviders(ConstraintSettingInfo.PROVIDER.id())) + .mandatoryProviders(ConstraintSettingInfo.PROVIDER.id()) + .nonconfigurable("constants must be consistent across configurations")) .build(); }