Remove the ExecutionPlatformConstraintsAllowed enum entirely.
Fixes #8134.
Closes #10182.
PiperOrigin-RevId: 279141108
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 f4e1d18..af803b0 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
@@ -221,44 +221,6 @@
}
/**
- * Describes in which way a rule implementation allows additional execution platform constraints.
- */
- public enum ExecutionPlatformConstraintsAllowed {
- /**
- * Allows additional execution platform constraints to be added in the rule definition, which
- * apply to all targets of that rule.
- */
- PER_RULE(1),
- /**
- * Users are allowed to specify additional execution platform constraints for each target, using
- * the 'exec_compatible_with' attribute. This also allows setting constraints in the rule
- * definition, like PER_RULE.
- */
- PER_TARGET(2);
-
- private final int priority;
-
- ExecutionPlatformConstraintsAllowed(int priority) {
- this.priority = priority;
- }
-
- public int priority() {
- return priority;
- }
-
- public static ExecutionPlatformConstraintsAllowed highestPriority(
- ExecutionPlatformConstraintsAllowed first, ExecutionPlatformConstraintsAllowed... rest) {
- ExecutionPlatformConstraintsAllowed result = first;
- for (ExecutionPlatformConstraintsAllowed value : rest) {
- if (result == null || result.priority() < value.priority()) {
- result = value;
- }
- }
- return result;
- }
- }
-
- /**
* For Bazel's constraint system: the attribute that declares the set of environments a rule
* supports, overriding the defaults for their respective groups.
*/
@@ -724,8 +686,6 @@
private final Map<String, Attribute> attributes = new LinkedHashMap<>();
private final Set<Label> requiredToolchains = new HashSet<>();
private boolean useToolchainResolution = true;
- private ExecutionPlatformConstraintsAllowed executionPlatformConstraintsAllowed =
- ExecutionPlatformConstraintsAllowed.PER_RULE;
private Set<Label> executionPlatformConstraints = new HashSet<>();
private OutputFile.Kind outputFileKind = OutputFile.Kind.FILE;
@@ -760,21 +720,10 @@
addRequiredToolchains(parent.getRequiredToolchains());
useToolchainResolution = parent.useToolchainResolution;
-
- // Make sure we use the highest priority value from all parents.
- executionPlatformConstraintsAllowed(
- ExecutionPlatformConstraintsAllowed.highestPriority(
- executionPlatformConstraintsAllowed, parent.executionPlatformConstraintsAllowed()));
addExecutionPlatformConstraints(parent.getExecutionPlatformConstraints());
for (Attribute attribute : parent.getAttributes()) {
String attrName = attribute.getName();
- // TODO(https://github.com/bazelbuild/bazel/issues/8134): Define the attribute on a
- // standard base class and remove this check entirely.
- if (attrName.equals(RuleClass.EXEC_COMPATIBLE_WITH_ATTR)) {
- // Don't inherit: this will be re-created
- continue;
- }
Preconditions.checkArgument(
!attributes.containsKey(attrName) || attributes.get(attrName).equals(attribute),
"Attribute %s is inherited multiple times in %s ruleclass",
@@ -832,14 +781,7 @@
if (type == RuleClassType.PLACEHOLDER) {
Preconditions.checkNotNull(ruleDefinitionEnvironmentHashCode, this.name);
}
- if (executionPlatformConstraintsAllowed == ExecutionPlatformConstraintsAllowed.PER_TARGET
- && !this.contains(EXEC_COMPATIBLE_WITH_ATTR)) {
- this.add(
- attr(EXEC_COMPATIBLE_WITH_ATTR, BuildType.LABEL_LIST)
- .allowedFileTypes()
- .nonconfigurable("Used in toolchain resolution")
- .value(ImmutableList.of()));
- }
+
if (buildSetting != null) {
Type<?> type = buildSetting.getType();
Attribute.Builder<?> attrBuilder =
@@ -888,7 +830,6 @@
thirdPartyLicenseExistencePolicy,
requiredToolchains,
useToolchainResolution,
- executionPlatformConstraintsAllowed,
executionPlatformConstraints,
outputFileKind,
attributes.values(),
@@ -1398,20 +1339,6 @@
}
/**
- * Specifies whether targets of this rule can add additional constraints on the execution
- * platform selected. If this is {@link ExecutionPlatformConstraintsAllowed#PER_TARGET}, there
- * will be an attribute named {@code exec_compatible_with} that can be used to add these
- * constraints.
- *
- * <p>Please note that this value is not inherited by child rules, and must be re-set on them if
- * the same behavior is required.
- */
- public Builder executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed value) {
- this.executionPlatformConstraintsAllowed = value;
- return this;
- }
-
- /**
* Adds additional execution platform constraints that apply for all targets from this rule.
*
* <p>Please note that this value is inherited by child rules.
@@ -1559,7 +1486,6 @@
private final ImmutableSet<Label> requiredToolchains;
private final boolean useToolchainResolution;
- private final ExecutionPlatformConstraintsAllowed executionPlatformConstraintsAllowed;
private final ImmutableSet<Label> executionPlatformConstraints;
/**
@@ -1614,7 +1540,6 @@
ThirdPartyLicenseExistencePolicy thirdPartyLicenseExistencePolicy,
Set<Label> requiredToolchains,
boolean useToolchainResolution,
- ExecutionPlatformConstraintsAllowed executionPlatformConstraintsAllowed,
Set<Label> executionPlatformConstraints,
OutputFile.Kind outputFileKind,
Collection<Attribute> attributes,
@@ -1653,7 +1578,6 @@
this.thirdPartyLicenseExistencePolicy = thirdPartyLicenseExistencePolicy;
this.requiredToolchains = ImmutableSet.copyOf(requiredToolchains);
this.useToolchainResolution = useToolchainResolution;
- this.executionPlatformConstraintsAllowed = executionPlatformConstraintsAllowed;
this.executionPlatformConstraints = ImmutableSet.copyOf(executionPlatformConstraints);
this.buildSetting = buildSetting;
@@ -2548,10 +2472,6 @@
return useToolchainResolution;
}
- public ExecutionPlatformConstraintsAllowed executionPlatformConstraintsAllowed() {
- return executionPlatformConstraintsAllowed;
- }
-
public ImmutableSet<Label> getExecutionPlatformConstraints() {
return executionPlatformConstraints;
}