Skip to content

Commit

Permalink
Remove --incompatible_disallow_data_transition flag
Browse files Browse the repository at this point in the history
    bazelbuild/bazel#6153

    RELNOTES: None.
    PiperOrigin-RevId: 240442015
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent 760ffa7 commit c868cb4
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import com.google.devtools.build.lib.analysis.config.HostTransition;
import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition;
import com.google.devtools.build.lib.analysis.config.transitions.SplitTransition;
import com.google.devtools.build.lib.analysis.config.transitions.TransitionFactory;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.packages.Attribute;
import com.google.devtools.build.lib.packages.Attribute.AllowedValueSet;
import com.google.devtools.build.lib.packages.Attribute.ImmutableAttributeFactory;
import com.google.devtools.build.lib.packages.Attribute.SkylarkComputedDefaultTemplate;
import com.google.devtools.build.lib.packages.Attribute.SplitTransitionProvider;
import com.google.devtools.build.lib.packages.AttributeValueSource;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.Provider;
Expand Down Expand Up @@ -252,7 +252,7 @@ && containsNonNoneKey(arguments, ALLOW_SINGLE_FILE_ARG)) {
Object trans = arguments.get(CONFIGURATION_ARG);
boolean isSplit =
trans instanceof SplitTransition
|| trans instanceof TransitionFactory
|| trans instanceof SplitTransitionProvider
|| trans instanceof StarlarkDefinedConfigTransition;
if (isSplit && defaultValue instanceof SkylarkLateBoundDefault) {
throw new EvalException(
Expand All @@ -263,8 +263,8 @@ && containsNonNoneKey(arguments, ALLOW_SINGLE_FILE_ARG)) {
builder.cfg(HostTransition.INSTANCE);
} else if (trans instanceof SplitTransition) {
builder.cfg((SplitTransition) trans);
} else if (trans instanceof TransitionFactory) {
builder.cfg((TransitionFactory) trans);
} else if (trans instanceof SplitTransitionProvider) {
builder.cfg((SplitTransitionProvider) trans);
} else if (trans instanceof StarlarkDefinedConfigTransition) {
StarlarkDefinedConfigTransition starlarkDefinedTransition =
(StarlarkDefinedConfigTransition) trans;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl

@Option(
name = "incompatible_no_attr_license",
defaultValue = "true",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
Expand Down Expand Up @@ -477,6 +477,20 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
+ "will be available")
public boolean incompatibleRemoveNativeMavenJar;

@Option(
name = "incompatible_strict_argument_ordering",
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, the order of arguments is stricter in function calls, see "
+ "https://github.com/bazelbuild/bazel/issues/6611")
public boolean incompatibleStricArgumentOrdering;

/** Used in an integration test to confirm that flags are visible to the interpreter. */
@Option(
name = "internal_skylark_flag_test_canary",
Expand Down Expand Up @@ -552,6 +566,7 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleNoTransitiveLoads(incompatibleNoTransitiveLoads)
.incompatibleRemapMainRepo(incompatibleRemapMainRepo)
.incompatibleRemoveNativeMavenJar(incompatibleRemoveNativeMavenJar)
.incompatibleStricArgumentOrdering(incompatibleStricArgumentOrdering)
.incompatibleUseToolchainProvidersInJavaCommon(
incompatibleUseToolchainProvidersInJavaCommon)
.internalSkylarkFlagTestCanary(internalSkylarkFlagTestCanary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean incompatibleRemoveNativeMavenJar();

public abstract boolean incompatibleStricArgumentOrdering();

public abstract boolean internalSkylarkFlagTestCanary();

public abstract boolean incompatibleUseToolchainProvidersInJavaCommon();
Expand Down Expand Up @@ -220,13 +222,14 @@ public static Builder builderWithDefaults() {
.incompatibleDisallowStructProviderSyntax(false)
.incompatibleExpandDirectories(true)
.incompatibleNewActionsApi(false)
.incompatibleNoAttrLicense(true)
.incompatibleNoAttrLicense(false)
.incompatibleNoOutputAttrDefault(false)
.incompatibleNoSupportToolsInActionInputs(false)
.incompatibleNoTargetOutputGroup(false)
.incompatibleNoTransitiveLoads(true)
.incompatibleRemapMainRepo(false)
.incompatibleRemoveNativeMavenJar(false)
.incompatibleStricArgumentOrdering(true)
.internalSkylarkFlagTestCanary(false)
.incompatibleDoNotSplitLinkingCmdline(false)
.build();
Expand Down Expand Up @@ -298,6 +301,8 @@ public abstract static class Builder {

public abstract Builder incompatibleRemoveNativeMavenJar(boolean value);

public abstract Builder incompatibleStricArgumentOrdering(boolean value);

public abstract Builder incompatibleUseToolchainProvidersInJavaCommon(boolean value);

public abstract Builder internalSkylarkFlagTestCanary(boolean value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws E
"--incompatible_no_transitive_loads=" + rand.nextBoolean(),
"--incompatible_remap_main_repo=" + rand.nextBoolean(),
"--incompatible_remove_native_maven_jar=" + rand.nextBoolean(),
"--incompatible_string_join_requires_strings=" + rand.nextBoolean(),
"--incompatible_strict_argument_ordering=" + rand.nextBoolean(),
"--incompatible_use_toolchain_providers_in_java_common=" + rand.nextBoolean(),
"--internal_skylark_flag_test_canary=" + rand.nextBoolean(),
"--incompatible_do_not_split_linking_cmdline=" + rand.nextBoolean());
Expand Down Expand Up @@ -201,7 +201,7 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.incompatibleNoTransitiveLoads(rand.nextBoolean())
.incompatibleRemapMainRepo(rand.nextBoolean())
.incompatibleRemoveNativeMavenJar(rand.nextBoolean())
.incompatibleStringJoinRequiresStrings(rand.nextBoolean())
.incompatibleStricArgumentOrdering(rand.nextBoolean())
.incompatibleUseToolchainProvidersInJavaCommon(rand.nextBoolean())
.internalSkylarkFlagTestCanary(rand.nextBoolean())
.incompatibleDoNotSplitLinkingCmdline(rand.nextBoolean())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ public void testAttrDoc() throws Exception {
buildAttribute("a4", "attr.label(doc='foo')");
buildAttribute("a5", "attr.label_keyed_string_dict(doc='foo')");
buildAttribute("a6", "attr.label_list(doc='foo')");
buildAttribute("a7", "attr.license(doc='foo')");
buildAttribute("a8", "attr.output(doc='foo')");
buildAttribute("a9", "attr.output_list(doc='foo')");
buildAttribute("a10", "attr.string(doc='foo')");
Expand All @@ -636,6 +637,14 @@ public void testAttrDoc() throws Exception {

@Test
public void testNoAttrLicense() throws Exception {
ev =
createEvaluationTestCase(
StarlarkSemantics.DEFAULT_SEMANTICS
.toBuilder()
.incompatibleNoAttrLicense(true)
.build());
ev.initialize();

EvalException expected = assertThrows(EvalException.class, () -> eval("attr.license()"));
assertThat(expected)
.hasMessageThat()
Expand Down Expand Up @@ -1016,6 +1025,29 @@ public void testLabelGetRelativeSyntaxError() throws Exception {
"Label('//foo:bar').relative('bad//syntax')");
}

@Test
public void testLicenseAttributesNonconfigurable() throws Exception {
scratch.file("test/BUILD");
scratch.file("test/rule.bzl",
"def _impl(ctx):",
" return",
"some_rule = rule(",
" implementation = _impl,",
" attrs = {",
" 'licenses': attr.license()",
" }",
")");
scratch.file("third_party/foo/BUILD",
"load('//test:rule.bzl', 'some_rule')",
"some_rule(",
" name='r',",
" licenses = ['unencumbered']",
")");
invalidatePackages();
// Should succeed without a "licenses attribute is potentially configurable" loading error:
createRuleContext("//third_party/foo:r");
}

@Test
public void testStructCreation() throws Exception {
// TODO(fwe): cannot be handled by current testing suite
Expand Down

0 comments on commit c868cb4

Please sign in to comment.