intel/genxml: Add GenXml.flatten_xml() method
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 15 Aug 2023 18:46:42 +0000 (11:46 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Thu, 14 Sep 2023 18:05:16 +0000 (11:05 -0700)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20593>

src/intel/genxml/intel_genxml.py

index be758e4..b8bf9da 100755 (executable)
@@ -347,6 +347,22 @@ class GenXml(object):
         """
         self.process_imported(merge=True)
 
+    def flatten_imported(self):
+        """Flattens the genxml to not include any imports
+
+        Essentially this helper will put the `self.et` into a state
+        that includes all imported items directly, and does not
+        contain any <import> tags. This is used by the
+        genxml_import.py with the --flatten switch to "undo" any
+        genxml imports.
+
+        """
+        self.merge_imported()
+        root = self.et.getroot()
+        imports = root.findall('import')
+        for i in imports:
+            root.remove(i)
+
     def add_xml_imports(self):
         """Adds imports to the genxml file.