From 7074f12644ae0ddc7f8d7471f776bce3375934d4 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 3 Mar 2019 22:12:31 +0100 Subject: [PATCH] mintro: Renamed --dependencies --> --scan-dependencies --- docs/markdown/IDE-integration.md | 9 +++------ docs/markdown/snippets/introspect_deps_no_bd.md | 11 ++++------- mesonbuild/mintro.py | 11 +++++++++++ run_unittests.py | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/docs/markdown/IDE-integration.md b/docs/markdown/IDE-integration.md index 35ce88391..7bbec5d4b 100644 --- a/docs/markdown/IDE-integration.md +++ b/docs/markdown/IDE-integration.md @@ -187,13 +187,10 @@ The list of all _found_ dependencies can be acquired from `intro-dependencies.json`. Here, the name, compiler and linker arguments for a dependency are listed. -### Using `--dependencies` without a build directory +### Scanning for dependecie with `--scan-dependencies` -It is also possible to get most targets without a build directory. This can be -done by running `meson introspect --dependencies /path/to/meson.build`. - -However, the generated output is vastly different from running the introspection -command with a build directory. +It is also possible to get most dependencies used without a build directory. +This can be done by running `meson introspect --scan-dependencies /path/to/meson.build`. The output format is as follows: diff --git a/docs/markdown/snippets/introspect_deps_no_bd.md b/docs/markdown/snippets/introspect_deps_no_bd.md index a28b6679e..cfae58b49 100644 --- a/docs/markdown/snippets/introspect_deps_no_bd.md +++ b/docs/markdown/snippets/introspect_deps_no_bd.md @@ -1,10 +1,7 @@ -## `introspect --dependencies` can now be used without configured build directory +## `introspect --scan-dependencies` can now be used to scan for dependencies used in a project -It is now possible to run `meson introspect --dependencies /path/to/meson.build` -without a configured build directory. - -However, the generated output is vastly different from running the introspection -command with a build directory. +It is now possible to run `meson introspect --scan-dependencies /path/to/meson.build` +without a configured build directory to scan for dependencies. The output format is as follows: @@ -25,4 +22,4 @@ in the `meson.build` (all dependencies are required by default). The inside a conditional block. In a real meson run these dependencies might not be used, thus they _may_ not be required, even if the `required` key is set. The `has_fallback` key just indicates whether a fallback was directly set in the -`dependency()` function. \ No newline at end of file +`dependency()` function. diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index b3cc4f541..243dc5d94 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -70,6 +70,11 @@ def get_meson_introspection_types(coredata: Optional[cdata.CoreData] = None, 'no_bd': lambda intr: list_deps_from_source(intr), 'desc': 'List external dependencies.', }, + 'scan_dependencies': { + 'no_bd': lambda intr: list_deps_from_source(intr), + 'desc': 'Scan for dependencies used in the meson.build file.', + 'key': 'scan-dependencies', + }, 'installed': { 'func': lambda: list_installed(installdata), 'desc': 'List all installed files and directories.', @@ -431,6 +436,8 @@ def run(options): # Extract introspection information from JSON for i in intro_types.keys(): + if 'func' not in intro_types[i]: + continue if not options.all and not getattr(options, i, False): continue curr = os.path.join(infodir, 'intro-{}.json'.format(i)) @@ -461,6 +468,8 @@ def generate_introspection_file(builddata: build.Build, backend: backends.Backen intro_info = [] for key, val in intro_types.items(): + if 'func' not in val: + continue intro_info += [(key, val['func']())] write_intro_info(intro_info, builddata.environment.info_dir) @@ -489,6 +498,8 @@ def write_meson_info_file(builddata: build.Build, errors: list, build_files_upda intro_info = {} for i in intro_types.keys(): + if 'func' not in intro_types[i]: + continue intro_info[i] = { 'file': 'intro-{}.json'.format(i), 'updated': i in updated_introspection_files diff --git a/run_unittests.py b/run_unittests.py index d1bd2012b..c1337a3c4 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3545,7 +3545,7 @@ recommended as it is not supported on some platforms''') def test_introspect_dependencies_from_source(self): testdir = os.path.join(self.unit_test_dir, '52 introspection') testfile = os.path.join(testdir, 'meson.build') - res_nb = self.introspect_directory(testfile, ['--dependencies'] + self.meson_args) + res_nb = self.introspect_directory(testfile, ['--scan-dependencies'] + self.meson_args) expected = [ { 'name': 'threads',