Merge changes from topic "product-flags2" into main am: bae67b9994
am: 119292b4b6
Original change: https://android-review.googlesource.com/c/platform/build/+/2816075 Change-Id: I0e3066335354900b855e443b9b94c3e7450659e3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -55,6 +55,11 @@ _all_flags_schema = {
|
|||||||
},
|
},
|
||||||
"declared_in": {"type": "string"},
|
"declared_in": {"type": "string"},
|
||||||
},
|
},
|
||||||
|
"optional_keys": {
|
||||||
|
"appends": {
|
||||||
|
"type": "bool",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,17 +80,23 @@ _all_values_schema = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def flag(name, partitions, default):
|
def flag(name, partitions, default, _kwmarker = (), appends = False):
|
||||||
"""Declare a flag.
|
"""Declare a flag.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name: name of the flag
|
name: name of the flag
|
||||||
partitions: the partitions where this should be recorded.
|
partitions: the partitions where this should be recorded.
|
||||||
default: the default value of the flag.
|
default: the default value of the flag.
|
||||||
|
_kwmarker: Used to detect argument misuse.
|
||||||
|
appends: Whether new values should be append (not replace) the old.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A dictionary containing the flag declaration.
|
A dictionary containing the flag declaration.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# If specified, appends must be a keyword value.
|
||||||
|
if _kwmarker != ():
|
||||||
|
fail("Too many positional parameters")
|
||||||
if not partitions:
|
if not partitions:
|
||||||
fail("At least 1 partition is required")
|
fail("At least 1 partition is required")
|
||||||
if not name.startswith("RELEASE_"):
|
if not name.startswith("RELEASE_"):
|
||||||
@@ -105,6 +116,7 @@ def flag(name, partitions, default):
|
|||||||
"name": name,
|
"name": name,
|
||||||
"partitions": partitions,
|
"partitions": partitions,
|
||||||
"default": default,
|
"default": default,
|
||||||
|
"appends": appends,
|
||||||
}
|
}
|
||||||
|
|
||||||
def value(name, value):
|
def value(name, value):
|
||||||
@@ -153,10 +165,12 @@ def release_config(all_flags, all_values):
|
|||||||
|
|
||||||
# Validate flags
|
# Validate flags
|
||||||
flag_names = []
|
flag_names = []
|
||||||
|
flags_dict = {}
|
||||||
for flag in all_flags:
|
for flag in all_flags:
|
||||||
if flag["name"] in flag_names:
|
if flag["name"] in flag_names:
|
||||||
fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"])
|
fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"])
|
||||||
flag_names.append(flag["name"])
|
flag_names.append(flag["name"])
|
||||||
|
flags_dict[flag["name"]] = flag
|
||||||
|
|
||||||
# Record which flags go on which partition
|
# Record which flags go on which partition
|
||||||
partitions = {}
|
partitions = {}
|
||||||
@@ -170,13 +184,21 @@ def release_config(all_flags, all_values):
|
|||||||
else:
|
else:
|
||||||
partitions.setdefault(partition, []).append(flag["name"])
|
partitions.setdefault(partition, []).append(flag["name"])
|
||||||
|
|
||||||
# Validate values
|
# Generate final values.
|
||||||
# TODO(joeo): Disallow duplicate values after we've split AOSP and vendor flags.
|
# Only declared flags may have a value.
|
||||||
values = {}
|
values = {}
|
||||||
for value in all_values:
|
for value in all_values:
|
||||||
if value["name"] not in flag_names:
|
name = value["name"]
|
||||||
fail(value["set_in"] + ": Value set for undeclared build flag: " + value["name"])
|
if name not in flag_names:
|
||||||
values[value["name"]] = value
|
fail(value["set_in"] + ": Value set for undeclared build flag: " + name)
|
||||||
|
if flags_dict[name]["appends"]:
|
||||||
|
if name in values:
|
||||||
|
values[name]["value"] += " " + value["value"]
|
||||||
|
values[name]["set_in"] += " " + value["set_in"]
|
||||||
|
else:
|
||||||
|
values[name] = value
|
||||||
|
else:
|
||||||
|
values[name] = value
|
||||||
|
|
||||||
# Collect values
|
# Collect values
|
||||||
result = {
|
result = {
|
||||||
|
Reference in New Issue
Block a user