freedreno: explicitly declare required depend_files, part 1

Fixes the following with meson2hermetic:

src/freedreno/registers/adreno/a6xx_perfcntrs.py/genrule.sbox.textproto

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "gen_header.py", line 1220, in <module>
  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 <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41518>
This commit is contained in:
Gurchetan Singh 2026-05-11 11:53:09 -07:00 committed by Marge Bot
parent 1084ddd893
commit 1fe5838568
2 changed files with 22 additions and 12 deletions

View file

@ -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

View file

@ -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')