Skip to content

Commit 4386e2a

Browse files
committed
Permit all unknown b_ options.
Closes mesonbuild#14254.
1 parent d995cbc commit 4386e2a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

mesonbuild/msetup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def generate(self, capture: bool = False, vslite_ctx: T.Optional[dict] = None) -
191191
def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Any, all_subprojects: T.Any) -> None:
192192
pending = coredata.optstore.pending_project_options
193193
errlist: T.List[str] = []
194-
permitted_unknowns = ['b_vscrt', 'b_lto', 'b_lundef', 'b_ndebug']
195194
permitlist: T.List[str] = []
196195
for opt in pending:
197196
# Due to backwards compatibility setting build options in non-cross
@@ -204,8 +203,10 @@ def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options:
204203
if opt.subproject and opt.subproject not in all_subprojects:
205204
continue
206205
if coredata.optstore.is_compiler_option(opt):
206+
permitlist.append(opt.name)
207207
continue
208-
if opt.name in permitted_unknowns:
208+
# Ditto for base options.
209+
if coredata.optstore.is_base_option(opt):
209210
permitlist.append(opt.name)
210211
continue
211212
keystr = str(opt)
@@ -222,7 +223,7 @@ def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options:
222223
# support it, this option gets silently swallowed.
223224
# So at least print a message about it.
224225
optstr = ','.join(permitlist)
225-
mlog.warning(f'Some command line options went unused: {optstr}', fatal=False)
226+
mlog.warning(f'The following command line option(s) were not used: {optstr}', fatal=False)
226227

227228
coredata.optstore.clear_pending()
228229

unittests/platformagnostictests.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,12 @@ def test_reconfigure_base_options(self):
415415
def test_setup_with_unknown_option(self):
416416
testdir = os.path.join(self.common_test_dir, '1 trivial')
417417

418-
for option in ('not_an_option', 'b_not_an_option'):
419-
out = self.init(testdir, extra_args=['--wipe', f'-D{option}=1'], allow_fail=True)
420-
self.assertIn(f'ERROR: Unknown options: "{option}"', out)
418+
out = self.init(testdir, extra_args=['--wipe', '-Dnot_an_option=1'], allow_fail=True)
419+
self.assertIn('ERROR: Unknown options: "not_an_option"', out)
420+
421+
out = self.init(testdir, extra_args=['--wipe', '-Db_not_an_option=1'])
422+
self.assertIn('WARNING: The following command line option(s) were not used: b_not_an_option', out)
423+
421424

422425
def test_configure_new_option(self) -> None:
423426
"""Adding a new option without reconfiguring should work."""

0 commit comments

Comments
 (0)