Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add incompatible_disallow_rule_execution_platform_constraints_allowed flag. #8145

Closed
wants to merge 6 commits into from

Conversation

katre
Copy link
Member

@katre katre commented Apr 25, 2019

Part of #8136 and #8134.

RELNOTES: Adds
incompatible_disallow_rule_execution_platform_constraints_allowed, which
disallows the use of the "execution_platform_constraints_allowed"
attribute when defining new rules.

flag.

Part of bazelbuild#8136 and bazelbuild#8134.

RELNOTES: Adds
incompatible_disallow_rule_execution_platform_constraints_allowed, which
disallows the use of the "execution_platform_constraints_allowed"
attribute when defining new rules.
@@ -398,8 +398,13 @@ public BaseFunction rule(
execCompatibleWith.getContents(String.class, "exec_compatile_with"),
ast.getLocation()));
}
if (executionPlatformConstraintsAllowed) {

if (funcallEnv.getSemantics().incompatibleDisallowRuleExecutionPlatformConstraintsAllowed()) {
Copy link
Contributor

@c-parsons c-parsons Apr 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like the fully incompatible change you want -- a user can still specify rule(..., execution_platform_constraints_allowed = False), it just would have no effect.

I'd recommend the following instead of any change in this class:

  1. Introduce a new FlagIdentifier entry in StarlarkSemantics.java for the new flag
  2. In SkylarkRuleFunctionsApi.java, find the @param for execution_platform_constraints_allowed, and set the following fields on it:
    A. disableWithFlag = [new flag identifier]
    B. valueWhenDisabled = "True"

This should work out-of-the-box (but you should write a specific test for it, just in case :)) Let me know if you run into any issues!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is much cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add a test~!

@@ -623,6 +637,8 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleDisallowOldOctalNotation(incompatibleDisallowOldOctalNotation)
.incompatibleDisallowOldStyleArgsAdd(incompatibleDisallowOldStyleArgsAdd)
.incompatibleDisallowStructProviderSyntax(incompatibleDisallowStructProviderSyntax)
.incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When introducing new flags, you also need to update SkylarkSemanticsConsistencyTest.java

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -54,6 +54,7 @@
INCOMPATIBLE_NO_TARGET_OUTPUT_GROUP(StarlarkSemantics::incompatibleNoTargetOutputGroup),
INCOMPATIBLE_NO_ATTR_LICENSE(StarlarkSemantics::incompatibleNoAttrLicense),
INCOMPATIBLE_OBJC_FRAMEWORK_CLEANUP(StarlarkSemantics::incompatibleObjcFrameworkCleanup),
INCOMPATIBLE_DISALLOW_RULE_EXECUTION_PLATFORM_CONSTRAINTS_ALLOWED(StarlarkSemantics::incompatibleDisallowRuleExecutionPlatformConstraintsAllowed),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap to avoid line length limit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grr my formatter script didn't work, sorry.

@@ -398,8 +398,13 @@ public BaseFunction rule(
execCompatibleWith.getContents(String.class, "exec_compatile_with"),
ast.getLocation()));
}
if (executionPlatformConstraintsAllowed) {

if (funcallEnv.getSemantics().incompatibleDisallowRuleExecutionPlatformConstraintsAllowed()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add a test~!

@katre
Copy link
Member Author

katre commented Apr 25, 2019

Tests added.

scratch.file("test/BUILD", "toolchain_type(name = 'my_toolchain_type')");
evalAndExport(
"def impl():",
" return 0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: AFAIK creating a target with these rules in these tests would fail with a different error anyway because you can't return an int from a rule implementation. return [] instead or just pass

Same for the other new tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just copying registerDummyUserDefinedFunction, which I have switched back to using and also fixed.

@@ -164,6 +166,8 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean incompatibleDisallowStructProviderSyntax();

public abstract boolean incompatibleDisallowRuleExecutionPlatformConstraintsAllowed();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is nitty, but the docs above mandate listing variables here and in the other places alphabetically, and I know there's some precedent for enforcing that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll fix that on the imported version.

@bazel-io bazel-io closed this in 5688793 Apr 26, 2019
@katre katre deleted the i8136-epca-flag branch April 26, 2019 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants