annotations: do not drop undefined configs in derivatives
authorAndrea Righi <andrea.righi@canonical.com>
Tue, 31 Jan 2023 13:47:15 +0000 (14:47 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 31 Jan 2023 13:54:51 +0000 (14:54 +0100)
Prevent dropping configs that are undefined across all the supported
architectures in annotations that have includes, because we may want to
use them to override configs imported from other annotations.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
kconfig/annotations.py

index 84dd4d26e6af6841c820293192f980aa9222f78e..3eb2c078c097b48ad6851e43beb76fea99662593 100644 (file)
@@ -214,9 +214,11 @@ class Annotation(Config):
                 if flavour not in list(set(self.arch + self.flavour)):
                     del self.config[conf]['policy'][flavour]
             # Remove configs that are all undefined across all arches/flavours
-            if 'policy' in self.config[conf]:
-                if list(set(self.config[conf]['policy'].values())) == ['-']:
-                    self.config[conf]['policy'] = {}
+            # (unless we have includes)
+            if not self.include:
+                if 'policy' in self.config[conf]:
+                    if list(set(self.config[conf]['policy'].values())) == ['-']:
+                        self.config[conf]['policy'] = {}
             # Drop empty rules
             if not self.config[conf]['policy']:
                 del self.config[conf]
@@ -238,15 +240,17 @@ class Annotation(Config):
                         self.config[conf]['policy'][arch] = value
         # After the first round of compaction we may end up having configs that
         # are undefined across all arches, so do another round of compaction to
-        # drop these settings that are not needed anymore.
-        for conf in self.config.copy():
-            # Remove configs that are all undefined across all arches/flavours
-            if 'policy' in self.config[conf]:
-                if list(set(self.config[conf]['policy'].values())) == ['-']:
-                    self.config[conf]['policy'] = {}
-            # Drop empty rules
-            if not self.config[conf]['policy']:
-                del self.config[conf]
+        # drop these settings that are not needed anymore
+        # (unless we have includes).
+        if not self.include:
+            for conf in self.config.copy():
+                # Remove configs that are all undefined across all arches/flavours
+                if 'policy' in self.config[conf]:
+                    if list(set(self.config[conf]['policy'].values())) == ['-']:
+                        self.config[conf]['policy'] = {}
+                # Drop empty rules
+                if not self.config[conf]['policy']:
+                    del self.config[conf]
 
     def save(self, fname: str):
         """ Save annotations data to the annotation file """