Use toplevel key when sp-specific one does not exist.

optionlookup
Jussi Pakkanen 4 years ago
parent 799b96f753
commit 6d01dec9e8
  1. 3
      mesonbuild/coredata.py
  2. 5
      mesonbuild/mesonlib/universal.py

@ -582,6 +582,9 @@ class CoreData:
except KeyError:
pass
if key.subproject:
# Per-subproject option was not found, try the top level one.
return self.get_option(key.toplevel_key())
raise MesonException(f'Tried to get unknown builtin option {str(key)}')
def set_option(self, key: OptionKey, value) -> None:

@ -1976,6 +1976,11 @@ class OptionKey:
_type = _classify_argument(self)
object.__setattr__(self, 'type', _type)
def toplevel_key(self):
if not self.subproject:
raise RuntimeError("Internal error: tried to get top level option for a top level option.")
return OptionKey(self.name, '', self.machine, self.lang, self.type)
def __setattr__(self, key: str, value: T.Any) -> None:
raise AttributeError('OptionKey instances do not support mutation.')

Loading…
Cancel
Save