Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d295d07d authored by Cole Faust's avatar Cole Faust Committed by Automerger Merge Worker
Browse files

Merge changes I1cfdc6f4,I22c91c79 into main am: 420f6978 am: 686b624b

parents 6be8a65c 686b624b
Loading
Loading
Loading
Loading
+48 −2
Original line number Original line Diff line number Diff line
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.


load("//build/bazel/utils:schema_validation.bzl", "validate")

# Partitions that get build system flag summaries
# Partitions that get build system flag summaries
_flag_partitions = [
_flag_partitions = [
    "product",
    "product",
@@ -28,6 +30,48 @@ VENDOR = ["vendor"]


_valid_types = ["NoneType", "bool", "list", "string", "int"]
_valid_types = ["NoneType", "bool", "list", "string", "int"]


_all_flags_schema = {
    "type": "list",
    "of": {
        "type": "dict",
        "required_keys": {
            "name": {"type": "string"},
            "partitions": {
                "type": "list",
                "of": {
                    "type": "string",
                    "choices": _flag_partitions + ["all"],
                },
                "unique": True,
            },
            "default": {
                "or": [
                    {"type": t}
                    for t in _valid_types
                ],
            },
            "declared_in": {"type": "string"},
        },
    },
}

_all_values_schema = {
    "type": "list",
    "of": {
        "type": "dict",
        "required_keys": {
            "name": {"type": "string"},
            "value": {
                "or": [
                    {"type": t}
                    for t in _valid_types
                ],
            },
            "set_in": {"type": "string"},
        },
    },
}

def flag(name, partitions, default):
def flag(name, partitions, default):
    "Declare a flag."
    "Declare a flag."
    if not partitions:
    if not partitions:
@@ -69,6 +113,8 @@ def _format_value(val):


def release_config(all_flags, all_values):
def release_config(all_flags, all_values):
    "Return the make variables that should be set for this release config."
    "Return the make variables that should be set for this release config."
    validate(all_flags, _all_flags_schema)
    validate(all_values, _all_values_schema)


    # Validate flags
    # Validate flags
    flag_names = []
    flag_names = []
@@ -82,6 +128,8 @@ def release_config(all_flags, all_values):
    for flag in all_flags:
    for flag in all_flags:
        for partition in flag["partitions"]:
        for partition in flag["partitions"]:
            if partition == "all":
            if partition == "all":
                if len(flag["partitions"]) > 1:
                    fail("\"all\" can't be combined with other partitions: " + str(flag["partitions"]))
                for partition in _flag_partitions:
                for partition in _flag_partitions:
                    partitions.setdefault(partition, []).append(flag["name"])
                    partitions.setdefault(partition, []).append(flag["name"])
            else:
            else:
@@ -105,8 +153,6 @@ def release_config(all_flags, all_values):
        if flag["name"] in values:
        if flag["name"] in values:
            val = values[flag["name"]]["value"]
            val = values[flag["name"]]["value"]
            set_in = values[flag["name"]]["set_in"]
            set_in = values[flag["name"]]["set_in"]
            if type(val) not in _valid_types:
                fail("Invalid type of value for flag \"" + flag["name"] + "\" (" + type(val) + ")")
        else:
        else:
            val = flag["default"]
            val = flag["default"]
            set_in = flag["declared_in"]
            set_in = flag["declared_in"]