run_target: do not yield broken names with subdirs
A run_target object created in a subdir/meson.build always has a ninja rule name of "name", not "subdir/name". Fixes #9175
This commit is contained in:
parent
d67850b45e
commit
0b63dff3ba
|
@ -358,7 +358,10 @@ class Backend:
|
||||||
|
|
||||||
@lru_cache(maxsize=None)
|
@lru_cache(maxsize=None)
|
||||||
def get_target_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
|
def get_target_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
|
||||||
if self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
|
if isinstance(target, build.RunTarget):
|
||||||
|
# this produces no output, only a dummy top-level name
|
||||||
|
dirname = ''
|
||||||
|
elif self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
|
||||||
dirname = target.get_subdir()
|
dirname = target.get_subdir()
|
||||||
else:
|
else:
|
||||||
dirname = 'meson-out'
|
dirname = 'meson-out'
|
||||||
|
|
|
@ -13,3 +13,5 @@ custom_target = custom_target('custom-target',
|
||||||
)
|
)
|
||||||
|
|
||||||
alias_target('build-all', [exe_target, custom_target])
|
alias_target('build-all', [exe_target, custom_target])
|
||||||
|
|
||||||
|
subdir('subdir')
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
r = run_target('run-target',
|
||||||
|
command: [python3, '-c', 'print("a run target was here")']
|
||||||
|
)
|
||||||
|
|
||||||
|
alias_target('aliased-run', r)
|
||||||
|
|
|
@ -3076,6 +3076,8 @@ class AllPlatformTests(BasePlatformTests):
|
||||||
self.run_target('build-all')
|
self.run_target('build-all')
|
||||||
self.assertPathExists(os.path.join(self.builddir, 'prog' + exe_suffix))
|
self.assertPathExists(os.path.join(self.builddir, 'prog' + exe_suffix))
|
||||||
self.assertPathExists(os.path.join(self.builddir, 'hello.txt'))
|
self.assertPathExists(os.path.join(self.builddir, 'hello.txt'))
|
||||||
|
out = self.run_target('aliased-run')
|
||||||
|
self.assertIn('a run target was here', out)
|
||||||
|
|
||||||
def test_configure(self):
|
def test_configure(self):
|
||||||
testdir = os.path.join(self.common_test_dir, '2 cpp')
|
testdir = os.path.join(self.common_test_dir, '2 cpp')
|
||||||
|
|
Loading…
Reference in New Issue