Skip to content

Commit

Permalink
Use correct subdir when generating processed file path
Browse files Browse the repository at this point in the history
We need the subdir of where the output file will actually be created,
not the current subdir of the interpreter.

Fixes: mesonbuild#13168
  • Loading branch information
tristan957 committed May 2, 2024
1 parent a0ff145 commit 4287858
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 1 addition & 2 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test_header = custom_target(
output: 'test_header.h',
command: [touch, '@OUTPUT@'],
)
22 changes: 22 additions & 0 deletions test cases/common/276 generator custom_tgt subdir/meson.build
Original file line number Diff line number Diff line change
@@ -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: '@[email protected]',
)

custom_target(
'check-headers.stamp',
command: [touch, '@INPUT@'],
input: gen.process(test_header),
output: 'check-headers.stamp',
build_by_default: true,
)

0 comments on commit 4287858

Please sign in to comment.