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.
  • Loading branch information
katre committed Nov 4, 2019
1 parent 6b7ea37 commit 9dace66
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 91 deletions.
Expand Up @@ -285,7 +285,6 @@ public BaseFunction rule(
SkylarkList<?> toolchains,
String doc,
SkylarkList<?> providesArg,
Boolean executionPlatformConstraintsAllowed,
SkylarkList<?> execCompatibleWith,
Object analysisTest,
Object buildSetting,
Expand Down Expand Up @@ -407,11 +406,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 @@ -394,6 +394,20 @@ public static class GraveyardOptions extends OptionsBase {
effectTags = {OptionEffectTag.UNKNOWN},
help = "No-op.")
public boolean experimentalUi;

@Deprecated
@Option(
name = "incompatible_disallow_rule_execution_platform_constraints_allowed",
defaultValue = "True",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.NO_OP},
metadataTags = {
OptionMetadataTag.DEPRECATED,
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "This option is deprecated and has no effect.")
public boolean incompatibleDisallowRuleExecutionPlatformConstraintsAllowed;
}

@Override
Expand Down
Expand Up @@ -355,20 +355,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 @@ -701,8 +687,6 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleDisallowEmptyGlob(incompatibleDisallowEmptyGlob)
.incompatibleDisallowOldStyleArgsAdd(incompatibleDisallowOldStyleArgsAdd)
.incompatibleDisallowStructProviderSyntax(incompatibleDisallowStructProviderSyntax)
.incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(
incompatibleDisallowRuleExecutionPlatformConstraintsAllowed)
.incompatibleDisallowUnverifiedHttpDownloads(
incompatibleDisallowUnverifiedHttpDownloads)
.incompatibleExpandDirectories(incompatibleExpandDirectories)
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 @@ -64,8 +64,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 @@ -169,8 +167,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)
.incompatibleExpandDirectories(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 @@ -198,7 +198,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 9dace66

Please sign in to comment.