diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-05-25 22:29:58 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-05-25 22:29:58 +0300 |
commit | 6d01dec9e84437d2f4a2b6ce8e864a37be005d62 (patch) | |
tree | 72065e098421264b8f993f9c89ce33f973ba73cf | |
parent | 799b96f75337d2e02b29af0ac54ed5f599b2b06e (diff) | |
download | meson-optionlookup.zip meson-optionlookup.tar.gz meson-optionlookup.tar.bz2 |
Use toplevel key when sp-specific one does not exist.optionlookup
-rw-r--r-- | mesonbuild/coredata.py | 3 | ||||
-rw-r--r-- | mesonbuild/mesonlib/universal.py | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 49b84b9..bfa160b 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.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: diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index 318b365..fbb3a00 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -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.') |