Allow duplicate release config maps and build flag declarations

Only include a release_config_map.mk file the first time it appears in
the list.

If the flag declaration is identical to one already declared, do not
raise an error.

This eases the process of migrating where flags are declared.

Bug: b/328781415
Bug: b/328495189
Test: manual, TH
Change-Id: I18316e769438f62071723771762d6e89be98b813
Merged-In: I18316e769438f62071723771762d6e89be98b813
This commit is contained in:
LaMont Jones
2024-03-14 10:48:55 -07:00
parent d826a2355d
commit 451abd6a06
2 changed files with 28 additions and 4 deletions

View File

@@ -145,6 +145,21 @@ def _format_value(val):
else:
return val
def equal_flag_declaration(flag, other):
"""Return true if the flag declarations are equal.
Args:
flag: This flag declaration.
other: Another flag declaration.
Returns:
Whether the declarations are the same.
"""
for key in "name", "partitions", "default", "appends":
if flag[key] != other[key]:
return False
return True
def release_config(all_flags, all_values):
"""Return the make variables that should be set for this release config.
@@ -163,7 +178,11 @@ def release_config(all_flags, all_values):
flags_dict = {}
for flag in all_flags:
if flag["name"] in flag_names:
fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"])
if equal_flag_declaration(flag, flags_dict[flag["name"]]):
continue
else:
fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"] +
" (declared first in " + flags_dict[flag["name"]]["declared_in"] + ")")
flag_names.append(flag["name"])
flags_dict[flag["name"]] = flag