From 5316c7df62926d49149053b5d8ccfb4a0042856e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 6 Oct 2021 10:31:37 -0400 Subject: [PATCH] ModuleState: Add wrapper to get option --- mesonbuild/modules/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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