aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/interpreter.py18
-rwxr-xr-xrun_unittests.py5
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