diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-07-21 11:12:26 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-08-18 19:47:07 -0700 |
commit | a7f3703440b5aaba0ae1bded8629a3af98ea7e82 (patch) | |
tree | bb4e909789fdcf6accac4176529df794bd124af9 /mesonbuild/modules/qt.py | |
parent | a16335a958774437c9c1ab58c55ba303b2b9a07d (diff) | |
download | meson-a7f3703440b5aaba0ae1bded8629a3af98ea7e82.zip meson-a7f3703440b5aaba0ae1bded8629a3af98ea7e82.tar.gz meson-a7f3703440b5aaba0ae1bded8629a3af98ea7e82.tar.bz2 |
modules/qt: Allow using generated sources for compile_translations ts_files
Diffstat (limited to 'mesonbuild/modules/qt.py')
-rw-r--r-- | mesonbuild/modules/qt.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 82a152e..9a1220f 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -93,7 +93,7 @@ if T.TYPE_CHECKING: method: str qresource: T.Optional[str] rcc_extra_arguments: T.List[str] - ts_files: T.List[str] + ts_files: T.List[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]] class QtBaseModule(ExtensionModule): @@ -514,10 +514,12 @@ class QtBaseModule(ExtensionModule): KwargInfo('method', str, default='auto'), KwargInfo('qresource', str, since='0.56.0'), KwargInfo('rcc_extra_arguments', ContainerTypeInfo(list, str), listify=True, default=[], since='0.56.0'), - KwargInfo('ts_files', ContainerTypeInfo(list, (str, File)), listify=True, default=[]), + KwargInfo('ts_files', ContainerTypeInfo(list, (str, File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)), listify=True, default=[]), ) def compile_translations(self, state: 'ModuleState', args: T.Tuple, kwargs: 'CompileTranslationsKwArgs') -> ModuleReturnValue: ts_files = kwargs['ts_files'] + if any(isinstance(s, (build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)) for s in ts_files): + FeatureNew.single_use('qt.compile_translations: custom_target or generator for "ts_files" keyword argument', '0.60.0', state.subproject) install_dir = kwargs['install_dir'] qresource = kwargs['qresource'] if qresource: @@ -546,6 +548,11 @@ class QtBaseModule(ExtensionModule): raise MesonException('qt.compile_translations: ' + self.lrelease.name + ' not found') if qresource: + # In this case we know that ts_files is always a List[str], as + # it's generated above and no ts_files are passed in. However, + # mypy can't figure that out so we use assert to assure it that + # what we're doing is safe + assert isinstance(ts, str), 'for mypy' outdir = os.path.dirname(os.path.normpath(os.path.join(state.subdir, ts))) ts = os.path.basename(ts) else: @@ -553,9 +560,9 @@ class QtBaseModule(ExtensionModule): cmd = [self.lrelease, '@INPUT@', '-qm', '@OUTPUT@'] lrelease_kwargs = {'output': '@BASENAME@.qm', 'input': ts, - 'install': kwargs.get('install', False), + 'install': kwargs['install'], 'install_tag': 'i18n', - 'build_by_default': kwargs.get('build_by_default', False), + 'build_by_default': kwargs['build_by_default'], 'command': cmd} if install_dir is not None: lrelease_kwargs['install_dir'] = install_dir |