Skip to content

Commit

Permalink
Make incompatible_new_actions_api no-op
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 576215983
Change-Id: Iec25e6f8c3c019fcbd1a54da80dacc1b86eddd3c
  • Loading branch information
mai93 authored and copybara-github committed Oct 24, 2023
1 parent 3db362c commit 6c02329
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@ public static final class BazelBuildGraveyardOptions extends BuildGraveyardOptio
* want to graveyard an all-command option specific to Blaze or Bazel, create a subclass.
*/
public static final class AllCommandGraveyardOptions extends OptionsBase {

@Option(
name = "incompatible_new_actions_api",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
effectTags = {OptionEffectTag.NO_OP},
help = "No-op")
public boolean incompatibleNewActionsApi;

@Option(
name = "experimental_enable_aspect_hints",
defaultValue = "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,6 @@ public final class BuildLanguageOptions extends OptionsBase {
+ "to the rule definition, falling back to rule usage if not visible.")
public boolean incompatibleVisibilityPrivateAttributesAtDefinition;

@Option(
name = "incompatible_new_actions_api",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
help =
"If set to true, the API to create actions is only available on `ctx.actions`, "
+ "not on `ctx`.")
public boolean incompatibleNewActionsApi;

@Option(
name = "incompatible_no_attr_license",
defaultValue = "true",
Expand Down Expand Up @@ -754,7 +743,6 @@ public StarlarkSemantics toStarlarkSemantics() {
INCOMPATIBLE_FIX_PACKAGE_GROUP_REPOROOT_SYNTAX,
incompatibleFixPackageGroupReporootSyntax)
.setBool(INCOMPATIBLE_JAVA_COMMON_PARAMETERS, incompatibleJavaCommonParameters)
.setBool(INCOMPATIBLE_NEW_ACTIONS_API, incompatibleNewActionsApi)
.setBool(INCOMPATIBLE_NO_ATTR_LICENSE, incompatibleNoAttrLicense)
.setBool(INCOMPATIBLE_NO_IMPLICIT_FILE_EXPORT, incompatibleNoImplicitFileExport)
.setBool(INCOMPATIBLE_NO_PACKAGE_DISTRIBS, incompatibleNoPackageDistribs)
Expand Down Expand Up @@ -861,7 +849,6 @@ public StarlarkSemantics toStarlarkSemantics() {
"+incompatible_do_not_split_linking_cmdline";
public static final String INCOMPATIBLE_JAVA_COMMON_PARAMETERS =
"+incompatible_java_common_parameters";
public static final String INCOMPATIBLE_NEW_ACTIONS_API = "+incompatible_new_actions_api";
public static final String INCOMPATIBLE_NO_ATTR_LICENSE = "+incompatible_no_attr_license";
public static final String INCOMPATIBLE_NO_PACKAGE_DISTRIBS = "-incompatible_no_package_distribs";
public static final String INCOMPATIBLE_NO_IMPLICIT_FILE_EXPORT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public static void main(String[] args)
.build();
parser.parseAndExitUponError(args);
BuildLanguageOptions semanticsOptions = parser.getOptions(BuildLanguageOptions.class);
semanticsOptions.incompatibleNewActionsApi = false;
SkydocOptions skydocOptions = parser.getOptions(SkydocOptions.class);

String targetFileLabelString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ private static BuildLanguageOptions buildRandomOptions(Random rand) throws Excep
"--incompatible_do_not_split_linking_cmdline=" + rand.nextBoolean(),
"--incompatible_java_common_parameters=" + rand.nextBoolean(),
"--incompatible_merge_fixed_and_default_shell_env=" + rand.nextBoolean(),
"--incompatible_new_actions_api=" + rand.nextBoolean(),
"--incompatible_no_attr_license=" + rand.nextBoolean(),
"--incompatible_no_implicit_file_export=" + rand.nextBoolean(),
"--incompatible_no_package_distribs=" + rand.nextBoolean(),
Expand Down Expand Up @@ -194,7 +193,6 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.setBool(BuildLanguageOptions.INCOMPATIBLE_JAVA_COMMON_PARAMETERS, rand.nextBoolean())
.setBool(
BuildLanguageOptions.INCOMPATIBLE_MERGE_FIXED_AND_DEFAULT_SHELL_ENV, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_NEW_ACTIONS_API, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_NO_ATTR_LICENSE, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_NO_IMPLICIT_FILE_EXPORT, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_NO_PACKAGE_DISTRIBS, rand.nextBoolean())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,6 @@ public void testCoverageInstrumentedMatchesFilterNonDefaultLabel() throws Except

@Test
public void testFrozenRuleContextHasInaccessibleAttributes() throws Exception {
setBuildLanguageOptions("--incompatible_new_actions_api=false");
scratch.file(
"test/BUILD",
"load('//test:rules.bzl', 'main_rule', 'dep_rule')",
Expand Down Expand Up @@ -2948,14 +2947,11 @@ public void testFrozenRuleContextForAspectsHasInaccessibleAttributes() throws Ex
" 'deps': attr.label_list(aspects = [MyAspect])",
" },",
")");
setBuildLanguageOptions("--incompatible_new_actions_api=false");

reporter.removeHandler(failFastHandler);
invalidatePackages();

AssertionError e =
assertThrows(
"Should have been unable to access dep." + attribute,
AssertionError.class,
() -> getConfiguredTarget("//test:main"));
getConfiguredTarget("//test:main");

// Typical value of e.getMessage():
//
Expand All @@ -2966,13 +2962,11 @@ public void testFrozenRuleContextForAspectsHasInaccessibleAttributes() throws Ex
// File "/workspace/test/rules.bzl", line 7, column 18, in _aspect_impl
// Error: cannot access field or method 'attr' of rule context for '//test:dep' \
// outside of its own rule implementation function
assertThat(e)
.hasMessageThat()
.contains(
"cannot access field or method '"
+ Iterables.get(Splitter.on('(').split(attribute), 0)
+ "' of rule context for '//test:dep' outside of its own rule implementation "
+ "function");
assertContainsEvent(
"cannot access field or method '"
+ Iterables.get(Splitter.on('(').split(attribute), 0)
+ "' of rule context for '//test:dep' outside of its own rule implementation "
+ "function");
}
}

Expand Down

0 comments on commit 6c02329

Please sign in to comment.