aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-07-21 11:12:26 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-08-18 19:47:07 -0700
commita7f3703440b5aaba0ae1bded8629a3af98ea7e82 (patch)
treebb4e909789fdcf6accac4176529df794bd124af9
parenta16335a958774437c9c1ab58c55ba303b2b9a07d (diff)
downloadmeson-a7f3703440b5aaba0ae1bded8629a3af98ea7e82.zip
meson-a7f3703440b5aaba0ae1bded8629a3af98ea7e82.tar.gz
meson-a7f3703440b5aaba0ae1bded8629a3af98ea7e82.tar.bz2
modules/qt: Allow using generated sources for compile_translations ts_files
-rw-r--r--docs/markdown/_include_qt_base.md4
-rw-r--r--mesonbuild/modules/qt.py15
2 files changed, 14 insertions, 5 deletions
diff --git a/docs/markdown/_include_qt_base.md b/docs/markdown/_include_qt_base.md
index db0cc48..db8667c 100644
--- a/docs/markdown/_include_qt_base.md
+++ b/docs/markdown/_include_qt_base.md
@@ -85,7 +85,9 @@ It returns an array of targets and sources to pass to a compilation target.
This method generates the necessary targets to build translation files with
lrelease, it takes no positional arguments, and the following keyword arguments:
- - `ts_files` (str | File)[], the list of input translation files produced by Qt's lupdate tool.
+ - `ts_files` (File | string | custom_target | custom_target index | generator_output)[]:
+ the list of input translation files produced by Qt's lupdate tool.
+ *New in 0.60.0*: support for custom_target, custom_target_index, and generator_output.
- `install` bool: when true, this target is installed during the install step (optional).
- `install_dir` string: directory to install to (optional).
- `build_by_default` bool: when set to true, to have this target be built by
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