From 3317afe72da7798cbbefa55bf41f92f45e0fc91d Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 26 May 2025 10:15:34 +0200 Subject: options: accept backend options as pending on first invocation They must be there when running re-configuring, because the backend cannot be changed, but they can be pending on the first invocation. Signed-off-by: Paolo Bonzini --- mesonbuild/options.py | 5 ++++- unittests/optiontests.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 1ef5087a5..e999c61ee 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -1362,7 +1362,8 @@ class OptionStore: else: self.pending_options[key] = valstr - def accept_as_pending_option(self, key: OptionKey, known_subprojects: T.Optional[T.Union[T.Set[str], T.KeysView[str]]] = None) -> bool: + def accept_as_pending_option(self, key: OptionKey, known_subprojects: T.Optional[T.Union[T.Set[str], T.KeysView[str]]] = None, + first_invocation: bool = False) -> bool: # Fail on unknown options that we can know must exist at this point in time. # Subproject and compiler options are resolved later. # @@ -1373,6 +1374,8 @@ class OptionStore: return True if self.is_compiler_option(key): return True + if first_invocation and self.is_backend_option(key): + return True return (self.is_base_option(key) and key.evolve(subproject=None, machine=MachineChoice.HOST) in COMPILER_BASE_OPTIONS) diff --git a/unittests/optiontests.py b/unittests/optiontests.py index 25cebba49..b2ca5e026 100644 --- a/unittests/optiontests.py +++ b/unittests/optiontests.py @@ -224,6 +224,12 @@ class OptionTests(unittest.TestCase): self.assertTrue(optstore.accept_as_pending_option(OptionKey('b_ndebug'))) self.assertFalse(optstore.accept_as_pending_option(OptionKey('b_whatever'))) + def test_backend_option_pending(self): + optstore = OptionStore(False) + # backend options are known after the first invocation + self.assertTrue(optstore.accept_as_pending_option(OptionKey('backend_whatever'), set(), True)) + self.assertFalse(optstore.accept_as_pending_option(OptionKey('backend_whatever'), set(), False)) + def test_reconfigure_b_nonexistent(self): optstore = OptionStore(False) optstore.set_from_configure_command(['b_ndebug=true'], []) -- cgit v1.2.3