aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/snippets/introspect_multiple.md11
-rw-r--r--mesonbuild/mconf.py2
-rw-r--r--mesonbuild/mintro.py20
-rwxr-xr-xrun_unittests.py26
-rw-r--r--test cases/unit/49 introspection/meson.build2
5 files changed, 53 insertions, 8 deletions
diff --git a/docs/markdown/snippets/introspect_multiple.md b/docs/markdown/snippets/introspect_multiple.md
index b7266f8..d05eae6 100644
--- a/docs/markdown/snippets/introspect_multiple.md
+++ b/docs/markdown/snippets/introspect_multiple.md
@@ -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). \ No newline at end of file
+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. \ No newline at end of file
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index 28589da..eca32bf 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -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
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index 326cd6c..04850c6 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -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)
diff --git a/run_unittests.py b/run_unittests.py
index 811df6b..492a22c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -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
diff --git a/test cases/unit/49 introspection/meson.build b/test cases/unit/49 introspection/meson.build
index bd5d51a..09b1d4f 100644
--- a/test cases/unit/49 introspection/meson.build
+++ b/test cases/unit/49 introspection/meson.build
@@ -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')