summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-05-26 10:15:34 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-06-18 21:33:19 +0300
commit3317afe72da7798cbbefa55bf41f92f45e0fc91d (patch)
tree786ba1b4f3112ed9115c6be05198f54c8ecd95e9
parent7c3354a7f41036e828d5a83f274952bf54811906 (diff)
downloadmeson-3317afe72da7798cbbefa55bf41f92f45e0fc91d.tar.gz
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 <pbonzini@redhat.com>
-rw-r--r--mesonbuild/options.py5
-rw-r--r--unittests/optiontests.py6
2 files changed, 10 insertions, 1 deletions
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'], [])