interpreter: Do not create Generator in GeneratorHolder

This is an odd pattern, not the way most Holders work, and would be
problematic if a method wanted to return a Generator.
pull/8822/head
Dylan Baker 4 years ago
parent d064466e8b
commit 2ac9b32391
  1. 11
      mesonbuild/interpreter/interpreter.py
  2. 7
      mesonbuild/interpreter/interpreterobjects.py

@ -267,7 +267,7 @@ class Interpreter(InterpreterBase):
self.ast = ast self.ast = ast
self.sanity_check_ast() self.sanity_check_ast()
self.builtin.update({'meson': MesonMain(build, self)}) self.builtin.update({'meson': MesonMain(build, self)})
self.generators = [] self.generators: T.List['GeneratorHolder'] = []
self.processed_buildfiles = set() # type: T.Set[str] self.processed_buildfiles = set() # type: T.Set[str]
self.project_args_frozen = False self.project_args_frozen = False
self.global_args_frozen = False # implies self.project_args_frozen 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', @permittedKwargs({'arguments', 'output', 'depends', 'depfile', 'capture',
'preserve_path_from'}) 'preserve_path_from'})
def func_generator(self, node, args, kwargs): def func_generator(self, node: mparser.FunctionNode, args, kwargs) -> GeneratorHolder:
gen = GeneratorHolder(self, args, kwargs) gen = build.Generator(args, kwargs)
self.generators.append(gen) holder = GeneratorHolder(self, gen, self)
return gen self.generators.append(holder)
return holder
@typed_pos_args('benchmark', str, (ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File)) @typed_pos_args('benchmark', str, (ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File))
@typed_kwargs('benchmark', *TEST_KWARGS) @typed_kwargs('benchmark', *TEST_KWARGS)

@ -621,11 +621,12 @@ class ExternalLibraryHolder(InterpreterObject, ObjectHolder[ExternalLibrary]):
return DependencyHolder(pdep, self.subproject) return DependencyHolder(pdep, self.subproject)
class GeneratorHolder(InterpreterObject, ObjectHolder[build.Generator]): class GeneratorHolder(InterpreterObject, ObjectHolder[build.Generator]):
@FeatureNewKwargs('generator', '0.43.0', ['capture']) @FeatureNewKwargs('generator', '0.43.0', ['capture'])
def __init__(self, interp, args, kwargs): def __init__(self, gen: 'build.Generator', interpreter: 'Interpreter'):
self.interpreter = interp
InterpreterObject.__init__(self) 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}) self.methods.update({'process': self.process_method})
@FeatureNewKwargs('generator.process', '0.45.0', ['preserve_path_from']) @FeatureNewKwargs('generator.process', '0.45.0', ['preserve_path_from'])

Loading…
Cancel
Save