From 11f96380351a88059ec55f1070fdebc1b1033117 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 19 Jan 2022 12:42:25 -0800 Subject: build: replace kwargs in CustomTarget initializer Because we don't want to pass the Interpreter kwargs into the build layer. This turned out to be a mega commit, as there's really on elegant way to make this change in an incremental way. On the nice side, mypy made this change super easy, as nearly all of the calls to `CustomTarget` are fully type checked! It also turns out that we're not handling install_tags in custom_target correctly, since we're not converting the boolean values into Optional values! --- mesonbuild/modules/qt.py | 59 +++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'mesonbuild/modules/qt.py') diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index cf97368..37072b4 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -328,14 +328,16 @@ class QtBaseModule(ExtensionModule): for s in sources: qrc_deps.extend(self._parse_qrc_deps(state, s)) - rcc_kwargs: T.Dict[str, T.Any] = { # TODO: if CustomTarget had typing information we could use that here... - 'input': sources, - 'output': name + '.cpp', - 'command': self.tools['rcc'].get_command() + ['-name', name, '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS, - 'depend_files': qrc_deps, - 'depfile': f'{name}.d', - } - res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs) + res_target = build.CustomTarget( + name, + state.subdir, + state.subproject, + self.tools['rcc'].get_command() + ['-name', name, '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS, + sources, + [f'{name}.cpp'], + depend_files=qrc_deps, + depfile=f'{name}.d', + ) targets.append(res_target) else: for rcc_file in sources: @@ -345,14 +347,16 @@ class QtBaseModule(ExtensionModule): else: basename = os.path.basename(rcc_file.fname) name = f'qt{self.qt_version}-{basename.replace(".", "_")}' - rcc_kwargs = { - 'input': rcc_file, - 'output': f'{name}.cpp', - 'command': self.tools['rcc'].get_command() + ['-name', '@BASENAME@', '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS, - 'depend_files': qrc_deps, - 'depfile': f'{name}.d', - } - res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs) + res_target = build.CustomTarget( + name, + state.subdir, + state.subproject, + self.tools['rcc'].get_command() + ['-name', '@BASENAME@', '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS, + [rcc_file], + [f'{name}.cpp'], + depend_files=qrc_deps, + depfile=f'{name}.d', + ) targets.append(res_target) return targets @@ -570,16 +574,19 @@ class QtBaseModule(ExtensionModule): ts = os.path.basename(ts) else: outdir = state.subdir - cmd = [self.tools['lrelease'], '@INPUT@', '-qm', '@OUTPUT@'] - lrelease_kwargs: T.Dict[str, T.Any] = { - 'output': '@BASENAME@.qm', - 'input': ts, - 'install': kwargs['install'], - 'install_dir': install_dir or [], - 'install_tag': 'i18n', - 'build_by_default': kwargs['build_by_default'], - 'command': cmd} - lrelease_target = build.CustomTarget(f'qt{self.qt_version}-compile-{ts}', outdir, state.subproject, lrelease_kwargs) + cmd: T.List[T.Union[ExternalProgram, str]] = [self.tools['lrelease'], '@INPUT@', '-qm', '@OUTPUT@'] + lrelease_target = build.CustomTarget( + f'qt{self.qt_version}-compile-{ts}', + outdir, + state.subproject, + cmd, + [ts], + ['@BASENAME@.qm'], + install=kwargs['install'], + install_dir=install_dir, + install_tag=['i18n'], + build_by_default=kwargs['build_by_default'], + ) translations.append(lrelease_target) if qresource: return ModuleReturnValue(results.return_value[0], [results.new_objects, translations]) -- cgit v1.1