aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-03-04 11:06:43 +0100
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-03-04 17:36:41 +0100
commitbe0a05e7770ba716aed3369e9d7f26713a99ff0a (patch)
tree51030c85209c74d6640a38135d469efc4b68b206
parent675bb2f340e581c3b092d082a43b22ce3bae0da8 (diff)
downloadmeson-be0a05e7770ba716aed3369e9d7f26713a99ff0a.zip
meson-be0a05e7770ba716aed3369e9d7f26713a99ff0a.tar.gz
meson-be0a05e7770ba716aed3369e9d7f26713a99ff0a.tar.bz2
mintro: include the correct target filenames for flat layout
Fixes: #8408
-rw-r--r--mesonbuild/mintro.py12
-rwxr-xr-xrun_unittests.py13
2 files changed, 23 insertions, 2 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index 0497845..9d8682c 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -119,6 +119,12 @@ def list_installed(installdata: backends.InstallData) -> T.Dict[str, str]:
res[i.path] = os.path.join(installdata.prefix, i.install_path)
return res
+def get_target_dir(coredata: cdata.CoreData, subdir: str) -> str:
+ if coredata.get_option(OptionKey('layout')) == 'flat':
+ return 'meson-out'
+ else:
+ return subdir
+
def list_targets_from_source(intr: IntrospectionInterpreter) -> T.List[T.Dict[str, T.Union[bool, str, T.List[T.Union[str, T.Dict[str, T.Union[str, T.List[str], bool]]]]]]]:
tlist = [] # type: T.List[T.Dict[str, T.Union[bool, str, T.List[T.Union[str, T.Dict[str, T.Union[str, T.List[str], bool]]]]]]]
root_dir = Path(intr.source_root)
@@ -148,13 +154,14 @@ def list_targets_from_source(intr: IntrospectionInterpreter) -> T.List[T.Dict[st
for i in intr.targets:
sources = nodes_to_paths(i['sources'])
extra_f = nodes_to_paths(i['extra_files'])
+ outdir = get_target_dir(intr.coredata, i['subdir'])
tlist += [{
'name': i['name'],
'id': i['id'],
'type': i['type'],
'defined_in': i['defined_in'],
- 'filename': [os.path.join(i['subdir'], x) for x in i['outputs']],
+ 'filename': [os.path.join(outdir, x) for x in i['outputs']],
'build_by_default': i['build_by_default'],
'target_sources': [{
'language': 'unknown',
@@ -186,12 +193,13 @@ def list_targets(builddata: build.Build, installdata: backends.InstallData, back
if not isinstance(target, build.Target):
raise RuntimeError('The target object in `builddata.get_targets()` is not of type `build.Target`. Please file a bug with this error message.')
+ outdir = get_target_dir(builddata.environment.coredata, target.subdir)
t = {
'name': target.get_basename(),
'id': idname,
'type': target.get_typename(),
'defined_in': os.path.normpath(os.path.join(src_dir, target.subdir, 'meson.build')),
- 'filename': [os.path.join(build_dir, target.subdir, x) for x in target.get_outputs()],
+ 'filename': [os.path.join(build_dir, outdir, x) for x in target.get_outputs()],
'build_by_default': target.build_by_default,
'target_sources': backend.get_introspection_data(idname, target),
'extra_files': [os.path.normpath(os.path.join(src_dir, x.subdir, x.fname)) for x in target.extra_files],
diff --git a/run_unittests.py b/run_unittests.py
index 53642ca..6cdcc8c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -4538,6 +4538,19 @@ class AllPlatformTests(BasePlatformTests):
self.assertIn('c_args', optnames)
self.assertNotIn('build.c_args', optnames)
+ def test_introspect_json_flat(self):
+ testdir = os.path.join(self.unit_test_dir, '57 introspection')
+ out = self.init(testdir, extra_args=['-Dlayout=flat'])
+ infodir = os.path.join(self.builddir, 'meson-info')
+ self.assertPathExists(infodir)
+
+ with open(os.path.join(infodir, 'intro-targets.json'), 'r') as fp:
+ targets = json.load(fp)
+
+ for i in targets:
+ for out in i['filename']:
+ assert(os.path.relpath(out, self.builddir).startswith('meson-out'))
+
def test_introspect_json_dump(self):
testdir = os.path.join(self.unit_test_dir, '57 introspection')
self.init(testdir)