diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 74fe145d2..d09fa865c 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -18,13 +18,14 @@ import os import typing as T from .. import build, mesonlib -from ..mesonlib import relpath, HoldableObject +from ..mesonlib import relpath, HoldableObject, MachineChoice, OptionKey from ..interpreterbase.decorators import noKwargs, noPosargs if T.TYPE_CHECKING: from ..interpreter import Interpreter from ..interpreterbase import TYPE_var, TYPE_kwargs from ..programs import ExternalProgram + from ..wrap import WrapMode class ModuleState: """Object passed to all module methods. @@ -102,6 +103,12 @@ class ModuleState: # TODO: Use interpreter internal API, but we need to go through @typed_kwargs self._interpreter.func_test(self.current_node, args, kwargs) + def get_option(self, name: str, subproject: str = '', + machine: MachineChoice = MachineChoice.HOST, + lang: T.Optional[str] = None, + module: T.Optional[str] = None) -> T.Union[str, int, bool, 'WrapMode']: + return self.environment.coredata.get_option(mesonlib.OptionKey(name, subproject, machine, lang, module)) + class ModuleObject(HoldableObject): """Base class for all objects returned by modules