aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/qt.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-06-01 13:57:39 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-06-15 12:35:15 -0700
commited06ae3db1ee56053663a812bdcc665c92e44cc6 (patch)
treee25afd5e38875d44914a1b8a5ba65cce82e3e3a0 /mesonbuild/modules/qt.py
parentd27948b1dc11303274b622ed2fa4e765a09feb38 (diff)
downloadmeson-ed06ae3db1ee56053663a812bdcc665c92e44cc6.zip
meson-ed06ae3db1ee56053663a812bdcc665c92e44cc6.tar.gz
meson-ed06ae3db1ee56053663a812bdcc665c92e44cc6.tar.bz2
modules/qt: Dispatch the preprocess method to the compile_resources method
Which removes code duplication and makes our testing better
Diffstat (limited to 'mesonbuild/modules/qt.py')
-rw-r--r--mesonbuild/modules/qt.py35
1 files changed, 5 insertions, 30 deletions
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index 52fb2c3..d25c127 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -212,7 +212,7 @@ class QtBaseModule(ExtensionModule):
KwargInfo('extra_args', ContainerTypeInfo(list, str), listify=True),
KwargInfo('method', str, default='auto')
)
- def compile_resources(self, state: 'ModuleState', args: T.Tuple, kwargs: 'ResourceCompilerKwArgs'):
+ def compile_resources(self, state: 'ModuleState', args: T.Tuple, kwargs: 'ResourceCompilerKwArgs') -> ModuleReturnValue:
"""Compile Qt resources files.
Uses CustomTargets to generate .cpp files from .qrc files.
@@ -288,39 +288,14 @@ class QtBaseModule(ExtensionModule):
"please check your qt{2} installation"
if (moc_headers or moc_sources) and not self.moc.found():
raise MesonException(err_msg.format('MOC', f'moc-qt{self.qt_version}', self.qt_version))
+
if rcc_files:
- if not self.rcc.found():
- raise MesonException(err_msg.format('RCC', f'rcc-qt{self.qt_version}', self.qt_version))
# custom output name set? -> one output file, multiple otherwise
rcc_kwargs: 'ResourceCompilerKwArgs' = {'sources': rcc_files, 'extra_args': rcc_extra_arguments, 'method': method}
if args:
- qrc_deps = []
- for i in rcc_files:
- qrc_deps += self._parse_qrc_deps(state, i)
- name = args[0]
- rcc_kwargs = {'input': rcc_files,
- 'output': name + '.cpp',
- 'command': [self.rcc, '-name', name, '-o', '@OUTPUT@', rcc_extra_arguments, '@INPUT@'],
- 'depend_files': qrc_deps}
- res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
- sources.append(res_target)
- else:
- for rcc_file in rcc_files:
- qrc_deps = self._parse_qrc_deps(state, rcc_file)
- if type(rcc_file) is str:
- basename = os.path.basename(rcc_file)
- elif type(rcc_file) is File:
- basename = os.path.basename(rcc_file.fname)
- name = 'qt' + str(self.qt_version) + '-' + basename.replace('.', '_')
- rcc_kwargs = {'input': rcc_file,
- 'output': name + '.cpp',
- 'command': [self.rcc, '-name', '@BASENAME@', '-o', '@OUTPUT@', rcc_extra_arguments, '@INPUT@'],
- 'depend_files': qrc_deps}
- if self.rcc_supports_depfiles:
- rcc_kwargs['depfile'] = name + '.d'
- rcc_kwargs['command'] += ['--depfile', '@DEPFILE@']
- res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
- sources.append(res_target)
+ rcc_kwargs['name'] = args[0]
+ sources.extend(self.compile_resources(state, tuple(), rcc_kwargs).return_value)
+
if ui_files:
if not self.uic.found():
raise MesonException(err_msg.format('UIC', f'uic-qt{self.qt_version}', self.qt_version))