diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-10-31 15:49:49 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-11-03 08:47:12 -0800 |
| commit | 0514719b3cfadf0c80d10dc6652154c7c2a86bce (patch) | |
| tree | 80694e7b71d62590b53c71260132d22b4eb60a9a /mesonbuild/backend/backends.py | |
| parent | d00f840c573103c2d51aed2b169386f7acfe7026 (diff) | |
| download | meson-0514719b3cfadf0c80d10dc6652154c7c2a86bce.tar.gz | |
backends: add CustomTargetIndexes to meson-{test,benchmark}-prereq
If a CustomTargetIndex is passed as an argument to a test, running meson
test (with no test glob) does not automatically build the custom_target
before running the test, because CustomTargetIndex outputs are not added
as prerequisites to the meson-test-prereq and meson-benchmark-prereq
targets.
Fixes: #14743
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/backend/backends.py')
| -rw-r--r-- | mesonbuild/backend/backends.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 5be2ade27..db7b5785c 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -1374,21 +1374,25 @@ class Backend: result[name] = b return result - def get_testlike_targets(self, benchmark: bool = False) -> T.OrderedDict[str, T.Union[build.BuildTarget, build.CustomTarget]]: - result: T.OrderedDict[str, T.Union[build.BuildTarget, build.CustomTarget]] = OrderedDict() + def get_testlike_targets(self, benchmark: bool = False) -> T.Iterable[T.Union[build.BuildTarget, build.CustomTarget]]: targets = self.build.get_benchmarks() if benchmark else self.build.get_tests() for t in targets: exe = t.exe - if isinstance(exe, (build.CustomTarget, build.BuildTarget)): - result[exe.get_id()] = exe + if isinstance(exe, build.CustomTargetIndex): + yield exe.target + elif isinstance(exe, (build.CustomTarget, build.BuildTarget)): + yield exe for arg in t.cmd_args: - if not isinstance(arg, (build.CustomTarget, build.BuildTarget)): - continue - result[arg.get_id()] = arg + if isinstance(arg, build.CustomTargetIndex): + yield arg.target + elif isinstance(arg, (build.CustomTarget, build.BuildTarget)): + yield arg for dep in t.depends: assert isinstance(dep, (build.CustomTarget, build.BuildTarget, build.CustomTargetIndex)) - result[dep.get_id()] = dep - return result + if isinstance(dep, build.CustomTargetIndex): + yield dep.target + else: + yield dep @lru_cache(maxsize=None) def get_custom_target_provided_by_generated_source(self, generated_source: build.CustomTarget) -> 'ImmutableListProtocol[str]': |
