diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py index ac0ea7f06..6753b0255 100644 --- a/mesonbuild/msetup.py +++ b/mesonbuild/msetup.py @@ -191,7 +191,6 @@ class MesonApp: def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Any, all_subprojects: T.Any) -> None: pending = coredata.optstore.pending_project_options errlist: T.List[str] = [] - permitted_unknowns = ['b_vscrt', 'b_lto', 'b_lundef', 'b_ndebug'] permitlist: T.List[str] = [] for opt in pending: # Due to backwards compatibility setting build options in non-cross @@ -204,8 +203,10 @@ class MesonApp: if opt.subproject and opt.subproject not in all_subprojects: continue if coredata.optstore.is_compiler_option(opt): + permitlist.append(opt.name) continue - if opt.name in permitted_unknowns: + # Ditto for base options. + if coredata.optstore.is_base_option(opt): permitlist.append(opt.name) continue keystr = str(opt) @@ -222,7 +223,7 @@ class MesonApp: # support it, this option gets silently swallowed. # So at least print a message about it. optstr = ','.join(permitlist) - mlog.warning(f'Some command line options went unused: {optstr}', fatal=False) + mlog.warning(f'The following command line option(s) were not used: {optstr}', fatal=False) coredata.optstore.clear_pending() diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py index f787805a5..990936e85 100644 --- a/unittests/platformagnostictests.py +++ b/unittests/platformagnostictests.py @@ -415,9 +415,12 @@ class PlatformAgnosticTests(BasePlatformTests): def test_setup_with_unknown_option(self): testdir = os.path.join(self.common_test_dir, '1 trivial') - for option in ('not_an_option', 'b_not_an_option'): - out = self.init(testdir, extra_args=['--wipe', f'-D{option}=1'], allow_fail=True) - self.assertIn(f'ERROR: Unknown options: "{option}"', out) + out = self.init(testdir, extra_args=['--wipe', '-Dnot_an_option=1'], allow_fail=True) + self.assertIn('ERROR: Unknown options: "not_an_option"', out) + + out = self.init(testdir, extra_args=['--wipe', '-Db_not_an_option=1']) + self.assertIn('WARNING: The following command line option(s) were not used: b_not_an_option', out) + def test_configure_new_option(self) -> None: """Adding a new option without reconfiguring should work."""