driconf: add support for multiple input files in the static script
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 30 Nov 2022 09:36:40 +0000 (10:36 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 1 Dec 2022 16:55:31 +0000 (16:55 +0000)
RADV has its own drirc file and this is required to fix the static
driconf path.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20077>

src/util/driconf_static.py
src/util/meson.build

index 3e62336..ed4cf9e 100644 (file)
@@ -22,8 +22,8 @@
 
 from mako.template import Template
 from xml.etree import ElementTree
+import argparse
 import os
-import sys
 
 def dbg(str):
     if False:
@@ -80,12 +80,13 @@ class Device(object):
             self.engines.append(Engine(engine))
 
 class DriConf(object):
-    def __init__(self, xmlpath):
+    def __init__(self, xmlpaths):
         self.devices = []
-        root = ElementTree.parse(xmlpath).getroot()
+        for xmlpath in xmlpaths:
+            root = ElementTree.parse(xmlpath).getroot()
 
-        for device in root.findall('device'):
-            self.devices.append(Device(device))
+            for device in root.findall('device'):
+                self.devices.append(Device(device))
 
 
 template = """\
@@ -225,8 +226,16 @@ static const struct driconf_device *driconf[] = {
 };
 """
 
-xml = sys.argv[1]
-dst = sys.argv[2]
+parser = argparse.ArgumentParser()
+parser.add_argument('drirc',
+                    nargs=argparse.ONE_OR_MORE,
+                    help='drirc *.conf file(s) to statically include')
+parser.add_argument('header',
+                    help='C header file to output the static configuration to')
+args = parser.parse_args()
+
+xml = args.drirc
+dst = args.header
 
 with open(dst, 'wb') as f:
     f.write(Template(template, output_encoding='utf-8').render(driconf=DriConf(xml)))
index b6960a7..88f1090 100644 (file)
@@ -191,10 +191,10 @@ files_xmlconfig = files(
 
 files_xmlconfig += custom_target(
   'driconf_static.h',
-  input: ['driconf_static.py', '00-mesa-defaults.conf'],
+  input: ['driconf_static.py'] + files_drirc,
   output: 'driconf_static.h',
   command: [
-    prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'
+    prog_python, '@INPUT@', '@OUTPUT@',
   ],
 )