From 8ea115e390899d404087c9719c2a17ee403d2f6c Mon Sep 17 00:00:00 2001 From: aiuto Date: Fri, 31 Jan 2020 13:19:58 -0800 Subject: [PATCH] Create an incompatibleApplicableLicenses flag. RELNOTES: Create the incompatibleApplicableLicenses flag. We plan to flip this from false to true in Bazel 4.x. Implementation to follow. https://github.com/bazelbuild/bazel/issues/10687 https://github.com/bazelbuild/bazel/issues/7444 PiperOrigin-RevId: 292603753 --- .../lib/packages/StarlarkSemanticsOptions.java | 14 ++++++++++++++ .../build/lib/syntax/StarlarkSemantics.java | 6 ++++++ .../packages/SkylarkSemanticsConsistencyTest.java | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java index ec7e8b88d054f0..f17274c4538ee8 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java +++ b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java @@ -418,6 +418,19 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl help = "If set to true, disables the function `attr.license`.") public boolean incompatibleNoAttrLicense; + @Option( + name = "incompatible_applicable_licenses", + defaultValue = "false", + // TODO(aiuto): change to OptionDocumentationCategory.STARLARK_SEMANTICS, + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, + help = "If set to true, enables the function `attr.applicable_licenses`.") + public boolean incompatibleApplicableLicenses; + @Option( name = "incompatible_no_implicit_file_export", defaultValue = "false", @@ -620,6 +633,7 @@ public StarlarkSemantics toSkylarkSemantics() { .experimentalStarlarkUnusedInputsList(experimentalStarlarkUnusedInputsList) .experimentalCcSharedLibrary(experimentalCcSharedLibrary) .experimentalRepoRemoteExec(experimentalRepoRemoteExec) + .incompatibleApplicableLicenses(incompatibleApplicableLicenses) .incompatibleBzlDisallowLoadAfterStatement(incompatibleBzlDisallowLoadAfterStatement) .incompatibleDepsetUnion(incompatibleDepsetUnion) .incompatibleDisableTargetProviderFields(incompatibleDisableTargetProviderFields) diff --git a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java index 87dc97f70c6bbb..40ae57b501fdb7 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java @@ -62,6 +62,7 @@ public enum FlagIdentifier { StarlarkSemantics::experimentalStarlarkUnusedInputsList), EXPERIMENTAL_CC_SHARED_LIBRARY(StarlarkSemantics::experimentalCcSharedLibrary), EXPERIMENTAL_REPO_REMOTE_EXEC(StarlarkSemantics::experimentalRepoRemoteExec), + INCOMPATIBLE_APPLICABLE_LICENSES(StarlarkSemantics::incompatibleApplicableLicenses), INCOMPATIBLE_DISABLE_DEPSET_INPUTS(StarlarkSemantics::incompatibleDisableDepsetItems), INCOMPATIBLE_NO_OUTPUT_ATTR_DEFAULT(StarlarkSemantics::incompatibleNoOutputAttrDefault), INCOMPATIBLE_NO_RULE_OUTPUTS_PARAM(StarlarkSemantics::incompatibleNoRuleOutputsParam), @@ -162,6 +163,8 @@ public boolean flagValue(FlagIdentifier flagIdentifier) { public abstract boolean incompatibleAlwaysCheckDepsetElements(); + public abstract boolean incompatibleApplicableLicenses(); + public abstract boolean incompatibleBzlDisallowLoadAfterStatement(); public abstract boolean incompatibleDepsetUnion(); @@ -261,6 +264,7 @@ public static Builder builderWithDefaults() { .experimentalCcSharedLibrary(false) .experimentalRepoRemoteExec(false) .incompatibleAlwaysCheckDepsetElements(false) + .incompatibleApplicableLicenses(false) .incompatibleBzlDisallowLoadAfterStatement(true) .incompatibleDepsetUnion(true) .incompatibleDisableTargetProviderFields(false) @@ -324,6 +328,8 @@ public abstract static class Builder { public abstract Builder incompatibleAlwaysCheckDepsetElements(boolean value); + public abstract Builder incompatibleApplicableLicenses(boolean value); + public abstract Builder incompatibleBzlDisallowLoadAfterStatement(boolean value); public abstract Builder incompatibleDepsetUnion(boolean value); diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java index 1302bdab3b4c90..af485debe6a77a 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java @@ -138,6 +138,7 @@ private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws E "--experimental_cc_shared_library=" + rand.nextBoolean(), "--experimental_repo_remote_exec=" + rand.nextBoolean(), "--incompatible_always_check_depset_elements=" + rand.nextBoolean(), + "--incompatible_applicable_licenses=" + rand.nextBoolean(), "--incompatible_bzl_disallow_load_after_statement=" + rand.nextBoolean(), "--incompatible_depset_for_libraries_to_link_getter=" + rand.nextBoolean(), "--incompatible_depset_union=" + rand.nextBoolean(), @@ -188,6 +189,7 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) { .experimentalCcSharedLibrary(rand.nextBoolean()) .experimentalRepoRemoteExec(rand.nextBoolean()) .incompatibleAlwaysCheckDepsetElements(rand.nextBoolean()) + .incompatibleApplicableLicenses(rand.nextBoolean()) .incompatibleBzlDisallowLoadAfterStatement(rand.nextBoolean()) .incompatibleDepsetForLibrariesToLinkGetter(rand.nextBoolean()) .incompatibleDepsetUnion(rand.nextBoolean())