interpreter|build: Pass just the executable down to Generator

This requires that the interpreter has done the validation, which it now
does at all callsites. This simplifies the Generator initializer.
pull/8822/head
Dylan Baker 4 years ago
parent 2ac9b32391
commit d2c1ab40a0
  1. 9
      mesonbuild/build.py
  2. 6
      mesonbuild/interpreter/interpreter.py
  3. 6
      mesonbuild/modules/qt.py

@ -1498,12 +1498,7 @@ You probably should put it in link_with instead.''')
return
class Generator:
def __init__(self, args, kwargs):
if len(args) != 1:
raise InvalidArguments('Generator requires exactly one positional argument: the executable')
exe = unholder(args[0])
if not isinstance(exe, (Executable, programs.ExternalProgram)):
raise InvalidArguments('First generator argument must be an executable.')
def __init__(self, exe: T.Union['Executable', programs.ExternalProgram], kwargs):
self.exe = exe
self.depfile = None
self.capture = False
@ -1514,7 +1509,7 @@ class Generator:
repr_str = "<{0}: {1}>"
return repr_str.format(self.__class__.__name__, self.exe)
def get_exe(self):
def get_exe(self) -> T.Union['Executable', programs.ExternalProgram]:
return self.exe
def process_kwargs(self, kwargs):

@ -1954,8 +1954,10 @@ 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: mparser.FunctionNode, args, kwargs) -> GeneratorHolder:
gen = build.Generator(args, kwargs)
@typed_pos_args('generator', (ExecutableHolder, ExternalProgramHolder))
def func_generator(self, node: mparser.FunctionNode, args: T.Tuple[T.Union[ExecutableHolder, ExternalProgramHolder]],
kwargs) -> GeneratorHolder:
gen = build.Generator(args[0].held_object, kwargs)
holder = GeneratorHolder(self, gen, self)
self.generators.append(holder)
return holder

@ -348,7 +348,7 @@ class QtBaseModule(ExtensionModule):
'output': 'ui_@BASENAME@.h',
'arguments': kwargs['extra_args'] + ['-o', '@OUTPUT@', '@INPUT@']}
# TODO: This generator isn't added to the generator list in the Interpreter
gen = build.Generator([self.uic], ui_kwargs) # type: ignore
gen = build.Generator(self.uic, ui_kwargs) # type: ignore
out = gen.process_files(f'Qt{self.qt_version} ui', kwargs['sources'], state)
return ModuleReturnValue(out, [out])
@ -384,12 +384,12 @@ class QtBaseModule(ExtensionModule):
if kwargs['headers']:
moc_kwargs = {'output': 'moc_@BASENAME@.cpp',
'arguments': arguments}
moc_gen = build.Generator([self.moc], moc_kwargs) # type: ignore
moc_gen = build.Generator(self.moc, moc_kwargs) # type: ignore
output.append(moc_gen.process_files(f'Qt{self.qt_version} moc header', kwargs['headers'], state))
if kwargs['sources']:
moc_kwargs = {'output': '@BASENAME@.moc',
'arguments': arguments}
moc_gen = build.Generator([self.moc], moc_kwargs) # type: ignore
moc_gen = build.Generator(self.moc, moc_kwargs) # type: ignore
output.append(moc_gen.process_files(f'Qt{self.qt_version} moc source', kwargs['sources'], state))
return ModuleReturnValue(output, [output])

Loading…
Cancel
Save