Skip to content

Commit 3317afe

Browse files
bonzinijpakkane
authored andcommitted
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 <[email protected]>
1 parent 7c3354a commit 3317afe

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mesonbuild/options.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,8 @@ def initialize_from_top_level_project_call(self,
13621362
else:
13631363
self.pending_options[key] = valstr
13641364

1365-
def accept_as_pending_option(self, key: OptionKey, known_subprojects: T.Optional[T.Union[T.Set[str], T.KeysView[str]]] = None) -> bool:
1365+
def accept_as_pending_option(self, key: OptionKey, known_subprojects: T.Optional[T.Union[T.Set[str], T.KeysView[str]]] = None,
1366+
first_invocation: bool = False) -> bool:
13661367
# Fail on unknown options that we can know must exist at this point in time.
13671368
# Subproject and compiler options are resolved later.
13681369
#
@@ -1373,6 +1374,8 @@ def accept_as_pending_option(self, key: OptionKey, known_subprojects: T.Optional
13731374
return True
13741375
if self.is_compiler_option(key):
13751376
return True
1377+
if first_invocation and self.is_backend_option(key):
1378+
return True
13761379
return (self.is_base_option(key) and
13771380
key.evolve(subproject=None, machine=MachineChoice.HOST) in COMPILER_BASE_OPTIONS)
13781381

unittests/optiontests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ def test_b_nonexistent(self):
224224
self.assertTrue(optstore.accept_as_pending_option(OptionKey('b_ndebug')))
225225
self.assertFalse(optstore.accept_as_pending_option(OptionKey('b_whatever')))
226226

227+
def test_backend_option_pending(self):
228+
optstore = OptionStore(False)
229+
# backend options are known after the first invocation
230+
self.assertTrue(optstore.accept_as_pending_option(OptionKey('backend_whatever'), set(), True))
231+
self.assertFalse(optstore.accept_as_pending_option(OptionKey('backend_whatever'), set(), False))
232+
227233
def test_reconfigure_b_nonexistent(self):
228234
optstore = OptionStore(False)
229235
optstore.set_from_configure_command(['b_ndebug=true'], [])

0 commit comments

Comments
 (0)