Skip to content

Commit

Permalink
Flip --incompatible_existing_rules_immutable_view flag to true
Browse files Browse the repository at this point in the history
Fixes #13907

RELNOTES[INC]: The --incompatible_existing_rules_immutable_view flag has been
flipped to true. See #13907 for
migration notes.

PiperOrigin-RevId: 427215851
  • Loading branch information
tetromino authored and copybara-github committed Feb 8, 2022
1 parent f34ab2f commit 74b7dd5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>None</code> if no rule instance of that name"
+ " exists." //
+ "<p>If the <code>--incompatible_existing_rules_immutable_view</code> flag is set,"
+ " instead returns an immutable dict-like object (i.e. supporting dict-like"
+ " iteration, <code>len(x)</code>, <code>name in x</code>, <code>x[name]</code>,"
+ " <code>x.get(name)</code>, <code>x.items()</code>, <code>x.keys()</code>, and"
+ " <code>x.values()</code>) with the same content." //
"Returns an immutable dict-like object that describes the attributes of a rule"
+ " instantiated in this thread's package, or <code>None</code> if no rule instance"
+ " of that name exists." //
+ "<p>Here, an <em>immutable dict-like object</em> means a deeply immutable object"
+ " <code>x</code> supporting dict-like iteration, <code>len(x)</code>, <code>name in"
+ " x</code>, <code>x[name]</code>, <code>x.get(name)</code>, <code>x.items()</code>,"
+ " <code>x.keys()</code>, and <code>x.values()</code>." //
+ "<p>If the <code>--noincompatible_existing_rules_immutable_view</code> flag is set,"
+ " instead returns a new mutable dict with the same content." //
+ "<p>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"
Expand Down Expand Up @@ -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 <code>existing_rule(name)</code>." //
+ "<p>If the <code>--incompatible_existing_rules_immutable_view</code> flag is set,"
+ " instead returns an immutable dict-like object (i.e. supporting dict-like"
+ " iteration, <code>len(x)</code>, <code>name in x</code>, <code>x[name]</code>,"
+ " <code>x.get(name)</code>, <code>x.items()</code>, <code>x.keys()</code>, and"
+ " <code>x.values()</code>) with the same content." //
+ "<p><i>Note: If possible, avoid using this function. It makes BUILD files brittle"
+ " and order-dependent. Furthermore, unless the"
+ " <code>--incompatible_existing_rules_immutable_view</code> flag is set, this"
+ " function may be very expensive, especially if called within a loop.</i>",
"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"
+ " <code>existing_rule(name)</code>." //
+ "<p>Here, an <em>immutable dict-like object</em> means a deeply immutable object"
+ " <code>x</code> supporting dict-like iteration, <code>len(x)</code>, <code>name in"
+ " x</code>, <code>x[name]</code>, <code>x.get(name)</code>, <code>x.items()</code>,"
+ " <code>x.keys()</code>, and <code>x.values()</code>." //
+ "<p>If the <code>--noincompatible_existing_rules_immutable_view</code> flag is set,"
+ " instead returns a new mutable dict with the same content." //
+ "<p><em>Note: If possible, avoid using this function. It makes BUILD files brittle"
+ " and order-dependent. Furthermore, if the"
+ " </em><code>--noincompatible_existing_rules_immutable_view</code><em> flag is set,"
+ " this function may be very expensive, especially if called within a loop.</em>",
useStarlarkThread = true)
Object existingRules(StarlarkThread thread) throws EvalException;

Expand Down

0 comments on commit 74b7dd5

Please sign in to comment.