mintro: Fix section key in buildoptions

This reverts the changes to the `section` key for the
buildoptions and moves the machine choice into it's
own `machine` key.

With this commit the __undocumented__ breaking change
to the introspection format (introduced in 0.51.0) is
reverted and a new key is added instead.
pull/5673/head
Daniel Mensinger 6 years ago committed by Jussi Pakkanen
parent 341d245e68
commit 3b3f53ab55
  1. 10
      docs/markdown/IDE-integration.md
  2. 14
      mesonbuild/mintro.py
  3. 9
      run_unittests.py

@ -143,7 +143,8 @@ the `intro-buildoptions.json` file. Here is the JSON format for each option.
"description": "the description", "description": "the description",
"type": "type ID", "type": "type ID",
"value": "value depends on type", "value": "value depends on type",
"section": "section ID" "section": "section ID",
"machine": "machine ID"
} }
``` ```
@ -168,6 +169,13 @@ The possible values for `section` are:
- user - user
- test - test
The `machine` key specifies the machine configuration for the option. Possible
values are:
- any
- host
- build
To set the options, use the `meson configure` command. To set the options, use the `meson configure` command.
Since Meson 0.50.0 it is also possible to get the default buildoptions Since Meson 0.50.0 it is also possible to get the default buildoptions

@ -229,31 +229,33 @@ def list_buildoptions(coredata: cdata.CoreData) -> List[dict]:
core_options = {k: o for k, o in coredata.builtins.items() if k in core_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, core_options, 'core')
add_keys(optlist, coredata.builtins_per_machine.host, 'core (for host machine)') add_keys(optlist, coredata.builtins_per_machine.host, 'core', machine='host')
add_keys( add_keys(
optlist, optlist,
{'build.' + k: o for k, o in coredata.builtins_per_machine.build.items()}, {'build.' + k: o for k, o in coredata.builtins_per_machine.build.items()},
'core (for build machine)', 'core',
machine='build',
) )
add_keys(optlist, coredata.backend_options, 'backend') add_keys(optlist, coredata.backend_options, 'backend')
add_keys(optlist, coredata.base_options, 'base') add_keys(optlist, coredata.base_options, 'base')
add_keys(optlist, coredata.compiler_options.host, 'compiler (for host machine)') add_keys(optlist, coredata.compiler_options.host, 'compiler', machine='host')
add_keys( add_keys(
optlist, optlist,
{'build.' + k: o for k, o in coredata.compiler_options.build.items()}, {'build.' + k: o for k, o in coredata.compiler_options.build.items()},
'compiler (for build machine)', 'compiler',
machine='build',
) )
add_keys(optlist, dir_options, 'directory') add_keys(optlist, dir_options, 'directory')
add_keys(optlist, coredata.user_options, 'user') add_keys(optlist, coredata.user_options, 'user')
add_keys(optlist, test_options, 'test') add_keys(optlist, test_options, 'test')
return optlist return optlist
def add_keys(optlist, options: Dict[str, cdata.UserOption], section): def add_keys(optlist, options: Dict[str, cdata.UserOption], section: str, machine: str = 'any'):
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, 'section': section} optdict = {'name': key, 'value': opt.value, 'section': section, 'machine': machine}
if isinstance(opt, cdata.UserStringOption): if isinstance(opt, cdata.UserStringOption):
typestr = 'string' typestr = 'string'
elif isinstance(opt, cdata.UserBooleanOption): elif isinstance(opt, cdata.UserBooleanOption):

@ -2630,6 +2630,7 @@ int main(int argc, char **argv) {
'section': 'user', 'section': 'user',
'type': 'array', 'type': 'array',
'value': ['foo', 'bar'], 'value': ['foo', 'bar'],
'machine': 'any',
} }
tdir = os.path.join(self.unit_test_dir, '19 array option') tdir = os.path.join(self.unit_test_dir, '19 array option')
self.init(tdir) self.init(tdir)
@ -2655,6 +2656,7 @@ int main(int argc, char **argv) {
'section': 'user', 'section': 'user',
'type': 'array', 'type': 'array',
'value': ['foo', 'bar'], 'value': ['foo', 'bar'],
'machine': 'any',
} }
tdir = os.path.join(self.unit_test_dir, '19 array option') tdir = os.path.join(self.unit_test_dir, '19 array option')
self.init(tdir) self.init(tdir)
@ -2680,6 +2682,7 @@ int main(int argc, char **argv) {
'section': 'user', 'section': 'user',
'type': 'array', 'type': 'array',
'value': [], 'value': [],
'machine': 'any',
} }
tdir = os.path.join(self.unit_test_dir, '19 array option') tdir = os.path.join(self.unit_test_dir, '19 array option')
self.init(tdir, extra_args='-Dlist=') self.init(tdir, extra_args='-Dlist=')
@ -3496,6 +3499,7 @@ recommended as it is not supported on some platforms''')
('section', str), ('section', str),
('type', str), ('type', str),
('description', str), ('description', str),
('machine', str),
] ]
buildoptions_typelist = [ buildoptions_typelist = [
@ -3506,6 +3510,9 @@ recommended as it is not supported on some platforms''')
('array', list, []), ('array', list, []),
] ]
buildoptions_sections = ['core', 'backend', 'base', 'compiler', 'directory', 'user', 'test']
buildoptions_machines = ['any', 'build', 'host']
dependencies_typelist = [ dependencies_typelist = [
('name', str), ('name', str),
('compile_args', list), ('compile_args', list),
@ -3561,6 +3568,8 @@ recommended as it is not supported on some platforms''')
valid_type = True valid_type = True
break break
self.assertIn(i['section'], buildoptions_sections)
self.assertIn(i['machine'], buildoptions_machines)
self.assertTrue(valid_type) self.assertTrue(valid_type)
if i['name'] in buildopts_to_find: if i['name'] in buildopts_to_find:
self.assertEqual(i['value'], buildopts_to_find[i['name']]) self.assertEqual(i['value'], buildopts_to_find[i['name']])

Loading…
Cancel
Save