diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-05-15 19:14:44 +0200 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2025-05-23 13:55:44 -0400 |
| commit | 82fca502e131007f21d849f6a51064a92ac5b9ba (patch) | |
| tree | 8e0e02ca377194546a2adfbea11870da16a25e98 | |
| parent | cf3e5fe4c389d5ea7b8448b94f009157404c192c (diff) | |
| download | meson-82fca502e131007f21d849f6a51064a92ac5b9ba.tar.gz | |
options: process project options before machine options
Restore the behavior from before commit d37d649b0 ("Make all Meson level
options overridable per subproject.", 2025-02-13). The old code was:
options: T.MutableMapping[OptionKey, T.Any] = OrderedDict()
# process project default options
for k, v in default_options.items():
if not subproject or k.subproject == subproject:
options[k] = v
# override them with machine default and command line options
options.update(env.options)
env.options = options
Fixes: #14608
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | mesonbuild/options.py | 30 | ||||
| -rw-r--r-- | unittests/optiontests.py | 16 |
2 files changed, 31 insertions, 15 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py index ac90b2292..cd7d2eb6d 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -1289,21 +1289,6 @@ class OptionStore: (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: # @@ -1338,6 +1323,21 @@ class OptionStore: 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) diff --git a/unittests/optiontests.py b/unittests/optiontests.py index 0bdd7dc45..5758a2d5c 100644 --- a/unittests/optiontests.py +++ b/unittests/optiontests.py @@ -35,6 +35,22 @@ class OptionTests(unittest.TestCase): 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 OptionStore', '/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").""" |
