diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-06-07 23:41:17 -0400 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-06-09 18:10:23 +0000 |
commit | 18e25b67737fa27ba38ee293718dc9ca40c81a43 (patch) | |
tree | 8ce2efd624d7c56997daf2805f83183385a70302 | |
parent | 2e34024a05ef7d38e24781513d04eab8fb30f882 (diff) | |
download | meson-18e25b67737fa27ba38ee293718dc9ca40c81a43.zip meson-18e25b67737fa27ba38ee293718dc9ca40c81a43.tar.gz meson-18e25b67737fa27ba38ee293718dc9ca40c81a43.tar.bz2 |
Fix options being reset to default on reconfigure
Closes: #3712
-rw-r--r-- | mesonbuild/interpreter.py | 18 | ||||
-rwxr-xr-x | run_unittests.py | 5 |
2 files changed, 19 insertions, 4 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index a58e57d..1e225da 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2269,7 +2269,10 @@ to directly access options of other subprojects.''') else: raise InterpreterException('Unknown backend "%s".' % backend) - self.coredata.init_backend_options(backend) + # Only init backend options on first invocation otherwise it would + # override values previously set from command line. + if self.environment.first_invocation: + self.coredata.init_backend_options(backend) options = {k: v for k, v in self.environment.cmd_line_options.items() if k.startswith('backend_')} self.coredata.set_options(options) @@ -2289,9 +2292,16 @@ to directly access options of other subprojects.''') oi.process(self.option_file) self.coredata.merge_user_options(oi.options) - default_options = mesonlib.stringlistify(kwargs.get('default_options', [])) - default_options = coredata.create_options_dict(default_options) - default_options.update(self.default_project_options) + # Do not set default_options on reconfigure otherwise it would override + # values previously set from command line. That means that changing + # default_options in a project will trigger a reconfigure but won't + # have any effect. + if self.environment.first_invocation: + default_options = mesonlib.stringlistify(kwargs.get('default_options', [])) + default_options = coredata.create_options_dict(default_options) + default_options.update(self.default_project_options) + else: + default_options = {} self.set_options(default_options) self.set_backend() diff --git a/run_unittests.py b/run_unittests.py index f353a10..7c68904 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2117,6 +2117,11 @@ recommended as it is not supported on some platforms''') self.setconf('--default-library=shared') obj = mesonbuild.coredata.load(self.builddir) self.assertEqual(obj.builtins['default_library'].value, 'shared') + if self.backend is Backend.ninja: + # reconfigure target works only with ninja backend + self.build('reconfigure') + obj = mesonbuild.coredata.load(self.builddir) + self.assertEqual(obj.builtins['default_library'].value, 'shared') self.wipe() # Should fail on unknown options |