diff options
Diffstat (limited to 'mesonbuild/ast')
| -rw-r--r-- | mesonbuild/ast/interpreter.py | 10 | ||||
| -rw-r--r-- | mesonbuild/ast/introspection.py | 20 |
2 files changed, 20 insertions, 10 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index b462c7e87..cde578a9a 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -65,6 +65,16 @@ if T.TYPE_CHECKING: _T = T.TypeVar('_T') _V = T.TypeVar('_V') +# `IntrospectionDependency` is to the `IntrospectionInterpreter` what `Dependency` is to the normal `Interpreter`. +@dataclass +class IntrospectionDependency(MesonInterpreterObject): + name: str + required: T.Union[bool] + version: T.List[str] + has_fallback: bool + conditional: bool + node: FunctionNode + # `IntrospectionBuildTarget` is to the `IntrospectionInterpreter` what `BuildTarget` is to the normal `Interpreter`. @dataclass class IntrospectionBuildTarget(MesonInterpreterObject): diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 316b26175..88ca72c84 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -16,7 +16,7 @@ from ..interpreterbase import InvalidArguments, SubProject from ..mesonlib import MachineChoice from ..options import OptionKey from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode -from .interpreter import AstInterpreter, IntrospectionBuildTarget +from .interpreter import AstInterpreter, IntrospectionBuildTarget, IntrospectionDependency if T.TYPE_CHECKING: from ..build import BuildTarget @@ -66,7 +66,7 @@ class IntrospectionInterpreter(AstInterpreter): self.default_options = {OptionKey('backend'): self.backend} self.project_data: T.Dict[str, T.Any] = {} self.targets: T.List[IntrospectionBuildTarget] = [] - self.dependencies: T.List[T.Dict[str, T.Any]] = [] + self.dependencies: T.List[IntrospectionDependency] = [] self.project_node: BaseNode = None self.funcs.update({ @@ -225,14 +225,14 @@ class IntrospectionInterpreter(AstInterpreter): required = required.value if not isinstance(required, bool): required = False - self.dependencies += [{ - 'name': name, - 'required': required, - 'version': version, - 'has_fallback': has_fallback, - 'conditional': node.condition_level > 0, - 'node': node - }] + newdep = IntrospectionDependency( + name=name, + required=required, + version=version, + has_fallback=has_fallback, + conditional=node.condition_level > 0, + node=node) + self.dependencies += [newdep] def build_target(self, node: BaseNode, args: T.List[TYPE_var], kwargs_raw: T.Dict[str, TYPE_var], targetclass: T.Type[BuildTarget]) -> IntrospectionBuildTarget: args = self.flatten_args(args) |
