Skip to content

options: process project options before machine options #14611

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 15 additions & 15 deletions mesonbuild/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,21 +1285,6 @@ def initialize_from_top_level_project_call(self,
(project_default_options, cmd_line_options, machine_file_options) = self.first_handle_prefix(project_default_options_in,
cmd_line_options_in,
machine_file_options_in)
for key, valstr in machine_file_options.items():
# Due to backwards compatibility we ignore all build-machine options
# when building natively.
if not self.is_cross and key.is_for_build():
continue
if key.subproject:
self.augments[key] = valstr
elif key in self.options:
self.set_option(key, valstr, first_invocation)
else:
proj_key = key.as_root()
if proj_key in self.options:
self.set_option(proj_key, valstr, first_invocation)
else:
self.pending_options[key] = valstr
for keystr, valstr in project_default_options.items():
# Ths is complicated by the fact that a string can have two meanings:
#
Expand Down Expand Up @@ -1334,6 +1319,21 @@ def initialize_from_top_level_project_call(self,
self.set_option(proj_key, valstr)
else:
self.pending_options[key] = valstr
for key, valstr in machine_file_options.items():
# Due to backwards compatibility we ignore all build-machine options
# when building natively.
if not self.is_cross and key.is_for_build():
continue
if key.subproject:
self.augments[key] = valstr
elif key in self.options:
self.set_option(key, valstr, first_invocation)
else:
proj_key = key.as_root()
if proj_key in self.options:
self.set_option(proj_key, valstr, first_invocation)
else:
self.pending_options[key] = valstr
for keystr, valstr in cmd_line_options.items():
if isinstance(keystr, str):
key = OptionKey.from_string(keystr)
Expand Down
16 changes: 16 additions & 0 deletions unittests/optiontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ def test_toplevel_project(self):
optstore.initialize_from_top_level_project_call({OptionKey('someoption'): new_value}, {}, {})
self.assertEqual(optstore.get_value_for(k), new_value)

def test_machine_vs_project(self):
optstore = OptionStore(False)
name = 'backend'
default_value = 'ninja'
proj_value = 'xcode'
mfile_value = 'vs2010'
k = OptionKey(name)
prefix = UserStringOption('prefix', 'This is needed by OptionStroe', '/usr')
optstore.add_system_option('prefix', prefix)
vo = UserStringOption(k.name, 'You know what this is', default_value)
optstore.add_system_option(k.name, vo)
self.assertEqual(optstore.get_value_for(k), default_value)
optstore.initialize_from_top_level_project_call({OptionKey(name): proj_value}, {},
{OptionKey(name): mfile_value})
self.assertEqual(optstore.get_value_for(k), mfile_value)

def test_subproject_system_option(self):
"""Test that subproject system options get their default value from the global
option (e.g. "sub:b_lto" can be initialized from "b_lto")."""
Expand Down
Loading