ModuleState: Add wrapper to get option

pull/9357/merge
Xavier Claessens 3 years ago committed by Eli Schwartz
parent 2628ce576c
commit 5316c7df62
  1. 9
      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

Loading…
Cancel
Save