From 4287858810a312a2d145f4764a289b46cd01119d Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Thu, 2 May 2024 00:01:25 -0500 Subject: [PATCH] Use correct subdir when generating processed file path We need the subdir of where the output file will actually be created, not the current subdir of the interpreter. Fixes: #13168 --- mesonbuild/build.py | 3 +-- .../include/meson.build | 4 ++++ .../meson.build | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test cases/common/276 generator custom_tgt subdir/include/meson.build create mode 100644 test cases/common/276 generator custom_tgt subdir/meson.build diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 6f0d6a2ddaac..44971ac63aeb 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1823,8 +1823,7 @@ def process_files(self, files: T.Iterable[T.Union[str, File, 'CustomTarget', 'Cu if isinstance(e, CustomTargetIndex): output.depends.add(e.target) if isinstance(e, (CustomTarget, CustomTargetIndex)): - output.depends.add(e) - fs = [File.from_built_file(state.subdir, f) for f in e.get_outputs()] + fs = [File.from_built_file(e.get_subdir(), f) for f in e.get_outputs()] elif isinstance(e, GeneratedList): if preserve_path_from: raise InvalidArguments("generator.process: 'preserve_path_from' is not allowed if one input is a 'generated_list'.") diff --git a/test cases/common/276 generator custom_tgt subdir/include/meson.build b/test cases/common/276 generator custom_tgt subdir/include/meson.build new file mode 100644 index 000000000000..15eafd3c42af --- /dev/null +++ b/test cases/common/276 generator custom_tgt subdir/include/meson.build @@ -0,0 +1,4 @@ +test_header = custom_target( + output: 'test_header.h', + command: [touch, '@OUTPUT@'], +) diff --git a/test cases/common/276 generator custom_tgt subdir/meson.build b/test cases/common/276 generator custom_tgt subdir/meson.build new file mode 100644 index 000000000000..4e4766538c80 --- /dev/null +++ b/test cases/common/276 generator custom_tgt subdir/meson.build @@ -0,0 +1,22 @@ +project('276 generator custom_tgt subdir') + +touch = find_program('touch', required: false) +if not touch.found() + error('MESON_SKIP_TEST: touch is required to run the test') +endif + +subdir('include') + +gen = generator( + touch, + arguments: ['@OUTPUT@'], + output: '@PLAINNAME@.t', +) + +custom_target( + 'check-headers.stamp', + command: [touch, '@INPUT@'], + input: gen.process(test_header), + output: 'check-headers.stamp', + build_by_default: true, +)