From: Andrea Righi Date: Tue, 12 Dec 2023 16:02:12 +0000 (+0100) Subject: annotations: properly update arch overrides X-Git-Tag: v0.2~3 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=1d674c2619b3664c23cf6e5a2e718e9ff58ea831;p=annotations.git annotations: properly update arch overrides New rules that are overriding a whole arch should also override all the correspondent flavours for that particular arch. Signed-off-by: Andrea Righi --- diff --git a/kconfig/annotations.py b/kconfig/annotations.py index 98121d9..69cf501 100644 --- a/kconfig/annotations.py +++ b/kconfig/annotations.py @@ -110,13 +110,22 @@ class Annotation(Config): m = re.match(r".* policy<(.*?)>", line) if m: match = True - try: - entry["policy"] |= literal_eval(m.group(1)) - except TypeError: - entry["policy"] = { - **entry["policy"], - **literal_eval(m.group(1)), - } + # Update the previous entry considering potential overrides: + # - if the new entry is adding a rule for a new + # arch/flavour, simply add that + # - if the new entry is overriding a previous + # arch-flavour item, then overwrite that item + # - if the new entry is overriding a whole arch, then + # remove all the previous flavour rules of that arch + new_entry = literal_eval(m.group(1)) + for key in new_entry: + if key in self.arch: + for flavour_key in list(entry["policy"].keys()): + if flavour_key.startswith(key): + del entry["policy"][flavour_key] + entry["policy"][key] = new_entry[key] + else: + entry["policy"][key] = new_entry[key] m = re.match(r".* note<(.*?)>", line) if m: