From 0b63dff3badf4f728d5dadda81dbef8de67ba164 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 31 Aug 2021 18:59:10 -0400 Subject: 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 --- mesonbuild/backend/backends.py | 5 ++++- test cases/unit/65 alias target/meson.build | 2 ++ test cases/unit/65 alias target/subdir/meson.build | 6 ++++++ unittests/allplatformstests.py | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test cases/unit/65 alias target/subdir/meson.build diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index b119377..f8ccdbe 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -358,7 +358,10 @@ class Backend: @lru_cache(maxsize=None) 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() else: dirname = 'meson-out' diff --git a/test cases/unit/65 alias target/meson.build b/test cases/unit/65 alias target/meson.build index 6934cc7..bcd4005 100644 --- a/test cases/unit/65 alias target/meson.build +++ b/test cases/unit/65 alias target/meson.build @@ -13,3 +13,5 @@ custom_target = custom_target('custom-target', ) alias_target('build-all', [exe_target, custom_target]) + +subdir('subdir') diff --git a/test cases/unit/65 alias target/subdir/meson.build b/test cases/unit/65 alias target/subdir/meson.build new file mode 100644 index 0000000..b3f5480 --- /dev/null +++ b/test cases/unit/65 alias target/subdir/meson.build @@ -0,0 +1,6 @@ +r = run_target('run-target', + command: [python3, '-c', 'print("a run target was here")'] +) + +alias_target('aliased-run', r) + diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 828ca58..fd88a27 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -3076,6 +3076,8 @@ class AllPlatformTests(BasePlatformTests): self.run_target('build-all') self.assertPathExists(os.path.join(self.builddir, 'prog' + exe_suffix)) 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): testdir = os.path.join(self.common_test_dir, '2 cpp') -- cgit v1.1