Skip to content

Commit

Permalink
Fix pending options.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Jul 23, 2024
1 parent 499b212 commit b6023ce
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions mesonbuild/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b6023ce

Please sign in to comment.