[Qt module] Add File object support for generated or not qrc files

Added missing sub-folder test

Closes #3324

Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
pull/3326/head
Alexis Jeandet 7 years ago
parent 8efd940092
commit 0407fac59e
  1. 20
      mesonbuild/modules/qt.py
  2. 2
      test cases/frameworks/4 qt/meson.build
  3. 12
      test cases/frameworks/4 qt/subfolder/main.cpp
  4. 19
      test cases/frameworks/4 qt/subfolder/meson.build
  5. 6
      test cases/frameworks/4 qt/subfolder/resources/stuff4.qrc.in

@ -15,7 +15,7 @@
import os
from .. import mlog
from .. import build
from ..mesonlib import MesonException, Popen_safe, extract_as_list
from ..mesonlib import MesonException, Popen_safe, extract_as_list, File
from ..dependencies import Qt4Dependency, Qt5Dependency
import xml.etree.ElementTree as ET
from . import ModuleReturnValue, get_include_args
@ -71,16 +71,21 @@ class QtBaseModule:
mlog.log(' {}:'.format(compiler_name.lower()), mlog.red('NO'))
self.tools_detected = True
def parse_qrc(self, state, fname):
abspath = os.path.join(state.environment.source_dir, state.subdir, fname)
relative_part = os.path.dirname(fname)
def parse_qrc(self, state, rcc_file):
if type(rcc_file) is str:
abspath = os.path.join(state.environment.source_dir, state.subdir, rcc_file)
relative_part = os.path.dirname(rcc_file)
elif type(rcc_file) is File:
abspath = rcc_file.fname
relative_part = os.path.dirname(abspath)
try:
tree = ET.parse(abspath)
root = tree.getroot()
result = []
for child in root[0]:
if child.tag != 'file':
mlog.warning("malformed rcc file: ", os.path.join(state.subdir, fname))
mlog.warning("malformed rcc file: ", os.path.join(state.subdir, rcc_file))
break
else:
result.append(os.path.join(relative_part, child.text))
@ -116,7 +121,10 @@ class QtBaseModule:
sources.append(res_target)
else:
for rcc_file in rcc_files:
basename = os.path.basename(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',

@ -56,7 +56,7 @@ foreach qt : ['qt4', 'qt5']
endif
# Test that setting a unique name with a positional argument works
qtmodule.preprocess(qt + 'teststuff', qresources : ['stuff.qrc', 'stuff2.qrc'], method : get_option('method'))
qtmodule.preprocess(qt + 'teststuff', qresources : files(['stuff.qrc', 'stuff2.qrc']), method : get_option('method'))
qexe = executable(qt + 'app',
sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing.

@ -1,9 +1,17 @@
#include <QImage>
int main(int argc, char **argv) {
#ifndef UNITY_BUILD
Q_INIT_RESOURCE(stuff3);
QImage qi(":/thing.png");
if(qi.width() != 640) {
Q_INIT_RESOURCE(stuff4);
#endif
QImage img1(":/thing.png");
if(img1.width() != 640) {
return 1;
}
QImage img2(":/thing4.png");
if(img2.width() != 640) {
return 1;
}
return 0;

@ -1,4 +1,19 @@
cfg = configuration_data()
qresources = qtmodule.preprocess(qresources : 'resources/stuff3.qrc')
cfg.set('filepath', meson.current_source_dir()+'/../thing2.png')
rc_file = configure_file(
configuration : cfg,
input : 'resources/stuff4.qrc.in',
output : 'stuff4.qrc',
)
app = executable('subfolder', 'main.cpp', qresources, dependencies : qtdep)
extra_cpp_args = []
if meson.is_unity()
extra_cpp_args += '-DUNITY_BUILD'
qresources = qtmodule.preprocess(qt + '_subfolder_unity_ressource',qresources : ['resources/stuff3.qrc', rc_file])
else
qresources = qtmodule.preprocess(qresources : ['resources/stuff3.qrc', rc_file])
endif
app = executable('subfolder', 'main.cpp', qresources, dependencies : qtdep, cpp_args: extra_cpp_args)
test(qt + 'subfolder', app)

@ -0,0 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
<file alias="thing4.png">@filepath@</file>
</qresource>
</RCC>
Loading…
Cancel
Save