Merge pull request #4546 from mensinda/buildopts

Added 'section' key to buildoptions introspection
pull/4556/head
Jussi Pakkanen 6 years ago committed by GitHub
commit 2fb98144dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      docs/markdown/IDE-integration.md
  2. 14
      docs/markdown/snippets/buildopts_section.md
  3. 22
      mesonbuild/mconf.py
  4. 37
      mesonbuild/mintro.py
  5. 3
      run_unittests.py

@ -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. 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. 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 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. 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`. 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. 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.

@ -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

@ -115,21 +115,21 @@ class Conf:
print(' Source dir', self.build.environment.source_dir) print(' Source dir', self.build.environment.source_dir)
print(' Build dir ', self.build.environment.build_dir) print(' Build dir ', self.build.environment.build_dir)
dir_option_names = ['prefix', dir_option_names = ['bindir',
'libdir',
'libexecdir',
'bindir',
'sbindir',
'includedir',
'datadir', 'datadir',
'mandir', 'includedir',
'infodir', 'infodir',
'libdir',
'libexecdir',
'localedir', 'localedir',
'sysconfdir',
'localstatedir', 'localstatedir',
'sharedstatedir'] 'mandir',
test_option_names = ['stdsplit', 'prefix',
'errorlogs'] '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] 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} dir_options = {k: o for k, o in self.coredata.builtins.items() if k in dir_option_names}

@ -124,18 +124,43 @@ def list_target_files(target_name, coredata, builddata):
def list_buildoptions(coredata, builddata): def list_buildoptions(coredata, builddata):
optlist = [] optlist = []
add_keys(optlist, coredata.user_options)
add_keys(optlist, coredata.compiler_options) dir_option_names = ['bindir',
add_keys(optlist, coredata.base_options) 'datadir',
add_keys(optlist, coredata.builtins) 'includedir',
'infodir',
'libdir',
'libexecdir',
'localedir',
'localstatedir',
'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}
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)) print(json.dumps(optlist))
def add_keys(optlist, options): def add_keys(optlist, options, section):
keys = list(options.keys()) keys = list(options.keys())
keys.sort() keys.sort()
for key in keys: for key in keys:
opt = options[key] opt = options[key]
optdict = {'name': key, 'value': opt.value} optdict = {'name': key, 'value': opt.value, 'section': section}
if isinstance(opt, cdata.UserStringOption): if isinstance(opt, cdata.UserStringOption):
typestr = 'string' typestr = 'string'
elif isinstance(opt, cdata.UserBooleanOption): elif isinstance(opt, cdata.UserBooleanOption):

@ -2253,6 +2253,7 @@ int main(int argc, char **argv) {
expected = { expected = {
'name': 'list', 'name': 'list',
'description': 'list', 'description': 'list',
'section': 'user',
'type': 'array', 'type': 'array',
'value': ['foo', 'bar'], 'value': ['foo', 'bar'],
} }
@ -2277,6 +2278,7 @@ int main(int argc, char **argv) {
expected = { expected = {
'name': 'list', 'name': 'list',
'description': 'list', 'description': 'list',
'section': 'user',
'type': 'array', 'type': 'array',
'value': ['foo', 'bar'], 'value': ['foo', 'bar'],
} }
@ -2301,6 +2303,7 @@ int main(int argc, char **argv) {
expected = { expected = {
'name': 'list', 'name': 'list',
'description': 'list', 'description': 'list',
'section': 'user',
'type': 'array', 'type': 'array',
'value': [], 'value': [],
} }

Loading…
Cancel
Save