Skip to content

Commit cc4cfbc

Browse files
bruchar1dcbaker
authored andcommitted
Fix unknown base options not detected in commandline arguments
1 parent 76f6874 commit cc4cfbc

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

mesonbuild/coredata.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,8 @@ def set_options(self, options: T.Dict[OptionKey, T.Any], subproject: str = '', f
974974
return dirty
975975

976976
def set_default_options(self, default_options: T.MutableMapping[OptionKey, str], subproject: str, env: 'Environment') -> None:
977+
from .compilers import base_options
978+
977979
# Main project can set default options on subprojects, but subprojects
978980
# can only set default options on themselves.
979981
# Preserve order: if env.options has 'buildtype' it must come after
@@ -1005,7 +1007,10 @@ def set_default_options(self, default_options: T.MutableMapping[OptionKey, str],
10051007
continue
10061008
# Skip base, compiler, and backend options, they are handled when
10071009
# adding languages and setting backend.
1008-
if k.type in {OptionType.COMPILER, OptionType.BACKEND, OptionType.BASE}:
1010+
if k.type in {OptionType.COMPILER, OptionType.BACKEND}:
1011+
continue
1012+
if k.type == OptionType.BASE and k in base_options:
1013+
# set_options will report unknown base options
10091014
continue
10101015
options[k] = v
10111016

unittests/allplatformstests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ def test_command_line(self):
26942694

26952695
# It is not an error to set wrong option for unknown subprojects or
26962696
# language because we don't have control on which one will be selected.
2697-
self.init(testdir, extra_args=['-Dc_wrong=1', '-Dwrong:bad=1', '-Db_wrong=1'])
2697+
self.init(testdir, extra_args=['-Dc_wrong=1', '-Dwrong:bad=1'])
26982698
self.wipe()
26992699

27002700
# Test we can set subproject option

unittests/platformagnostictests.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,10 @@ def test_reconfigure_base_options(self):
285285
out = self.init(testdir, extra_args=['--reconfigure', '-Db_ndebug=if-release', '-Dc_std=c99'])
286286
self.assertIn('\nMessage: b_ndebug: if-release\n', out)
287287
self.assertIn('\nMessage: c_std: c99\n', out)
288+
289+
def test_setup_with_unknown_option(self):
290+
testdir = os.path.join(self.common_test_dir, '1 trivial')
291+
292+
for option in ('not_an_option', 'b_not_an_option'):
293+
out = self.init(testdir, extra_args=['--wipe', f'-D{option}=1'], allow_fail=True)
294+
self.assertIn(f'ERROR: Unknown options: "{option}"', out)

0 commit comments

Comments
 (0)