Skip to content

Commit

Permalink
Remove the deprecated option
Browse files Browse the repository at this point in the history
`--incompatible_disallow_rule_execution_platform_constraints_allowed`
and the associated Starlark code.

Part of bazelbuild#8134. Next PR will remove the actual underlying RuleClass enum
and functionality.

Closes bazelbuild#10163.

PiperOrigin-RevId: 278911121
  • Loading branch information
katre authored and Copybara-Service committed Nov 6, 2019
1 parent fb3a64d commit e4eadec
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 92 deletions.
Expand Up @@ -283,7 +283,6 @@ public BaseFunction rule(
SkylarkList<?> toolchains,
String doc,
SkylarkList<?> providesArg,
Boolean executionPlatformConstraintsAllowed,
SkylarkList<?> execCompatibleWith,
Object analysisTest,
Object buildSetting,
Expand Down Expand Up @@ -405,11 +404,7 @@ public BaseFunction rule(
bazelContext.getRepoMapping()));
}

if (executionPlatformConstraintsAllowed) {
builder.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_TARGET);
} else {
builder.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_RULE);
}
builder.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_TARGET);

return new SkylarkRuleFunction(builder, type, attributes, ast.getLocation());
}
Expand Down
Expand Up @@ -356,20 +356,6 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
// TODO(elenairina): Move option to graveyard after the flag is removed from the global blazerc.
public boolean incompatibleDisallowLegacyJavaInfo;

@Option(
name = "incompatible_disallow_rule_execution_platform_constraints_allowed",
defaultValue = "True",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"If set to true, disallow the use of the execution_platform_constraints_allowed "
+ "attribute on rule().")
public boolean incompatibleDisallowRuleExecutionPlatformConstraintsAllowed;

