From f876fce56c6a4694c120a4121d2bf24e75b9e878 Mon Sep 17 00:00:00 2001 From: ccalvarin Date: Tue, 27 Jun 2017 19:12:36 +0200 Subject: Update the --incompatible_ flag requirements to use the metadata tag. Leave the category for now as the generated docs still do not use the new categorization. PiperOrigin-RevId: 160290297 --- .../build/lib/runtime/AllIncompatibleChangesExpansion.java | 6 ++++++ .../devtools/build/lib/syntax/SkylarkSemanticsOptions.java | 11 +++++++++++ src/main/protobuf/option_filters.proto | 6 ++++-- 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansion.java b/src/main/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansion.java index 9e26da0633..3f7a193cd3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansion.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansion.java @@ -21,6 +21,7 @@ import com.google.devtools.common.options.IsolatedOptionsData; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionsBase; import com.google.devtools.common.options.OptionsParser; +import com.google.devtools.common.options.proto.OptionFilters.OptionMetadataTag; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Map; @@ -132,6 +133,11 @@ public class AllIncompatibleChangesExpansion implements ExpansionFunction { if (!annotation.category().equals(INCOMPATIBLE_CATEGORY)) { throw new IllegalArgumentException(prefix + "must have category \"incompatible changes\""); } + if (!ImmutableList.copyOf(annotation.metadataTags()) + .contains(OptionMetadataTag.INCOMPATIBLE_CHANGE)) { + throw new IllegalArgumentException( + prefix + "must have metadata tag \"OptionMetadataTag.INCOMPATIBLE_CHANGE\""); + } if (!IsolatedOptionsData.isExpansionOption(annotation)) { if (!field.getType().equals(Boolean.TYPE)) { throw new IllegalArgumentException( diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java index 8c69a561b6..1790411655 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java @@ -20,6 +20,7 @@ import com.google.devtools.common.options.OptionsBase; import com.google.devtools.common.options.OptionsParser.OptionUsageRestrictions; import com.google.devtools.common.options.UsesOnlyCoreTypes; import com.google.devtools.common.options.proto.OptionFilters.OptionEffectTag; +import com.google.devtools.common.options.proto.OptionFilters.OptionMetadataTag; import java.io.Serializable; /** @@ -53,6 +54,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, disables the deprecated `set` constructor for depsets." ) public boolean incompatibleDisallowSetConstructor; @@ -63,6 +65,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, disables the keyword-only argument syntax in function definition." ) public boolean incompatibleDisallowKeywordOnlyArgs; @@ -73,6 +76,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, `+=` on lists works like the `extend` method mutating the original " + "list. Otherwise it copies the original list without mutating it." @@ -85,6 +89,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, the `+` becomes disabled for dicts." ) public boolean incompatibleDisallowDictPlus; @@ -95,6 +100,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, all `load` must be called at the top of .bzl files, before any other " + "statement." @@ -107,6 +113,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, the first argument of 'load' statements is a label (not a path). " + "It must start with '//' or ':'." @@ -119,6 +126,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, 'if' statements are forbidden at the top-level " + "(outside a function definition)" @@ -131,6 +139,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, loop variables in a comprehension shadow any existing variable by " + "the same name. If the existing variable was declared in the same scope that " @@ -145,6 +154,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, depset type is not iterable. For loops and functions expecting an " + "iterable will reject depset objects. Use the `.to_list` method to explicitly " @@ -158,6 +168,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, help = "If set to true, the dictionary literal syntax doesn't allow duplicated keys." ) public boolean incompatibleDictLiteralHasNoDuplicates; diff --git a/src/main/protobuf/option_filters.proto b/src/main/protobuf/option_filters.proto index 059d414c5c..da614796b6 100644 --- a/src/main/protobuf/option_filters.proto +++ b/src/main/protobuf/option_filters.proto @@ -125,9 +125,11 @@ enum OptionMetadataTag { // labeled experimental. EXPERIMENTAL = 0; - // This option triggers a breaking change that is off by default, but will be - // enabled in the next major Bazel version. Use this option to test your + // This option triggers a backwards-incompatible change. It will be off by + // default when the option is first introduced, and later switched on by + // default on a major Blaze release. Use this option to test your // migration readiness or get early access to the feature. + // The option may be deprecated some time after the feature's release. INCOMPATIBLE_CHANGE = 1; // This flag is deprecated. It might either no longer have any effect, or -- cgit v1.2.3