Skip to content

Commit 9a765c8

Browse files
mai93copybara-github
authored andcommitted
Flip --incompatible_top_level_aspects_dependency flag
Aspect-on-aspect will be enabled by default for command line aspects. PiperOrigin-RevId: 398224654
1 parent 44fa806 commit 9a765c8

File tree

4 files changed

+12
-42
lines changed

4 files changed

+12
-42
lines changed

src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ public class BuildLanguageOptions extends OptionsBase implements Serializable {
560560

561561
@Option(
562562
name = "incompatible_top_level_aspects_dependency",
563-
defaultValue = "false",
563+
defaultValue = "true",
564564
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
565565
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
566566
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
@@ -718,7 +718,7 @@ public StarlarkSemantics toStarlarkSemantics() {
718718
public static final String INCOMPATIBLE_TOP_LEVEL_ASPECTS_REQUIRE_PROVIDERS =
719719
"-incompatible_top_level_aspects_require_providers";
720720
public static final String INCOMPATIBLE_TOP_LEVEL_ASPECTS_DEPENDENCY =
721-
"-incompatible_top_level_aspects_dependency";
721+
"+incompatible_top_level_aspects_dependency";
722722

723723
// non-booleans
724724
public static final StarlarkSemantics.Key<String> EXPERIMENTAL_BUILTINS_BZL_PATH =

src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ public void duplicateTopLevelAspects_duplicateAspectsIgnored() throws Exception
885885
AspectApplyingToFiles aspectApplyingToFiles = new AspectApplyingToFiles();
886886
setRulesAndAspectsAvailableInTests(ImmutableList.of(aspectApplyingToFiles), ImmutableList.of());
887887
pkg("a", "java_binary(name = 'x', main_class = 'x.FooBar', srcs = ['x.java'])");
888+
useConfiguration("--noincompatible_top_level_aspects_dependency");
888889

889890
AnalysisResult analysisResult =
890891
update(
@@ -904,7 +905,6 @@ public void duplicateTopLevelAspects_duplicateAspectsNotAllowed() throws Excepti
904905
AspectApplyingToFiles aspectApplyingToFiles = new AspectApplyingToFiles();
905906
setRulesAndAspectsAvailableInTests(ImmutableList.of(aspectApplyingToFiles), ImmutableList.of());
906907
pkg("a", "java_binary(name = 'x', main_class = 'x.FooBar', srcs = ['x.java'])");
907-
useConfiguration("--incompatible_top_level_aspects_dependency");
908908
reporter.removeHandler(failFastHandler);
909909

910910
assertThrows(

src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ private static BuildLanguageOptions buildRandomOptions(Random rand) throws Excep
147147
"--incompatible_no_rule_outputs_param=" + rand.nextBoolean(),
148148
"--incompatible_run_shell_command_string=" + rand.nextBoolean(),
149149
"--incompatible_struct_has_no_methods=" + rand.nextBoolean(),
150+
"--incompatible_top_level_aspects_dependency=" + rand.nextBoolean(),
150151
"--incompatible_visibility_private_attributes_at_definition=" + rand.nextBoolean(),
151152
"--incompatible_require_linker_input_cc_api=" + rand.nextBoolean(),
152153
"--incompatible_restrict_string_escapes=" + rand.nextBoolean(),
@@ -197,6 +198,7 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
197198
.setBool(BuildLanguageOptions.INCOMPATIBLE_NO_RULE_OUTPUTS_PARAM, rand.nextBoolean())
198199
.setBool(BuildLanguageOptions.INCOMPATIBLE_RUN_SHELL_COMMAND_STRING, rand.nextBoolean())
199200
.setBool(BuildLanguageOptions.INCOMPATIBLE_STRUCT_HAS_NO_METHODS, rand.nextBoolean())
201+
.setBool(BuildLanguageOptions.INCOMPATIBLE_TOP_LEVEL_ASPECTS_DEPENDENCY, rand.nextBoolean())
200202
.setBool(
201203
BuildLanguageOptions.INCOMPATIBLE_VISIBILITY_PRIVATE_ATTRIBUTES_AT_DEFINITION,
202204
rand.nextBoolean())

src/test/java/com/google/devtools/build/lib/starlark/StarlarkDefinedAspectsTest.java

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,7 +3429,6 @@ public void testAspectRequiredProviders_listOfRequiredProvidersLists() throws Ex
34293429

34303430
@Test
34313431
public void testAspectRequiredByMultipleAspects_inheritsAttrAspects() throws Exception {
3432-
useConfiguration("--incompatible_top_level_aspects_dependency");
34333432
scratch.file(
34343433
"test/defs.bzl",
34353434
"prov_a = provider()",
@@ -3533,7 +3532,6 @@ public void testAspectRequiredByMultipleAspects_inheritsAttrAspects() throws Exc
35333532

35343533
@Test
35353534
public void testAspectRequiredByMultipleAspects_inheritsRequiredProviders() throws Exception {
3536-
useConfiguration("--incompatible_top_level_aspects_dependency");
35373535
scratch.file(
35383536
"test/defs.bzl",
35393537
"aspect_prov_a = provider()",
@@ -3686,7 +3684,6 @@ public void testAspectRequiredByMultipleAspects_inheritsRequiredProviders() thro
36863684

36873685
@Test
36883686
public void testAspectRequiredByMultipleAspects_withDifferentParametersValues() throws Exception {
3689-
useConfiguration("--incompatible_top_level_aspects_dependency");
36903687
scratch.file(
36913688
"test/defs.bzl",
36923689
"prov_a = provider()",
@@ -3820,7 +3817,6 @@ public void testAspectRequiredByMultipleAspects_withDifferentParametersValues()
38203817
@Test
38213818
public void testAspectRequiresAspect_requireNativeAspect() throws Exception {
38223819
exposeNativeAspectToStarlark();
3823-
useConfiguration("--incompatible_top_level_aspects_dependency");
38243820
scratch.file(
38253821
"test/defs.bzl",
38263822
"prov_a = provider()",
@@ -4664,7 +4660,6 @@ public void testTopLevelAspectOnAspect_stackOfAspects() throws Exception {
46644660
"simple_rule(",
46654661
" name = 'dep_target',",
46664662
")");
4667-
useConfiguration("--incompatible_top_level_aspects_dependency");
46684663

46694664
AnalysisResult analysisResult =
46704665
update(
@@ -4769,7 +4764,6 @@ public void testTopLevelAspectOnAspect_requiredProviderProvidedTwiceFailed() thr
47694764
"simple_rule(",
47704765
" name = 'dep_target',",
47714766
")");
4772-
useConfiguration("--incompatible_top_level_aspects_dependency");
47734767
reporter.removeHandler(failFastHandler);
47744768

47754769
// The call to `update` does not throw an exception when "--keep_going" is passed in the
@@ -4854,7 +4848,6 @@ public void testTopLevelAspectOnAspect_requiredProviderProvidedTwicePassed() thr
48544848
"simple_rule(",
48554849
" name = 'dep_target',",
48564850
")");
4857-
useConfiguration("--incompatible_top_level_aspects_dependency");
48584851

48594852
AnalysisResult analysisResult =
48604853
update(
@@ -4926,7 +4919,6 @@ public void testTopLevelAspectOnAspect_requiredProviderNotProvided() throws Exce
49264919
"simple_rule(",
49274920
" name = 'dep_target',",
49284921
")");
4929-
useConfiguration("--incompatible_top_level_aspects_dependency");
49304922

49314923
AnalysisResult analysisResult =
49324924
update(ImmutableList.of("test/defs.bzl%a2", "test/defs.bzl%a1"), "//test:main");
@@ -4999,7 +4991,6 @@ public void testTopLevelAspectOnAspect_requiredProviderProvidedAfterTheAspect()
49994991
"simple_rule(",
50004992
" name = 'dep_target',",
50014993
")");
5002-
useConfiguration("--incompatible_top_level_aspects_dependency");
50034994

50044995
AnalysisResult analysisResult =
50054996
update(ImmutableList.of("test/defs.bzl%a1", "test/defs.bzl%a2"), "//test:main");
@@ -5078,7 +5069,6 @@ public void testTopLevelAspectOnAspect_differentAttrAspects() throws Exception {
50785069
"simple_rule(",
50795070
" name = 'extra_dep_target',",
50805071
")");
5081-
useConfiguration("--incompatible_top_level_aspects_dependency");
50825072

50835073
AnalysisResult analysisResult =
50845074
update(ImmutableList.of("test/defs.bzl%a2", "test/defs.bzl%a1"), "//test:main");
@@ -5174,7 +5164,6 @@ public void testTopLevelAspectOnAspect_differentRequiredRuleProviders() throws E
51745164
"rule_with_prov_b(",
51755165
" name = 'target_with_prov_b',",
51765166
")");
5177-
useConfiguration("--incompatible_top_level_aspects_dependency");
51785167

51795168
AnalysisResult analysisResult =
51805169
update(ImmutableList.of("test/defs.bzl%a2", "test/defs.bzl%a1"), "//test:main");
@@ -5267,7 +5256,6 @@ public void testTopLevelAspectOnAspect_providerRequiredByMultipleAspects() throw
52675256
"simple_rule(",
52685257
" name = 'dep_target',",
52695258
")");
5270-
useConfiguration("--incompatible_top_level_aspects_dependency");
52715259

52725260
AnalysisResult analysisResult =
52735261
update(
@@ -5401,7 +5389,6 @@ public void testTopLevelAspectOnAspect_diamondCase() throws Exception {
54015389
"r0(",
54025390
" name = 't0',",
54035391
")");
5404-
useConfiguration("--incompatible_top_level_aspects_dependency");
54055392

54065393
AnalysisResult analysisResult =
54075394
update(
@@ -5427,8 +5414,8 @@ public void testTopLevelAspectOnAspect_diamondCase() throws Exception {
54275414
/**
54285415
* --aspects = a1, a2, a1: aspect a1 requires a2p, a2 provides a2p.
54295416
*
5430-
* <p>top level aspects list is deduplicated by default and only the first occurrence of a1 will
5431-
* be there so a1 won't get the value of a2p.
5417+
* <p>top level aspects list is deduplicated when --incompatible_top_level_aspects_dependency is
5418+
* disabled and only the first occurrence of a1 will be there so a1 won't get the value of a2p.
54325419
*/
54335420
@Test
54345421
public void testTopLevelAspectOnAspect_duplicateAspectsIgnored() throws Exception {
@@ -5481,6 +5468,7 @@ public void testTopLevelAspectOnAspect_duplicateAspectsIgnored() throws Exceptio
54815468
"simple_rule(",
54825469
" name = 'dep_target',",
54835470
")");
5471+
useConfiguration("--noincompatible_top_level_aspects_dependency");
54845472

54855473
AnalysisResult analysisResult =
54865474
update(
@@ -5551,7 +5539,6 @@ public void testTopLevelAspectOnAspect_duplicateAspectsNotAllowed() throws Excep
55515539
"simple_rule(",
55525540
" name = 'dep_target',",
55535541
")");
5554-
useConfiguration("--incompatible_top_level_aspects_dependency");
55555542
reporter.removeHandler(failFastHandler);
55565543

55575544
// The call to `update` does not throw an exception when "--keep_going" is passed in the
@@ -5630,7 +5617,6 @@ public void testTopLevelAspectOnAspect_requiredAspectProviderOnlyAvailableOnDep(
56305617
"simple_rule(",
56315618
" name = 'dep_target',",
56325619
")");
5633-
useConfiguration("--incompatible_top_level_aspects_dependency");
56345620

56355621
AnalysisResult analysisResult = update(ImmutableList.of("test/defs.bzl%a1"), "//test:main");
56365622

@@ -5697,7 +5683,6 @@ public void testTopLevelAspectOnAspect_multipleTopLevelTargets() throws Exceptio
56975683
"simple_rule(",
56985684
" name = 't2',",
56995685
")");
5700-
useConfiguration("--incompatible_top_level_aspects_dependency");
57015686

57025687
AnalysisResult analysisResult =
57035688
update(ImmutableList.of("test/defs.bzl%a2", "test/defs.bzl%a1"), "//test:t2", "//test:t1");
@@ -5783,7 +5768,6 @@ public void testTopLevelAspectOnAspect_multipleRequiredProviders() throws Except
57835768
"simple_rule(",
57845769
" name = 'dep_target',",
57855770
")");
5786-
useConfiguration("--incompatible_top_level_aspects_dependency");
57875771

57885772
AnalysisResult analysisResult =
57895773
update(
@@ -5879,7 +5863,6 @@ public void testTopLevelAspectOnAspect_multipleRequiredProviders2() throws Excep
58795863
"simple_rule(",
58805864
" name = 'dep_target',",
58815865
")");
5882-
useConfiguration("--incompatible_top_level_aspects_dependency");
58835866

58845867
AnalysisResult analysisResult =
58855868
update(
@@ -5914,9 +5897,8 @@ public void testTopLevelAspectOnAspect_multipleRequiredProviders2() throws Excep
59145897
* aspects = a1, a2; aspect a1 provides a1p provider and aspect a2 requires a1p provider. These
59155898
* top-level aspects are applied on top-level target `main` whose rule also provides a1p.
59165899
*
5917-
* <p>If the incompatible_top_level_aspects_dependency flag is used to establish the dependency
5918-
* between a1 and a2, the build will fail since a2 will receive provider a1p twice (from a1
5919-
* applied on `main` and from `main` target itself)
5900+
* <p>By default, the dependency between a1 and a2 will be established, the build will fail since
5901+
* a2 will receive provider a1p twice (from a1 applied on `main` and from `main` target itself).
59205902
*/
59215903
@Test
59225904
public void testTopLevelAspects_duplicateRuleProviderError() throws Exception {
@@ -5951,7 +5933,6 @@ public void testTopLevelAspects_duplicateRuleProviderError() throws Exception {
59515933
" implementation = _my_rule_impl,",
59525934
")");
59535935
scratch.file("test/BUILD", "load('//test:defs.bzl', 'my_rule')", "my_rule(name = 'main')");
5954-
useConfiguration("--incompatible_top_level_aspects_dependency");
59555936
reporter.removeHandler(failFastHandler);
59565937

59575938
// The call to `update` does not throw an exception when "--keep_going" is passed in the
@@ -5972,7 +5953,7 @@ public void testTopLevelAspects_duplicateRuleProviderError() throws Exception {
59725953
* aspects = a1, a2; aspect a1 provides a1p provider and aspect a2 requires a1p provider. These
59735954
* top-level aspects are applied on top-level target `main` whose rule also provides a1p.
59745955
*
5975-
* <p>If the incompatible_top_level_aspects_dependency flag is not used, aspects a1 and a2 will
5956+
* <p>If the incompatible_top_level_aspects_dependency flag is disabled, aspects a1 and a2 will
59765957
* run independently and the build will succeed. a2 will only see the value of a1p provided by
59775958
* my_rule.
59785959
*/
@@ -6009,6 +5990,7 @@ public void testTopLevelAspects_duplicateRuleProviderPassed() throws Exception {
60095990
" implementation = _my_rule_impl,",
60105991
")");
60115992
scratch.file("test/BUILD", "load('//test:defs.bzl', 'my_rule')", "my_rule(name = 'main')");
5993+
useConfiguration("--noincompatible_top_level_aspects_dependency");
60125994
reporter.removeHandler(failFastHandler);
60135995

60145996
AnalysisResult analysisResult =
@@ -6026,7 +6008,6 @@ public void testTopLevelAspects_duplicateRuleProviderPassed() throws Exception {
60266008

60276009
@Test
60286010
public void testTopLevelAspectRequiresAspect_stackOfRequiredAspects() throws Exception {
6029-
useConfiguration("--incompatible_top_level_aspects_dependency");
60306011
scratch.file(
60316012
"test/defs.bzl",
60326013
"def _impl(target, ctx):",
@@ -6048,7 +6029,6 @@ public void testTopLevelAspectRequiresAspect_stackOfRequiredAspects() throws Exc
60486029

60496030
@Test
60506031
public void testTopLevelAspectRequiresAspect_aspectRequiredByMultipleAspects() throws Exception {
6051-
useConfiguration("--incompatible_top_level_aspects_dependency");
60526032
scratch.file(
60536033
"test/defs.bzl",
60546034
"def _impl(target, ctx):",
@@ -6072,7 +6052,6 @@ public void testTopLevelAspectRequiresAspect_aspectRequiredByMultipleAspects() t
60726052

60736053
@Test
60746054
public void testTopLevelAspectRequiresAspect_aspectRequiredByMultipleAspects2() throws Exception {
6075-
useConfiguration("--incompatible_top_level_aspects_dependency");
60766055
scratch.file(
60776056
"test/defs.bzl",
60786057
"def _impl(target, ctx):",
@@ -6096,7 +6075,6 @@ public void testTopLevelAspectRequiresAspect_aspectRequiredByMultipleAspects2()
60966075

60976076
@Test
60986077
public void testTopLevelAspectRequiresAspect_requireExistingAspect_passed() throws Exception {
6099-
useConfiguration("--incompatible_top_level_aspects_dependency");
61006078
scratch.file(
61016079
"test/defs.bzl",
61026080
"def _impl(target, ctx):",
@@ -6118,7 +6096,6 @@ public void testTopLevelAspectRequiresAspect_requireExistingAspect_passed() thro
61186096

61196097
@Test
61206098
public void testTopLevelAspectRequiresAspect_requireExistingAspect_failed() throws Exception {
6121-
useConfiguration("--incompatible_top_level_aspects_dependency");
61226099
scratch.file(
61236100
"test/defs.bzl",
61246101
"def _impl(target, ctx):",
@@ -6153,7 +6130,6 @@ public void testTopLevelAspectRequiresAspect_requireExistingAspect_failed() thro
61536130
public void testTopLevelAspectRequiresAspect_requiredNativeAspect_parametersNotAllowed()
61546131
throws Exception {
61556132
exposeNativeAspectToStarlark();
6156-
useConfiguration("--incompatible_top_level_aspects_dependency");
61576133
scratch.file(
61586134
"test/defs.bzl",
61596135
"def _impl(target, ctx):",
@@ -6181,7 +6157,6 @@ public void testTopLevelAspectRequiresAspect_requiredNativeAspect_parametersNotA
61816157
@Test
61826158
public void testTopLevelAspectRequiresAspect_requiredStarlarkAspect_parametersNotAllowed()
61836159
throws Exception {
6184-
useConfiguration("--incompatible_top_level_aspects_dependency");
61856160
reporter.removeHandler(failFastHandler);
61866161
scratch.file(
61876162
"test/defs.bzl",
@@ -6211,7 +6186,6 @@ public void testTopLevelAspectRequiresAspect_requiredStarlarkAspect_parametersNo
62116186

62126187
@Test
62136188
public void testTopLevelAspectRequiresAspect_ruleAttributes() throws Exception {
6214-
useConfiguration("--incompatible_top_level_aspects_dependency");
62156189
scratch.file(
62166190
"test/defs.bzl",
62176191
"RequiredAspectProv = provider()",
@@ -6299,7 +6273,6 @@ public void testTopLevelAspectRequiresAspect_inheritPropagationAttributes() thro
62996273
// base_aspect propagates over base_dep attribute and requires first_required_aspect which
63006274
// propagates over first_dep attribute and requires second_required_aspect which propagates over
63016275
// second_dep attribute
6302-
useConfiguration("--incompatible_top_level_aspects_dependency");
63036276
scratch.file(
63046277
"test/defs.bzl",
63056278
"BaseAspectProv = provider()",
@@ -6403,7 +6376,6 @@ public void testTopLevelAspectRequiresAspect_inheritPropagationAttributes() thro
64036376
public void testTopLevelAspectRequiresAspect_inheritRequiredProviders() throws Exception {
64046377
// aspect_a requires provider Prov_A and requires aspect_b which requires
64056378
// provider Prov_B and requires aspect_c which requires provider Prov_C
6406-
useConfiguration("--incompatible_top_level_aspects_dependency");
64076379
scratch.file(
64086380
"test/defs.bzl",
64096381
"Prov_A = provider()",
@@ -6529,7 +6501,6 @@ public void testTopLevelAspectRequiresAspect_inheritRequiredProviders() throws E
65296501

65306502
@Test
65316503
public void testTopLevelAspectRequiresAspect_inspectRequiredAspectActions() throws Exception {
6532-
useConfiguration("--incompatible_top_level_aspects_dependency");
65336504
scratch.file(
65346505
"test/defs.bzl",
65356506
"BaseAspectProvider = provider()",
@@ -6586,7 +6557,6 @@ public void testTopLevelAspectRequiresAspect_inspectRequiredAspectActions() thro
65866557
@Test
65876558
public void testTopLevelAspectRequiresAspect_inspectRequiredAspectGeneratedFiles()
65886559
throws Exception {
6589-
useConfiguration("--incompatible_top_level_aspects_dependency");
65906560
scratch.file(
65916561
"test/defs.bzl",
65926562
"BaseAspectProvider = provider()",
@@ -6637,7 +6607,6 @@ public void testTopLevelAspectRequiresAspect_inspectRequiredAspectGeneratedFiles
66376607
@Test
66386608
public void testTopLevelAspectRequiresAspect_withRequiredAspectProvidersSatisfied()
66396609
throws Exception {
6640-
useConfiguration("--incompatible_top_level_aspects_dependency");
66416610
scratch.file(
66426611
"test/defs.bzl",
66436612
"prov_a = provider()",
@@ -6728,7 +6697,6 @@ public void testTopLevelAspectRequiresAspect_withRequiredAspectProvidersSatisfie
67286697
@Test
67296698
public void testTopLevelAspectRequiresAspect_withRequiredAspectProvidersNotFound()
67306699
throws Exception {
6731-
useConfiguration("--incompatible_top_level_aspects_dependency");
67326700
scratch.file(
67336701
"test/defs.bzl",
67346702
"prov_a = provider()",

0 commit comments

Comments
 (0)