diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index 783387df1e29..0887fa2ebab1 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -49,7 +49,7 @@ if T.TYPE_CHECKING: from .visitor import AstVisitor from ..interpreter import Interpreter - from ..interpreterbase import TYPE_nkwargs, TYPE_var + from ..interpreterbase import SubProject, TYPE_nkwargs, TYPE_var from ..mparser import ( AndNode, ComparisonNode, @@ -84,8 +84,9 @@ class MockRunTarget(MesonInterpreterObject): _T = T.TypeVar('_T') _V = T.TypeVar('_V') + class AstInterpreter(InterpreterBase): - def __init__(self, source_root: str, subdir: str, subproject: str, visitors: T.Optional[T.List[AstVisitor]] = None): + def __init__(self, source_root: str, subdir: str, subproject: SubProject, visitors: T.Optional[T.List[AstVisitor]] = None): super().__init__(source_root, subdir, subproject) self.visitors = visitors if visitors is not None else [] self.processed_buildfiles: T.Set[str] = set() diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 49e58f43d101..095f30c14fd1 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -14,7 +14,7 @@ from .. import coredata as cdata from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary from ..compilers import detect_compiler_for -from ..interpreterbase import InvalidArguments +from ..interpreterbase import InvalidArguments, SubProject from ..mesonlib import MachineChoice, OptionKey from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, BaseStringNode from .interpreter import AstInterpreter @@ -51,7 +51,7 @@ def __init__(self, backend: str, visitors: T.Optional[T.List[AstVisitor]] = None, cross_file: T.Optional[str] = None, - subproject: str = '', + subproject: SubProject = SubProject(''), subproject_dir: str = 'subprojects', env: T.Optional[environment.Environment] = None): visitors = visitors if visitors is not None else [] @@ -126,7 +126,7 @@ def func_project(self, node: BaseNode, args: T.List[TYPE_var], kwargs: T.Dict[st if os.path.isdir(subprojects_dir): for i in os.listdir(subprojects_dir): if os.path.isdir(os.path.join(subprojects_dir, i)): - self.do_subproject(i) + self.do_subproject(SubProject(i)) self.coredata.init_backend_options(self.backend) options = {k: v for k, v in self.environment.options.items() if k.is_backend()} @@ -135,7 +135,7 @@ def func_project(self, node: BaseNode, args: T.List[TYPE_var], kwargs: T.Dict[st self._add_languages(proj_langs, True, MachineChoice.HOST) self._add_languages(proj_langs, True, MachineChoice.BUILD) - def do_subproject(self, dirname: str) -> None: + def do_subproject(self, dirname: SubProject) -> None: subproject_dir_abs = os.path.join(self.environment.get_source_dir(), self.subproject_dir) subpr = os.path.join(subproject_dir_abs, dirname) try: