nir/meson: only try to generate the nir_opt_algebraic tests when requested

Anything listed in a meson target's `output` is expected to exist once
the command has run. If it's missing, meson/ninja will run the command
again to try to generate it, resulting in a ton of files getting
re-generated/re-compiled for no reason.

Fixes: 4c30c44b75 ("nir: Generate unit tests for nir_opt_algebraic")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14667
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39350>
This commit is contained in:
Eric Engestrom 2026-01-16 14:25:40 +01:00 committed by Marge Bot
parent 1c118b9319
commit 246095da49
2 changed files with 8 additions and 5 deletions

View file

@ -44,13 +44,12 @@ nir_opcodes_c = custom_target(
nir_opt_algebraic = custom_target(
'nir_opt_algebraic',
input : 'nir_opt_algebraic.py',
output : ['nir_opt_algebraic.c', 'nir_opt_algebraic_pattern_test.cpp'],
command : [prog_python, '@INPUT@', '--out', '@OUTPUT0@', '--out-tests', '@OUTPUT1@'] +
(with_tests ? ['--build-tests'] : []),
output : ['nir_opt_algebraic.c'] + (with_tests ? ['nir_opt_algebraic_pattern_test.cpp'] : []),
command : [prog_python, '@INPUT@', '--out', '@OUTPUT0@'] +
(with_tests ? ['--build-tests', '--out-tests', '@OUTPUT1@'] : []),
depend_files : nir_algebraic_depends,
)
nir_opt_algebraic_c = nir_opt_algebraic[0]
nir_opt_algebraic_pattern_test_cpp = nir_opt_algebraic[1]
nir_intrinsics_h = custom_target(
'nir_intrinsics.h',
@ -411,6 +410,7 @@ if with_tests
# Split the compile of nir_opt_algebraic_pattern_tests into multiple compilation
# units, as it takes about of minute of compile time all together.
nir_opt_algebraic_pattern_test_cpp = nir_opt_algebraic[1]
nir_opt_algebraic_pattern_tests = []
foreach i : range(8)
nir_opt_algebraic_pattern_tests += static_library(

View file

@ -4282,10 +4282,13 @@ for s in [8, 16]:
parser = argparse.ArgumentParser()
parser.add_argument('--out', required=True)
parser.add_argument('--out-tests', required=True)
parser.add_argument('--out-tests')
parser.add_argument('--build-tests', action='store_true')
args = parser.parse_args()
if args.build_tests and not args.out_tests:
parser.error("--build-tests requires --out-tests")
passes = []
passes.append(nir_algebraic.AlgebraicPass(