Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix base and compiler options not reconfigurable. #12922

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bruchar1 this commit broke subprojects for me:

subprojects/mysubproj/meson.build:1:0: ERROR: In subproject mysubproj: Unknown options: "mysubproj:b_ndebug"


# 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 in {OptionType.COMPILER, OptionType.BACKEND}:
continue
if k.type == OptionType.BASE and k in base_options:
# set_options will report unknown base options
continue
options[k] = v

Expand Down
2 changes: 1 addition & 1 deletion unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,7 @@ def test_command_line(self):

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

# Test we can set subproject option
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'])
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'], allow_fail=True)
self.assertIn(f'ERROR: Unknown options: "{option}"', out)
Loading