diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 1a7d2fc45..cb513f753 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -267,7 +267,7 @@ class Interpreter(InterpreterBase): self.ast = ast self.sanity_check_ast() self.builtin.update({'meson': MesonMain(build, self)}) - self.generators = [] + self.generators: T.List['GeneratorHolder'] = [] self.processed_buildfiles = set() # type: T.Set[str] self.project_args_frozen = False self.global_args_frozen = False # implies self.project_args_frozen @@ -1954,10 +1954,11 @@ This will become a hard error in the future.''' % kwargs['input'], location=self @permittedKwargs({'arguments', 'output', 'depends', 'depfile', 'capture', 'preserve_path_from'}) - def func_generator(self, node, args, kwargs): - gen = GeneratorHolder(self, args, kwargs) - self.generators.append(gen) - return gen + def func_generator(self, node: mparser.FunctionNode, args, kwargs) -> GeneratorHolder: + gen = build.Generator(args, kwargs) + holder = GeneratorHolder(self, gen, self) + self.generators.append(holder) + return holder @typed_pos_args('benchmark', str, (ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File)) @typed_kwargs('benchmark', *TEST_KWARGS) diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py index f7c84667b..8913b21ac 100644 --- a/mesonbuild/interpreter/interpreterobjects.py +++ b/mesonbuild/interpreter/interpreterobjects.py @@ -621,11 +621,12 @@ class ExternalLibraryHolder(InterpreterObject, ObjectHolder[ExternalLibrary]): return DependencyHolder(pdep, self.subproject) class GeneratorHolder(InterpreterObject, ObjectHolder[build.Generator]): + @FeatureNewKwargs('generator', '0.43.0', ['capture']) - def __init__(self, interp, args, kwargs): - self.interpreter = interp + def __init__(self, gen: 'build.Generator', interpreter: 'Interpreter'): InterpreterObject.__init__(self) - ObjectHolder.__init__(self, build.Generator(args, kwargs), interp.subproject) + ObjectHolder.__init__(self, gen, interpreter.subproject) + self.interpreter = interpreter self.methods.update({'process': self.process_method}) @FeatureNewKwargs('generator.process', '0.45.0', ['preserve_path_from'])