Update intro dump on meson configure

pull/4547/head
Daniel Mensinger 6 years ago
parent c4eb5c79fe
commit b91c5aad85
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 11
      docs/markdown/snippets/introspect_multiple.md
  2. 2
      mesonbuild/mconf.py
  3. 20
      mesonbuild/mintro.py
  4. 26
      run_unittests.py
  5. 2
      test cases/unit/49 introspection/meson.build

@ -1,12 +1,13 @@
## Added option to introspect multiple parameters at once
Meson introspect can now print the results of multiple parameters
in a single call. The results are then printed as a single JSON
Meson introspect can now print the results of multiple introspection
commands in a single call. The results are then printed as a single JSON
object.
The format for a single command was not changed to keep backward
compatibility.
Furthermore the option `-a,--all` and `-i,--indent` was added to
print all introspection information in one go and format the
JSON output (the default is still compact JSON).
Furthermore the option `-a,--all`, `-i,--indent` and `-f,--force-new`
were added to print all introspection information in one go, format the
JSON output (the default is still compact JSON) and foce use the new
output format, even if only one introspection command was given.

@ -14,6 +14,7 @@
import os
from . import (coredata, mesonlib, build)
from . import mintro
def add_arguments(parser):
coredata.register_builtin_arguments(parser)
@ -162,6 +163,7 @@ def run(options):
c.print_conf()
if save:
c.save()
mintro.update_build_options(c.coredata, builddir)
except ConfException as e:
print('Meson configurator encountered an error:')
raise e

@ -487,8 +487,7 @@ def run(options):
if options.all or options.benchmarks:
toextract += ['benchmarks']
if options.all or options.buildoptions:
coredata = cdata.load(options.builddir)
results += [list_buildoptions(coredata)]
toextract += ['buildoptions']
if options.all or options.buildsystem_files:
toextract += ['buildsystem_files']
if options.all or options.dependencies:
@ -550,3 +549,20 @@ def generate_introspection_file(builddata: build.Build, backend: backends.Backen
with open(outfile, 'w') as fp:
json.dump(outdict, fp)
def update_build_options(coredata, builddir):
outfile = os.path.join(builddir, INTROSPECTION_OUTPUT_FILE)
outfile = os.path.abspath(outfile)
with open(outfile, 'r') as fp:
outdict = json.load(fp)
intro_info = [
list_buildoptions(coredata)
]
for i in intro_info:
outdict[i[0]] = i[1]
with open(outfile, 'w') as fp:
json.dump(outdict, fp)

@ -3256,6 +3256,32 @@ recommended as it is not supported on some platforms''')
self.assertEqual(res_all, res_file)
def test_introspect_config_update(self):
testdir = os.path.join(self.unit_test_dir, '49 introspection')
introfile = os.path.join(self.builddir, 'meson-introspection.json')
self.init(testdir)
self.assertPathExists(introfile)
with open(introfile, 'r') as fp:
res1 = json.load(fp)
self.setconf('-Dcpp_std=c++14')
self.setconf('-Dbuildtype=release')
for idx, i in enumerate(res1['buildoptions']):
if i['name'] == 'cpp_std':
res1['buildoptions'][idx]['value'] = 'c++14'
if i['name'] == 'buildtype':
res1['buildoptions'][idx]['value'] = 'release'
if i['name'] == 'optimization':
res1['buildoptions'][idx]['value'] = '3'
if i['name'] == 'debug':
res1['buildoptions'][idx]['value'] = False
with open(introfile, 'r') as fp:
res2 = json.load(fp)
self.assertDictEqual(res1, res2)
class FailureTests(BasePlatformTests):
'''
Tests that test failure conditions. Build files here should be dynamically

@ -1,4 +1,4 @@
project('introspection', ['c', 'cpp'], version: '1.2.3', default_options: ['cpp_std=c++11'])
project('introspection', ['c', 'cpp'], version: '1.2.3', default_options: ['cpp_std=c++11', 'buildtype=debug'])
dep1 = dependency('zlib')

Loading…
Cancel
Save