From c2e588a84f54411e72a41df2b1b57e4147d56e4e Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 23 Jul 2024 12:59:30 +0300 Subject: [PATCH] Fix pending options. --- mesonbuild/options.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 81797e59136c..441d5461b892 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -111,6 +111,7 @@ def __init__(self, # able tos ave the state and avoid the lookup function when # pickling/unpickling, but we need to be able to calculate it when # constructing a new OptionKey + assert ':' not in name object.__setattr__(self, 'name', name) object.__setattr__(self, 'subproject', subproject) object.__setattr__(self, 'machine', machine) @@ -709,13 +710,6 @@ def num_options(self): build = len(self.build_options) if self.build_options else 0 return basic + build - def add_system_option(self, name, value_object): - assert isinstance(name, str) - cname = self.form_canonical_keystring(name) - # FIXME; transfer the old value for combos etc. - if cname not in self.options: - self.options[cname] = value_object - def get_value_object_for(self, key): key = self.ensure_key(key) potential = self.options.get(key, None) @@ -751,9 +745,15 @@ def add_system_option_internal(self, key: T.Union[OptionKey, str], valobj: 'User assert isinstance(valobj, UserOption) if key not in self.options: self.options[key] = valobj + pval = self.pending_project_options.pop(key, None) + if pval is not None: + self.set_option(key.name, key.subproject, pval) + def add_compiler_option(self, language: str, key: T.Union[OptionKey, str], valobj: 'UserOption[T.Any]'): key = self.ensure_key(key) + if key.name == 'cpp_eh': + pass if not key.name.startswith(language + '_'): raise MesonException(f'Internal error: all compiler option names must start with language prefix. ({key.name} vs {language}_)') self.add_system_option(key, valobj) @@ -764,6 +764,9 @@ def add_project_option(self, key: OptionKey, valobj: 'UserOption[T.Any]'): assert key.subproject is not None self.options[key] = valobj self.project_options.add(key) + pval = self.pending_project_options.pop(key, None) + if pval is not None: + self.set_option(key.name, key.subproject, pval) def add_module_option(self, modulename: str, key: T.Union[OptionKey, str], valobj: 'UserOption[T.Any]'): key = self.ensure_key(key) @@ -948,7 +951,7 @@ def set_from_top_level_project_call(self, project_default_options, cmd_line_opti #else: # self.pending_project_options[key] = valstr for keystr, valstr in project_default_options.items(): - key = self.ensure_key(keystr) + key = OptionKey.from_string(keystr) if key.subproject is not None: self.pending_project_options[key] = valstr elif key in self.options: