Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mesonbuild/mcompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ def generate_target_names_ninja(target: ParsedTargetName, builddir: Path, intros
intro_target = get_target_from_intro_data(target, builddir, introspect_data)

if intro_target['type'] in {'alias', 'run'}:
return [target.name]
if intro_target['subproject']:
# TODO: This naming is required because of NinjaBackend.build_run_target_name()
# Can this be consolidated?
return [intro_target['subproject'] + '@@' + target.name]
else:
return [target.name]
else:
return [str(Path(out_file).relative_to(builddir.resolve())) for out_file in intro_target['filename']]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ subproject('foo')

true_cmd = find_program('true.py')

executable('bar', 'bar.c')
bar_exe = executable('bar', 'bar.c')
alias_target('bar_alias', bar_exe)
run_target('nop', command : [true_cmd])
custom_target('cus', output: ['cus.c'], command : [true_cmd])
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ project('subfoo', 'c')

true_cmd = find_program('true.py')

executable('bar', 'bar.c')
bar_exe = executable('bar', 'bar.c')
alias_target('bar_alias', bar_exe)
run_target('nop', command : [true_cmd])
custom_target('cus', output: ['cus.c'], command : [true_cmd])
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3

if __name__ == '__main__':
pass
print('Ran subproject true.py')
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3

if __name__ == '__main__':
pass
print('Ran top level true.py')
14 changes: 14 additions & 0 deletions unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3995,6 +3995,20 @@ def get_static_lib_name(basename: str) -> str:
out = self._run([*self.meson_command, 'compile', '-C', self.builddir, 'py3hi'])
self.assertIn('I am Python3.', out)

# run_target in subproject

testdir = os.path.join(self.common_test_dir, '83 identical target name in subproject')
self.init(testdir, extra_args=['--wipe'])
out = self._run([*self.meson_command, 'compile', '-C', self.builddir, './nop'])
self.assertIn('Ran top level true.py', out)
out = self._run([*self.meson_command, 'compile', '-C', self.builddir, './subprojects/foo/nop'])
self.assertIn('Ran subproject true.py', out)
# alias in subproject
self._run([*self.meson_command, 'compile', '-C', self.builddir, './bar_alias'])
self.assertPathExists(os.path.join(self.builddir, get_exe_name('bar')))
self._run([*self.meson_command, 'compile', '-C', self.builddir, './subprojects/foo/bar_alias'])
self.assertPathExists(os.path.join(self.builddir, 'subprojects', 'foo', get_exe_name('bar')))

# `--$BACKEND-args`

testdir = os.path.join(self.common_test_dir, '1 trivial')
Expand Down
Loading