Module: Mesa
Branch: main
Commit: 60ff0df39b7b5d20212dd285d470de001075d473
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=60ff0df39b7b5d20212dd285d470de001075d473

Author: Samuel Pitoiset <[email protected]>
Date:   Wed Nov 30 10:36:40 2022 +0100

driconf: add support for multiple input files in the static script

RADV has its own drirc file and this is required to fix the static
driconf path.

Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Dylan Baker <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20077>

---

 src/util/driconf_static.py | 23 ++++++++++++++++-------
 src/util/meson.build       |  4 ++--
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/util/driconf_static.py b/src/util/driconf_static.py
index 3e62336d647..ed4cf9ee254 100644
--- a/src/util/driconf_static.py
+++ b/src/util/driconf_static.py
@@ -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)))
diff --git a/src/util/meson.build b/src/util/meson.build
index b6960a7717e..88f109011d3 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -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@',
   ],
 )
 

Reply via email to