aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-06-01 20:48:35 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-06-15 12:48:53 -0700
commitd2c1ab40a0c94209d8e13886f3c7d697d30f2507 (patch)
treeb1d1d6600aaea3942e001036ad8504cc34f09ad1
parent2ac9b323918e8c61c4707fbd79d45cf1c6eecfd0 (diff)
downloadmeson-d2c1ab40a0c94209d8e13886f3c7d697d30f2507.zip
meson-d2c1ab40a0c94209d8e13886f3c7d697d30f2507.tar.gz
meson-d2c1ab40a0c94209d8e13886f3c7d697d30f2507.tar.bz2
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.
-rw-r--r--mesonbuild/build.py9
-rw-r--r--mesonbuild/interpreter/interpreter.py6
-rw-r--r--mesonbuild/modules/qt.py6
3 files changed, 9 insertions, 12 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index a685664..c401bd2 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.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):
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index cb513f7..3c69edf 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -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
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index 297ef09..76cc4db 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -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])