From 1f48aa595d53334a2cf2c5c9c14cb28a7b4ccbbc Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sat, 24 Nov 2018 09:49:33 +0100 Subject: [PATCH 1/3] Added 'section' key to buildoptions introspection --- mesonbuild/mintro.py | 37 +++++++++++++++++++++++++++++++------ run_unittests.py | 3 +++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index b15a608fe..94dee7c80 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -124,18 +124,43 @@ def list_target_files(target_name, coredata, builddata): def list_buildoptions(coredata, builddata): optlist = [] - add_keys(optlist, coredata.user_options) - add_keys(optlist, coredata.compiler_options) - add_keys(optlist, coredata.base_options) - add_keys(optlist, coredata.builtins) + + dir_option_names = ['prefix', + 'libdir', + 'libexecdir', + 'bindir', + 'sbindir', + 'includedir', + 'datadir', + 'mandir', + 'infodir', + 'localedir', + 'sysconfdir', + 'localstatedir', + 'sharedstatedir'] + test_option_names = ['stdsplit', + 'errorlogs'] + core_option_names = [k for k in coredata.builtins if k not in dir_option_names + test_option_names] + + dir_options = {k: o for k, o in coredata.builtins.items() if k in dir_option_names} + test_options = {k: o for k, o in coredata.builtins.items() if k in test_option_names} + core_options = {k: o for k, o in coredata.builtins.items() if k in core_option_names} + + add_keys(optlist, core_options, 'core') + add_keys(optlist, coredata.backend_options, 'backend') + add_keys(optlist, coredata.base_options, 'base') + add_keys(optlist, coredata.compiler_options, 'compiler') + add_keys(optlist, dir_options, 'directory') + add_keys(optlist, coredata.user_options, 'user') + add_keys(optlist, test_options, 'test') print(json.dumps(optlist)) -def add_keys(optlist, options): +def add_keys(optlist, options, section): keys = list(options.keys()) keys.sort() for key in keys: opt = options[key] - optdict = {'name': key, 'value': opt.value} + optdict = {'name': key, 'value': opt.value, 'section': section} if isinstance(opt, cdata.UserStringOption): typestr = 'string' elif isinstance(opt, cdata.UserBooleanOption): diff --git a/run_unittests.py b/run_unittests.py index a8371ad71..b99bc0561 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2253,6 +2253,7 @@ int main(int argc, char **argv) { expected = { 'name': 'list', 'description': 'list', + 'section': 'user', 'type': 'array', 'value': ['foo', 'bar'], } @@ -2277,6 +2278,7 @@ int main(int argc, char **argv) { expected = { 'name': 'list', 'description': 'list', + 'section': 'user', 'type': 'array', 'value': ['foo', 'bar'], } @@ -2301,6 +2303,7 @@ int main(int argc, char **argv) { expected = { 'name': 'list', 'description': 'list', + 'section': 'user', 'type': 'array', 'value': [], } From 1759fc8f459dc8d91675566c39b5dfee6fefe8dd Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sat, 24 Nov 2018 10:57:22 +0100 Subject: [PATCH 2/3] Sorted arrays alphabetically --- mesonbuild/mconf.py | 22 +++++++++++----------- mesonbuild/mintro.py | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index d0f837d3b..28589dab0 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -115,21 +115,21 @@ class Conf: print(' Source dir', self.build.environment.source_dir) print(' Build dir ', self.build.environment.build_dir) - dir_option_names = ['prefix', - 'libdir', - 'libexecdir', - 'bindir', - 'sbindir', - 'includedir', + dir_option_names = ['bindir', 'datadir', - 'mandir', + 'includedir', 'infodir', + 'libdir', + 'libexecdir', 'localedir', - 'sysconfdir', 'localstatedir', - 'sharedstatedir'] - test_option_names = ['stdsplit', - 'errorlogs'] + 'mandir', + 'prefix', + 'sbindir', + 'sharedstatedir', + 'sysconfdir'] + test_option_names = ['errorlogs', + 'stdsplit'] core_option_names = [k for k in self.coredata.builtins if k not in dir_option_names + test_option_names] dir_options = {k: o for k, o in self.coredata.builtins.items() if k in dir_option_names} diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 94dee7c80..4062299c0 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -125,21 +125,21 @@ def list_target_files(target_name, coredata, builddata): def list_buildoptions(coredata, builddata): optlist = [] - dir_option_names = ['prefix', - 'libdir', - 'libexecdir', - 'bindir', - 'sbindir', - 'includedir', + dir_option_names = ['bindir', 'datadir', - 'mandir', + 'includedir', 'infodir', + 'libdir', + 'libexecdir', 'localedir', - 'sysconfdir', 'localstatedir', - 'sharedstatedir'] - test_option_names = ['stdsplit', - 'errorlogs'] + 'mandir', + 'prefix', + 'sbindir', + 'sharedstatedir', + 'sysconfdir'] + test_option_names = ['errorlogs', + 'stdsplit'] core_option_names = [k for k in coredata.builtins if k not in dir_option_names + test_option_names] dir_options = {k: o for k, o in coredata.builtins.items() if k in dir_option_names} From ceb5e9f0420785799cbbc6167d224e89dcefb5ce Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sat, 24 Nov 2018 11:19:13 +0100 Subject: [PATCH 3/3] Updated docs [skip ci] --- docs/markdown/IDE-integration.md | 36 +++++++++++++++++++++ docs/markdown/snippets/buildopts_section.md | 14 ++++++++ 2 files changed, 50 insertions(+) create mode 100644 docs/markdown/snippets/buildopts_section.md diff --git a/docs/markdown/IDE-integration.md b/docs/markdown/IDE-integration.md index 2ce4b7868..5f0c0a66f 100644 --- a/docs/markdown/IDE-integration.md +++ b/docs/markdown/IDE-integration.md @@ -30,12 +30,48 @@ In order to make code completion work, you need the compiler flags for each comp Note that if the target has dependencies (such as generated sources), then the commands for those show up in this list as well, so you need to do some filtering. Alternatively you can grab every command invocation in the [Clang tools db](https://clang.llvm.org/docs/JSONCompilationDatabase.html) format that is written to a file called `compile_commands.json` in the build directory. +## Build Options + The next thing to display is the list of options that can be set. These include build type and so on. Here's how to extract them. meson introspect --buildoptions +This command returns a list of all supported buildoptions with the format: + +```json +{ + "name": "name of the option", + "description": "the description", + "type": "type ID", + "value": "value depends on type", + "section": "section ID" +} +``` + +The supported types are: + + - string + - boolean + - combo + - integer + - array + +For the type `combo` the key `choices` is also present. Here all valid values for the option are stored. + +The possible values for `section` are: + + - core + - backend + - base + - compiler + - directory + - user + - test + To set the options, use the `meson configure` command. +## Tests + Compilation and unit tests are done as usual by running the `ninja` and `ninja test` commands. A JSON formatted result log can be found in `workspace/project/builddir/meson-logs/testlog.json`. When these tests fail, the user probably wants to run the failing test in a debugger. To make this as integrated as possible, extract the test test setups with this command. diff --git a/docs/markdown/snippets/buildopts_section.md b/docs/markdown/snippets/buildopts_section.md new file mode 100644 index 000000000..74cf8a1c9 --- /dev/null +++ b/docs/markdown/snippets/buildopts_section.md @@ -0,0 +1,14 @@ +## New `section` key for the buildoptions introspection + +Meson now has a new `section` key in each build option. This allows +IDEs to group these options similar to `meson configure`. + +The possible values for `section` are: + + - core + - backend + - base + - compiler + - directory + - user + - test