From 1fe58385680017a6de546b5ab51f4e60980958e3 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Mon, 11 May 2026 11:53:09 -0700 Subject: [PATCH] freedreno: explicitly declare required depend_files, part 1 Fixes the following with meson2hermetic: src/freedreno/registers/adreno/a6xx_perfcntrs.py/genrule.sbox.textproto File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "gen_header.py", line 1220, in File "gen_header.py", line 1216, in main File "gen_header.py", line 1177, in dump_py_defines File "gen_header.py", line 688, in parse File "gen_header.py", line 680, in do_parse File "external/python/cpython3/Modules/pyexpat.c", line 471, in StartElement File "gen_header.py", line 732, in start_element File "gen_header.py", line 673, in do_parse FileNotFoundError: [Errno 2] No such file or directory: './out/src/freedreno/registers/adreno/adreno_common.xml' Soong/Bazel `genrules` run in a separate sandbox, and require that all dependencies be explicitly declared. It is necessary for reproducible, hermetic and distributed builds. Meson prefers explicit dependency declaration too, but does not require it. For example, if `adreno_common.xml` is modified, and it is in `depend_files` for the `adreno_pm4.xml.h` custom_target, meson knows to re-gen `adreno_pm4.xml.h` during incremental builds. For freedreno, the custom targets in `src/freedreno/registers/*` don't declare all XML dependencies that are actually used. This patch fixes this. The other option is workaround this in meson2hermetic, but being more explicit conceptually more correct. Reviewed-by: Eric Engestrom Part-of: --- src/freedreno/registers/adreno/meson.build | 23 +++++++++++++++------- src/freedreno/registers/meson.build | 11 ++++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/freedreno/registers/adreno/meson.build b/src/freedreno/registers/adreno/meson.build index 44ba48e0217..9543401d59d 100644 --- a/src/freedreno/registers/adreno/meson.build +++ b/src/freedreno/registers/adreno/meson.build @@ -1,7 +1,7 @@ # Copyright © 2019 Google, Inc # SPDX-License-Identifier: MIT -xml_reg_files = [ +xml_reg_files = files( 'a2xx.xml', 'a3xx.xml', 'a4xx.xml', @@ -15,7 +15,7 @@ xml_reg_files = [ 'a8xx_enums.xml', 'a8xx_descriptors.xml', 'a8xx_perfcntrs.xml', -] +) perfcntr_files = [ [ 'a2xx.xml', 'a2xx_perfcntrs.json' ], @@ -26,15 +26,16 @@ perfcntr_files = [ ] xml_files = xml_reg_files -xml_files += [ +xml_files += files( 'a6xx_gmu.xml', 'ocmem.xml', 'adreno_control_regs.xml', 'adreno_pipe_regs.xml', 'adreno_common.xml', -] +) freedreno_pm4_xml_header_file = [] +adreno_pm4_xml = files('adreno_pm4.xml') freedreno_pm4_xml_header_file += custom_target( 'adreno_pm4.xml.h', @@ -42,6 +43,7 @@ freedreno_pm4_xml_header_file += custom_target( output: 'adreno_pm4.xml.h', command: [prog_python, '@INPUT0@', '--rnn', rnn_src_path, '--xml', '@INPUT1@', 'c-defines'], capture: true, + depend_files: xml_files, ) freedreno_pm4_xml_header_file += custom_target( @@ -50,6 +52,7 @@ freedreno_pm4_xml_header_file += custom_target( output: 'adreno-pm4-pack.xml.h', command: [prog_python, '@INPUT0@', '--rnn', rnn_src_path, '--xml', '@INPUT1@', 'c-pack-structs'], capture: true, + depend_files: xml_files, ) freedreno_xml_header_files += freedreno_pm4_xml_header_file @@ -67,16 +70,18 @@ if install_fd_decode_tools endif foreach f : xml_files - _name = f + '.h' + _fname = fs.name(f) + _name = fs.replace_suffix(_fname, '.xml.h') freedreno_xml_header_files += custom_target( _name, input: [gen_header_py, f, freedreno_schema, freedreno_copyright], output: _name, command: [prog_python, '@INPUT0@', '--validate', '--rnn', rnn_src_path, '--xml', '@INPUT1@', 'c-defines'], capture: true, + depend_files: [xml_files, adreno_pm4_xml] ) if install_fd_decode_tools - _gzname = f + '.gz' + _gzname = fs.replace_suffix(_fname, '.xml.gz') custom_target( _gzname, input: f, @@ -98,6 +103,7 @@ foreach e : perfcntr_files output: _name, command: [prog_python, '@INPUT0@', '--validate', '--rnn', rnn_src_path, '--xml', '@INPUT1@', 'perfcntrs', '--json', '@INPUT2@'], capture: true, + depend_files: [xml_files, adreno_pm4_xml] ) endforeach @@ -107,17 +113,20 @@ freedreno_xml_header_files += custom_target( output: 'a6xx-pack.xml.h', command: [prog_python, '@INPUT0@', '--rnn', rnn_src_path, '--xml', '@INPUT1@', 'c-pack-structs'], capture: true, + depend_files: [xml_files, adreno_pm4_xml] ) freedreno_py_header_files = [] foreach f : xml_reg_files - _pyname = f.split('.')[0] + '.py' + _fname = fs.name(f) + _pyname = fs.replace_suffix(_fname, '.py') freedreno_py_header_files += custom_target( _pyname, input: [gen_header_py, f, freedreno_schema, freedreno_copyright], output: _pyname, command: [prog_python, '@INPUT0@', '--rnn', rnn_src_path, '--xml', '@INPUT1@', 'py-defines'], capture: true, + depend_files: [xml_files, adreno_pm4_xml] ) endforeach diff --git a/src/freedreno/registers/meson.build b/src/freedreno/registers/meson.build index f4be68117c3..9318ce48fe5 100644 --- a/src/freedreno/registers/meson.build +++ b/src/freedreno/registers/meson.build @@ -1,14 +1,14 @@ # Copyright © 2019 Google, Inc # SPDX-License-Identifier: MIT -xml_files = [ +xml_adreno_files = [ 'adreno.xml', ] rules_file = 'rules-fd.xsd' copyright_file = 'freedreno_copyright.xml' -install_files = xml_files + [rules_file, copyright_file] +install_files = xml_adreno_files + [rules_file, copyright_file] gen_header_py = files('gen_header.py') freedreno_schema = files(rules_file) @@ -16,7 +16,9 @@ freedreno_copyright = files(copyright_file) freedreno_xml_header_files = [] -foreach f : xml_files +subdir('adreno') + +foreach f : xml_adreno_files _name = f + '.h' freedreno_xml_header_files += custom_target( _name, @@ -24,6 +26,7 @@ foreach f : xml_files output: _name, command: [prog_python, '@INPUT0@', '--validate', '--rnn', rnn_src_path, '--xml', '@INPUT1@', 'c-defines'], capture: true, + depend_files: xml_files + adreno_pm4_xml ) endforeach @@ -42,5 +45,3 @@ if install_fd_decode_tools ) endforeach endif - -subdir('adreno')