modules: add ModuleState API to check whether an option was user-specified

Needed to check exclusivity of module options.
pull/9788/head
Eli Schwartz 3 years ago
parent 5d64a15be7
commit e8375d20a9
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 7
      mesonbuild/modules/__init__.py

@ -103,6 +103,13 @@ class ModuleState:
module: T.Optional[str] = None) -> T.Union[str, int, bool, 'WrapMode']: module: T.Optional[str] = None) -> T.Union[str, int, bool, 'WrapMode']:
return self.environment.coredata.get_option(mesonlib.OptionKey(name, subproject, machine, lang, module)) return self.environment.coredata.get_option(mesonlib.OptionKey(name, subproject, machine, lang, module))
def is_user_defined_option(self, name: str, subproject: str = '',
machine: MachineChoice = MachineChoice.HOST,
lang: T.Optional[str] = None,
module: T.Optional[str] = None) -> bool:
key = mesonlib.OptionKey(name, subproject, machine, lang, module)
return key in self._interpreter.user_defined_options.cmd_line_options
class ModuleObject(HoldableObject): class ModuleObject(HoldableObject):
"""Base class for all objects returned by modules """Base class for all objects returned by modules

Loading…
Cancel
Save