From d8defe8ecdc5bca03acc269c11afe9db7ed6d454 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 9 May 2025 11:58:53 +0200 Subject: mconf: extract option processing to CoreData.set_from_configure_command Prepare to reuse the logic in "meson setup --reconfigure". Signed-off-by: Paolo Bonzini --- mesonbuild/coredata.py | 7 +++++++ mesonbuild/mconf.py | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 4343f6996..238b1e8c8 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -412,6 +412,13 @@ class CoreData: return option_object.validate_value(override) return value + def set_from_configure_command(self, options: SharedCMDOptions) -> bool: + unset_opts = getattr(options, 'unset_opts', []) + all_D = options.projectoptions[:] + for keystr, valstr in options.cmd_line_options.items(): + all_D.append(f'{keystr}={valstr}') + return self.optstore.set_from_configure_command(all_D, unset_opts) + def set_option(self, key: OptionKey, value, first_invocation: bool = False) -> bool: dirty = False try: diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index d03e6487e..6534a7c03 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -370,11 +370,7 @@ def run_impl(options: CMDOptions, builddir: str) -> int: save = False if has_option_flags(options): - unset_opts = getattr(options, 'unset_opts', []) - all_D = options.projectoptions[:] - for keystr, valstr in options.cmd_line_options.items(): - all_D.append(f'{keystr}={valstr}') - save |= c.coredata.optstore.set_from_configure_command(all_D, unset_opts) + save |= c.coredata.set_from_configure_command(options) coredata.update_cmd_line_file(builddir, options) if options.clearcache: c.clear_cache() -- cgit v1.2.3