Skip to content

Commit

Permalink
Fix unknown base options not detected in commandline arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
bruchar1 committed Feb 28, 2024
1 parent abb9f59 commit 3e65171
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mesonbuild/coredata.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ def set_options(self, options: T.Dict[OptionKey, T.Any], subproject: str = '', f
return dirty

def set_default_options(self, default_options: T.MutableMapping[OptionKey, str], subproject: str, env: 'Environment') -> None:
from .compilers import base_options

# Main project can set default options on subprojects, but subprojects
# can only set default options on themselves.
# Preserve order: if env.options has 'buildtype' it must come after
Expand Down Expand Up @@ -1005,7 +1007,10 @@ def set_default_options(self, default_options: T.MutableMapping[OptionKey, str],
continue
# Skip base, compiler, and backend options, they are handled when
# adding languages and setting backend.
if k.type in {OptionType.COMPILER, OptionType.BACKEND, OptionType.BASE}:
if k.type == OptionType.BASE and k in base_options:
# set_options will report unknown base options
continue
if k.type in {OptionType.COMPILER, OptionType.BACKEND}:
continue
options[k] = v

Expand Down
7 changes: 7 additions & 0 deletions unittests/platformagnostictests.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,10 @@ def test_reconfigure_base_options(self):
out = self.init(testdir, extra_args=['--reconfigure', '-Db_ndebug=if-release', '-Dc_std=c99'], inprocess=True)
self.assertIn('\nMessage: b_ndebug: if-release\n', out)
self.assertIn('\nMessage: c_std: c99\n', out)

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'], inprocess=True, allow_fail=True)
self.assertIn(f'ERROR: Unknown options: "{option}"', out)

0 comments on commit 3e65171

Please sign in to comment.