freedreno/registers: split header build into subdirs
authorRob Clark <robdclark@chromium.org>
Sun, 2 Aug 2020 18:35:48 +0000 (11:35 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 3 Aug 2020 19:46:49 +0000 (19:46 +0000)
Instead of building the adreno/foo.xml headers from the toplevel, split
out a subdir().  This fits better with how meson likes things to be
structured.  But it does require fixing a bit about how gen_header.py
resolves imports, ie. it cannot assume the src file is at the root of
the $RNN_PATH.

This is needed for the next patch, to add support for installing the
register database for use with installed tools.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6154>

src/freedreno/computerator/a6xx.c
src/freedreno/computerator/main.h
src/freedreno/meson.build
src/freedreno/registers/adreno/meson.build [new file with mode: 0644]
src/freedreno/registers/gen_header.py
src/freedreno/registers/meson.build
src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_cs.h
src/freedreno/vulkan/tu_formats.c
src/freedreno/vulkan/tu_query.c

index 21d7d1c4894a9c0b254ca4120bc2bf7aa2815ac5..4d8dce2b6aa9c86d7ba06ddcaed0c8acb033fd67 100644 (file)
@@ -25,9 +25,9 @@
 
 #include "util/u_math.h"
 
-#include "registers/adreno_pm4.xml.h"
-#include "registers/adreno_common.xml.h"
-#include "registers/a6xx.xml.h"
+#include "adreno_pm4.xml.h"
+#include "adreno_common.xml.h"
+#include "a6xx.xml.h"
 
 #include "main.h"
 #include "ir3_asm.h"
index d72e143a3ae5b1de28d986d02ab03d360c9e950b..8d310f769696b6e7bb15438e669b0a2a6ca46f29 100644 (file)
@@ -31,8 +31,8 @@
 #include "drm/freedreno_drmif.h"
 #include "drm/freedreno_ringbuffer.h"
 
-#include "registers/adreno_pm4.xml.h"
-#include "registers/adreno_common.xml.h"
+#include "adreno_pm4.xml.h"
+#include "adreno_common.xml.h"
 
 #define MAX_BUFS 4
 
index 4350aa8d526880ad5db9782c6b7bf56cbef9d868..e039ab9c9a620981ec3b50fe6f72da51aaa8fe67 100644 (file)
@@ -18,7 +18,7 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-inc_freedreno = include_directories(['.', './registers', './common'])
+inc_freedreno = include_directories(['.', './registers', './registers/adreno', './common'])
 inc_freedreno_rnn = include_directories('rnn')
 
 rnn_src_path = meson.source_root() + '/src/freedreno/registers'
diff --git a/src/freedreno/registers/adreno/meson.build b/src/freedreno/registers/adreno/meson.build
new file mode 100644 (file)
index 0000000..eb9c073
--- /dev/null
@@ -0,0 +1,56 @@
+# Copyright © 2019 Google, Inc
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+xml_files = [
+  'a2xx.xml',
+  'a3xx.xml',
+  'a4xx.xml',
+  'a5xx.xml',
+  'a6xx.xml',
+  'adreno_common.xml',
+  'adreno_pm4.xml',
+]
+
+foreach f : xml_files
+  _name = f + '.h'
+  freedreno_xml_header_files += custom_target(
+    _name,
+    input: [gen_header_py, f],
+    output: _name,
+    command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@'],
+    capture: true,
+  )
+endforeach
+
+freedreno_xml_header_files += custom_target(
+    'a6xx-pack.xml.h',
+    input: [gen_header_py, 'a6xx.xml'],
+    output: 'a6xx-pack.xml.h',
+    command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@', '--pack-structs'],
+    capture: true,
+)
+
+freedreno_xml_header_files += custom_target(
+    'adreno-pm4-pack.xml.h',
+    input: [gen_header_py, 'adreno_pm4.xml'],
+    output: 'adreno-pm4-pack.xml.h',
+    command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@', '--pack-structs'],
+    capture: true,
+)
index c0fc47fd8b4e526439aa36690b246c72e070cf2e..db491cfbbb01a357781b8db35d7b20e050bee138 100644 (file)
@@ -335,14 +335,7 @@ class Parser(object):
                        raise self.error(e);
 
        def do_parse(self, filename):
-               try:
-                       file = open(filename, "rb")
-               except FileNotFoundError as e:
-                       # Look for the file in the parent directory if not
-                       # found in same directory:
-                       path = os.path.dirname(filename)
-                       base = os.path.basename(filename)
-                       file = open(path + "/../" + base, "rb")
+               file = open(filename, "rb")
                parser = xml.parsers.expat.ParserCreate()
                self.stack.append((parser, filename))
                parser.StartElementHandler = self.start_element
@@ -351,8 +344,8 @@ class Parser(object):
                self.stack.pop()
                file.close()
 
-       def parse(self, filename):
-               self.path = os.path.dirname(filename)
+       def parse(self, rnn_path, filename):
+               self.path = rnn_path
                self.stack = []
                self.do_parse(filename)
 
@@ -373,7 +366,7 @@ class Parser(object):
 
        def start_element(self, name, attrs):
                if name == "import":
-                       filename = os.path.basename(attrs["file"])
+                       filename = attrs["file"]
                        self.do_parse(os.path.join(self.path, filename))
                elif name == "domain":
                        self.current_domain = attrs["name"]
@@ -449,8 +442,9 @@ class Parser(object):
 
 def main():
        p = Parser()
-       xml_file = sys.argv[1]
-       if len(sys.argv) > 2 and sys.argv[2] == '--pack-structs':
+       rnn_path = sys.argv[1]
+       xml_file = sys.argv[2]
+       if len(sys.argv) > 3 and sys.argv[3] == '--pack-structs':
                do_structs = True
                guard = str.replace(os.path.basename(xml_file), '.', '_').upper() + '_STRUCTS'
        else:
@@ -460,7 +454,7 @@ def main():
        print("#ifndef %s\n#define %s\n" % (guard, guard))
 
        try:
-               p.parse(xml_file)
+               p.parse(rnn_path, xml_file)
        except Error as e:
                print(e)
                exit(1)
index d38e16612626eb247ae6753d433cff5ba591d2be..a0f2b351f88257e09fb6a87b300e8d9df1cd8d19 100644 (file)
 # SOFTWARE.
 
 xml_files = [
-  'a2xx.xml',
-  'a3xx.xml',
-  'a4xx.xml',
-  'a5xx.xml',
-  'a6xx.xml',
-  'adreno_common.xml',
-  'adreno_pm4.xml',
+  'adreno.xml',
 ]
 
+gen_header_py = files('gen_header.py')
+
 freedreno_xml_header_files = []
+
 foreach f : xml_files
   _name = f + '.h'
   freedreno_xml_header_files += custom_target(
     _name,
-    input : ['gen_header.py', 'adreno/' + f],
-    output : _name,
-    command : [prog_python, '@INPUT@'],
-    capture : true,
+    input: [gen_header_py, f],
+    output: _name,
+    command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@'],
+    capture: true,
   )
 endforeach
 
-freedreno_xml_header_files += custom_target(
-    'a6xx-pack.xml.h',
-    input : ['gen_header.py', 'adreno/a6xx.xml'],
-    output : 'a6xx-pack.xml.h',
-    command : [prog_python, '@INPUT@', '--pack-structs'],
-    capture : true,
-  )
-freedreno_xml_header_files += custom_target(
-    'adreno-pm4-pack.xml.h',
-     input : ['gen_header.py', 'adreno/adreno_pm4.xml'],
-     output : 'adreno-pm4-pack.xml.h',
-     command : [prog_python, '@INPUT@', '--pack-structs'],
-     capture : true,
-  )
+subdir('adreno')
index ae89c9ab86dbb416be17f47a5fc5c5cd3f61b1cb..deebd7132d53d693a1783c653cabdc6727e15504 100644 (file)
@@ -27,8 +27,8 @@
 
 #include "tu_private.h"
 
-#include "registers/adreno_pm4.xml.h"
-#include "registers/adreno_common.xml.h"
+#include "adreno_pm4.xml.h"
+#include "adreno_common.xml.h"
 
 #include "vk_format.h"
 
index 85c53ea4f6e55e59d1cd8d1877c7e6ea9c05e27e..77be4319a11a01e0787c7bdae3fa8484fc5a171e 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "tu_private.h"
 
-#include "registers/adreno_pm4.xml.h"
+#include "adreno_pm4.xml.h"
 
 void
 tu_cs_init(struct tu_cs *cs,
index 819a69029823a5cd0ec5a80f69d221b5f4f44cb5..6394ba138b8ce9886cb666f1f6f62e0c9c130a90 100644 (file)
@@ -25,8 +25,8 @@
 
 #include "tu_private.h"
 
-#include "registers/adreno_common.xml.h"
-#include "registers/a6xx.xml.h"
+#include "adreno_common.xml.h"
+#include "a6xx.xml.h"
 
 #include "vk_format.h"
 #include "vk_util.h"
index 4e7427161a25868c6d7885304e1de692ba42568c..9b013060cb37fbe1058d471034fb74f71ffbd594 100644 (file)
@@ -31,9 +31,9 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "registers/adreno_pm4.xml.h"
-#include "registers/adreno_common.xml.h"
-#include "registers/a6xx.xml.h"
+#include "adreno_pm4.xml.h"
+#include "adreno_common.xml.h"
+#include "a6xx.xml.h"
 
 #include "nir/nir_builder.h"
 #include "util/os_time.h"