diff options
author | Daniel Schulte <trilader@schroedingers-bit.net> | 2019-01-30 21:30:52 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-03-01 23:40:33 +0200 |
commit | f0b0bcf86d195cc65918eea0de2c92083ac39f3f (patch) | |
tree | f04e32d6e39b904f0e1ea9a1db7dea02afb89c75 | |
parent | 924cf5e6220836be7ba9b53082948315497fce30 (diff) | |
download | meson-f0b0bcf86d195cc65918eea0de2c92083ac39f3f.zip meson-f0b0bcf86d195cc65918eea0de2c92083ac39f3f.tar.gz meson-f0b0bcf86d195cc65918eea0de2c92083ac39f3f.tar.bz2 |
mintro: Add subproject_dir to --projectinfo
-rw-r--r-- | docs/markdown/snippets/introspect_projectinfo_subprojects_dir.md | 4 | ||||
-rw-r--r-- | mesonbuild/ast/introspection.py | 4 | ||||
-rw-r--r-- | mesonbuild/mintro.py | 4 | ||||
-rwxr-xr-x | run_unittests.py | 16 |
4 files changed, 24 insertions, 4 deletions
diff --git a/docs/markdown/snippets/introspect_projectinfo_subprojects_dir.md b/docs/markdown/snippets/introspect_projectinfo_subprojects_dir.md new file mode 100644 index 0000000..6d893d0 --- /dev/null +++ b/docs/markdown/snippets/introspect_projectinfo_subprojects_dir.md @@ -0,0 +1,4 @@ +## Add subproject_dir to --projectinfo introspection output + +This allows applications interfacing with Meson (such as IDEs) to know about +an overridden subproject directory. diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index f0ff43f..4a6e6de 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -96,8 +96,8 @@ class IntrospectionInterpreter(AstInterpreter): if not self.is_subproject() and 'subproject_dir' in kwargs: spdirname = kwargs['subproject_dir'] - if isinstance(spdirname, str): - self.subproject_dir = spdirname + if isinstance(spdirname, mparser.ElementaryNode): + self.subproject_dir = spdirname.value if not self.is_subproject(): self.project_data['subprojects'] = [] subprojects_dir = os.path.join(self.source_root, self.subproject_dir) diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 8f9ed1d..b1e6509 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -288,7 +288,8 @@ def list_benchmarks(benchdata): def list_projinfo(builddata: build.Build): result = {'version': builddata.project_version, - 'descriptive_name': builddata.project_name} + 'descriptive_name': builddata.project_name, + 'subproject_dir': builddata.subproject_dir} subprojects = [] for k, v in builddata.subprojects.items(): c = {'name': k, @@ -313,6 +314,7 @@ def list_projinfo_from_source(sourcedir, indent): files = [x for x in files if not x.startswith(basedir)] intr.project_data['buildsystem_files'] = files + intr.project_data['subproject_dir'] = intr.subproject_dir print(json.dumps(intr.project_data, indent=indent)) def run(options): diff --git a/run_unittests.py b/run_unittests.py index dcd3ced..32c7875 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3226,6 +3226,7 @@ recommended as it is not supported on some platforms''') expected = { 'descriptive_name': 'proj', 'version': 'undefined', + 'subproject_dir': 'subprojects', 'subprojects': [ { 'descriptive_name': 'sub', @@ -3251,6 +3252,19 @@ recommended as it is not supported on some platforms''') name = entry['name'] self.assertEquals(entry['subproject'], expected[name]) + def test_introspect_projectinfo_subproject_dir(self): + testdir = os.path.join(self.common_test_dir, '79 custom subproject dir') + self.init(testdir) + res = self.introspect('--projectinfo') + + self.assertEqual(res['subproject_dir'], 'custom_subproject_dir') + + def test_introspect_projectinfo_subproject_dir_from_source(self): + testfile = os.path.join(self.common_test_dir, '79 custom subproject dir', 'meson.build') + res = self.introspect_directory(testfile, '--projectinfo') + + self.assertEqual(res['subproject_dir'], 'custom_subproject_dir') + @skipIfNoExecutable('clang-format') def test_clang_format(self): if self.backend is not Backend.ninja: @@ -3404,7 +3418,7 @@ recommended as it is not supported on some platforms''') self.assertListEqual(dependencies_to_find, []) # Check projectinfo - self.assertDictEqual(res['projectinfo'], {'version': '1.2.3', 'descriptive_name': 'introspection', 'subprojects': []}) + self.assertDictEqual(res['projectinfo'], {'version': '1.2.3', 'descriptive_name': 'introspection', 'subproject_dir': 'subprojects', 'subprojects': []}) # Check targets targets_to_find = { |