@Option(
name = "incompatible_string_join_requires_strings",
defaultValue = "true",
Expand Down Expand Up @@ -688,8 +674,6 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleDisallowEmptyGlob(incompatibleDisallowEmptyGlob)
.incompatibleDisallowOldStyleArgsAdd(incompatibleDisallowOldStyleArgsAdd)
.incompatibleDisallowStructProviderSyntax(incompatibleDisallowStructProviderSyntax)
.incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(
incompatibleDisallowRuleExecutionPlatformConstraintsAllowed)
.incompatibleDisallowUnverifiedHttpDownloads(
incompatibleDisallowUnverifiedHttpDownloads)
.incompatibleNewActionsApi(incompatibleNewActionsApi)
Expand Down
Expand Up @@ -271,23 +271,6 @@ public interface SkylarkRuleFunctionsApi<FileApiT extends FileApi> {
positional = false,
defaultValue = "[]",
doc = PROVIDES_DOC),
@Param(
name = "execution_platform_constraints_allowed",
type = Boolean.class,
named = true,
positional = false,
defaultValue = "True",
disableWithFlag =
FlagIdentifier.INCOMPATIBLE_DISALLOW_RULE_EXECUTION_PLATFORM_CONSTRAINTS_ALLOWED,
valueWhenDisabled = "True",
doc =
"If true, a special attribute named <code>exec_compatible_with</code> of "
+ "label-list type is added, which must not already exist in "
+ "<code>attrs</code>. Targets may use this attribute to specify additional "
+ "constraints on the execution platform beyond those given in the "
+ "<code>exec_compatible_with</code> argument to <code>rule()</code>. "
+ "This will be deprecated and removed in the near future, and all rules will "
+ "be able to use <code>exec_compatible_with</code>."),
@Param(
name = "exec_compatible_with",
type = SkylarkList.class,
Expand Down Expand Up @@ -362,7 +345,6 @@ public BaseFunction rule(
SkylarkList<?> toolchains,
String doc,
SkylarkList<?> providesArg,
Boolean executionPlatformConstraintsAllowed,
SkylarkList<?> execCompatibleWith,
Object analysisTest,
Object buildSetting,
Expand Down
Expand Up @@ -65,8 +65,6 @@ public enum FlagIdentifier {
INCOMPATIBLE_NO_RULE_OUTPUTS_PARAM(StarlarkSemantics::incompatibleNoRuleOutputsParam),
INCOMPATIBLE_NO_TARGET_OUTPUT_GROUP(StarlarkSemantics::incompatibleNoTargetOutputGroup),
INCOMPATIBLE_NO_ATTR_LICENSE(StarlarkSemantics::incompatibleNoAttrLicense),
INCOMPATIBLE_DISALLOW_RULE_EXECUTION_PLATFORM_CONSTRAINTS_ALLOWED(
StarlarkSemantics::incompatibleDisallowRuleExecutionPlatformConstraintsAllowed),
INCOMPATIBLE_ALLOW_TAGS_PROPAGATION(StarlarkSemantics::experimentalAllowTagsPropagation),
NONE(null);

Expand Down Expand Up @@ -172,8 +170,6 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean incompatibleDisallowOldStyleArgsAdd();

public abstract boolean incompatibleDisallowRuleExecutionPlatformConstraintsAllowed();

public abstract boolean incompatibleDisallowStructProviderSyntax();

public abstract boolean incompatibleDisallowUnverifiedHttpDownloads();
Expand Down Expand Up @@ -273,7 +269,6 @@ public static Builder builderWithDefaults() {
.incompatibleDisallowDictPlus(true)
.incompatibleDisallowEmptyGlob(false)
.incompatibleDisallowOldStyleArgsAdd(true)
.incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(true)
.incompatibleDisallowStructProviderSyntax(false)
.incompatibleDisallowUnverifiedHttpDownloads(true)
.incompatibleNewActionsApi(true)
Expand Down Expand Up @@ -346,9 +341,6 @@ public abstract static class Builder {

public abstract Builder incompatibleDisallowOldStyleArgsAdd(boolean value);

public abstract Builder incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(
boolean value);

public abstract Builder incompatibleDisallowStructProviderSyntax(boolean value);

public abstract Builder incompatibleDisallowUnverifiedHttpDownloads(boolean value);
Expand Down
Expand Up @@ -139,7 +139,6 @@ public BaseFunction rule(
SkylarkList<?> toolchains,
String doc,
SkylarkList<?> providesArg,
Boolean executionPlatformConstraintsAllowed,
SkylarkList<?> execCompatibleWith,
Object analysisTest,
Object buildSetting,
Expand Down
Expand Up @@ -144,7 +144,6 @@ private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws E
"--incompatible_disallow_dict_plus=" + rand.nextBoolean(),
"--incompatible_disallow_empty_glob=" + rand.nextBoolean(),
"--incompatible_disallow_old_style_args_add=" + rand.nextBoolean(),
"--incompatible_disallow_rule_execution_platform_constraints_allowed=" + rand.nextBoolean(),
"--incompatible_disallow_struct_provider_syntax=" + rand.nextBoolean(),
"--incompatible_disallow_unverified_http_downloads=" + rand.nextBoolean(),
"--incompatible_do_not_split_linking_cmdline=" + rand.nextBoolean(),
Expand Down Expand Up @@ -198,7 +197,6 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.incompatibleDisallowDictPlus(rand.nextBoolean())
.incompatibleDisallowEmptyGlob(rand.nextBoolean())
.incompatibleDisallowOldStyleArgsAdd(rand.nextBoolean())
.incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(rand.nextBoolean())
.incompatibleDisallowStructProviderSyntax(rand.nextBoolean())
.incompatibleDisallowUnverifiedHttpDownloads(rand.nextBoolean())
.incompatibleDoNotSplitLinkingCmdline(rand.nextBoolean())
Expand Down
Expand Up @@ -1734,58 +1734,18 @@ public void testRuleAddExecutionConstraints() throws Exception {
}

@Test
public void testTargetsCanAddExecutionPlatformConstraints_enabled() throws Exception {
setSkylarkSemanticsOptions(
"--incompatible_disallow_rule_execution_platform_constraints_allowed=false");
reset();

public void testTargetsCanAddExecutionPlatformConstraints() throws Exception {
registerDummyStarlarkFunction();
scratch.file("test/BUILD", "toolchain_type(name = 'my_toolchain_type')");
evalAndExport(
"r1 = rule(impl, ",
" toolchains=['//test:my_toolchain_type'],",
" execution_platform_constraints_allowed=True,",
")");
RuleClass c = ((SkylarkRuleFunction) lookup("r1")).getRuleClass();
assertThat(c.executionPlatformConstraintsAllowed())
.isEqualTo(ExecutionPlatformConstraintsAllowed.PER_TARGET);
}

@Test
public void testTargetsCanAddExecutionPlatformConstraints_notEnabled() throws Exception {
setSkylarkSemanticsOptions(
"--incompatible_disallow_rule_execution_platform_constraints_allowed=false");
reset();

registerDummyStarlarkFunction();
scratch.file("test/BUILD", "toolchain_type(name = 'my_toolchain_type')");
evalAndExport(
"r1 = rule(impl, ",
" toolchains=['//test:my_toolchain_type'],",
" execution_platform_constraints_allowed=False,",
")");
RuleClass c = ((SkylarkRuleFunction) lookup("r1")).getRuleClass();
assertThat(c.executionPlatformConstraintsAllowed())
.isEqualTo(ExecutionPlatformConstraintsAllowed.PER_RULE);
}

@Test
public void testTargetsCanAddExecutionPlatformConstraints_disallowed() throws Exception {
setSkylarkSemanticsOptions(
"--incompatible_disallow_rule_execution_platform_constraints_allowed=true");
reset();

ev.setFailFast(false);
registerDummyStarlarkFunction();
scratch.file("test/BUILD", "toolchain_type(name = 'my_toolchain_type')");
evalAndExport(
"r1 = rule(impl, ",
" toolchains=['//test:my_toolchain_type'],",
" execution_platform_constraints_allowed=True,",
")");
ev.assertContainsError("parameter 'execution_platform_constraints_allowed' is deprecated");
}

@Test
public void testRuleFunctionReturnsNone() throws Exception {
scratch.file("test/rule.bzl",
Expand Down

0 comments on commit e4eadec

Please sign in to comment.