From 74b7dd55325d6588f1a8827dd3bdb30deea073a0 Mon Sep 17 00:00:00 2001 From: arostovtsev Date: Tue, 8 Feb 2022 09:42:54 -0800 Subject: [PATCH] Flip --incompatible_existing_rules_immutable_view flag to true Fixes https://github.com/bazelbuild/bazel/issues/13907 RELNOTES[INC]: The --incompatible_existing_rules_immutable_view flag has been flipped to true. See https://github.com/bazelbuild/bazel/issues/13907 for migration notes. PiperOrigin-RevId: 427215851 --- .../semantics/BuildLanguageOptions.java | 4 +- .../StarlarkNativeModuleApi.java | 43 ++++++++++--------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java index 732ecd72b14f61..9fe676d398aef6 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java +++ b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java @@ -147,7 +147,7 @@ public final class BuildLanguageOptions extends OptionsBase { @Option( name = "incompatible_existing_rules_immutable_view", - defaultValue = "false", + defaultValue = "true", documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS, effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS, OptionEffectTag.LOADING_AND_ANALYSIS}, metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, @@ -621,7 +621,7 @@ public StarlarkSemantics toStarlarkSemantics() { public static final String EXPERIMENTAL_ENABLE_ANDROID_MIGRATION_APIS = "-experimental_enable_android_migration_apis"; public static final String INCOMPATIBLE_EXISTING_RULES_IMMUTABLE_VIEW = - "-incompatible_existing_rules_immutable_view"; + "+incompatible_existing_rules_immutable_view"; public static final String EXPERIMENTAL_GOOGLE_LEGACY_API = "-experimental_google_legacy_api"; public static final String EXPERIMENTAL_NINJA_ACTIONS = "-experimental_ninja_actions"; public static final String EXPERIMENTAL_PLATFORMS_API = "-experimental_platforms_api"; diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java index efdb8e57a86e0a..7decf348785f5a 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java @@ -92,14 +92,15 @@ Sequence glob( @StarlarkMethod( name = "existing_rule", doc = - "Returns a new mutable dict that describes the attributes of a rule instantiated in this" - + " thread's package, or None if no rule instance of that name" - + " exists." // - + "

If the --incompatible_existing_rules_immutable_view flag is set," - + " instead returns an immutable dict-like object (i.e. supporting dict-like" - + " iteration, len(x), name in x, x[name]," - + " x.get(name), x.items(), x.keys(), and" - + " x.values()) with the same content." // + "Returns an immutable dict-like object that describes the attributes of a rule" + + " instantiated in this thread's package, or None if no rule instance" + + " of that name exists." // + + "

Here, an immutable dict-like object means a deeply immutable object" + + " x supporting dict-like iteration, len(x), name in" + + " x, x[name], x.get(name), x.items()," + + " x.keys(), and x.values()." // + + "

If the --noincompatible_existing_rules_immutable_view flag is set," + + " instead returns a new mutable dict with the same content." // + "

The result contains an entry for each attribute, with the exception of private" + " ones (whose names do not start with a letter) and a few unrepresentable legacy" + " attribute types. In addition, the dict contains entries for the rule instance's" @@ -129,18 +130,20 @@ Sequence glob( @StarlarkMethod( name = "existing_rules", doc = - "Returns a new mutable dict describing the rules so far instantiated in this thread's" - + " package. Each dict entry maps the name of the rule instance to the result that" - + " would be returned by existing_rule(name)." // - + "

If the --incompatible_existing_rules_immutable_view flag is set," - + " instead returns an immutable dict-like object (i.e. supporting dict-like" - + " iteration, len(x), name in x, x[name]," - + " x.get(name), x.items(), x.keys(), and" - + " x.values()) with the same content." // - + "

Note: If possible, avoid using this function. It makes BUILD files brittle" - + " and order-dependent. Furthermore, unless the" - + " --incompatible_existing_rules_immutable_view flag is set, this" - + " function may be very expensive, especially if called within a loop.", + "Returns an immutable dict-like object describing the rules so far instantiated in this" + + " thread's package. Each entry of the dict-like object maps the name of the rule" + + " instance to the result that would be returned by" + + " existing_rule(name)." // + + "

Here, an immutable dict-like object means a deeply immutable object" + + " x supporting dict-like iteration, len(x), name in" + + " x, x[name], x.get(name), x.items()," + + " x.keys(), and x.values()." // + + "

If the --noincompatible_existing_rules_immutable_view flag is set," + + " instead returns a new mutable dict with the same content." // + + "

Note: If possible, avoid using this function. It makes BUILD files brittle" + + " and order-dependent. Furthermore, if the" + + " --noincompatible_existing_rules_immutable_view flag is set," + + " this function may be very expensive, especially if called within a loop.", useStarlarkThread = true) Object existingRules(StarlarkThread thread) throws EvalException;