aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-11-13 21:17:41 +0200
committerGitHub <noreply@github.com>2017-11-13 21:17:41 +0200
commit897fd0bd169a5333b8b15af6b6e102ab53fe5cdf (patch)
tree75741d961acab948ee9671e9d152e71f5f9c5f35
parent69bd87a71624e2e665c3d43d765a3c5fb1313c96 (diff)
parent875b3bbbe46bc9a04f95e305e22380dc8a60af39 (diff)
downloadmeson-897fd0bd169a5333b8b15af6b6e102ab53fe5cdf.zip
meson-897fd0bd169a5333b8b15af6b6e102ab53fe5cdf.tar.gz
meson-897fd0bd169a5333b8b15af6b6e102ab53fe5cdf.tar.bz2
Merge pull request #2579 from thillux/master
Qt5-Module: add `name` option to rcc
-rw-r--r--mesonbuild/modules/qt.py24
-rw-r--r--test cases/frameworks/4 qt/main.cpp19
-rw-r--r--test cases/frameworks/4 qt/mainWindow.ui24
-rw-r--r--test cases/frameworks/4 qt/meson.build17
4 files changed, 69 insertions, 15 deletions
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index 5800e5c..285169b 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -101,17 +101,25 @@ class QtBaseModule:
qrc_deps = []
for i in rcc_files:
qrc_deps += self.parse_qrc(state, i)
+ # custom output name set? -> one output file, multiple otherwise
if len(args) > 0:
name = args[0]
+ rcc_kwargs = {'input': rcc_files,
+ 'output': name + '.cpp',
+ 'command': [self.rcc, '-name', name, '-o', '@OUTPUT@', '@INPUT@'],
+ 'depend_files': qrc_deps}
+ res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
+ sources.append(res_target)
else:
- basename = os.path.split(rcc_files[0])[1]
- name = 'qt' + str(self.qt_version) + '-' + basename.replace('.', '_')
- rcc_kwargs = {'input': rcc_files,
- 'output': name + '.cpp',
- 'command': [self.rcc, '-o', '@OUTPUT@', '@INPUT@'],
- 'depend_files': qrc_deps}
- res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
- sources.append(res_target)
+ for rcc_file in rcc_files:
+ basename = os.path.split(rcc_file)[1]
+ name = 'qt' + str(self.qt_version) + '-' + basename.replace('.', '_')
+ rcc_kwargs = {'input': rcc_file,
+ 'output': name + '.cpp',
+ 'command': [self.rcc, '-name', '@BASENAME@', '-o', '@OUTPUT@', '@INPUT@'],
+ 'depend_files': qrc_deps}
+ res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
+ sources.append(res_target)
if len(ui_files) > 0:
if not self.uic.found():
raise MesonException(err_msg.format('UIC', 'uic-qt' + self.qt_version))
diff --git a/test cases/frameworks/4 qt/main.cpp b/test cases/frameworks/4 qt/main.cpp
index 4c257a4..388467e 100644
--- a/test cases/frameworks/4 qt/main.cpp
+++ b/test cases/frameworks/4 qt/main.cpp
@@ -2,6 +2,10 @@
#include "mainWindow.h"
int main(int argc, char **argv) {
+ #ifndef UNITY_BUILD
+ Q_INIT_RESOURCE(stuff);
+ Q_INIT_RESOURCE(stuff2);
+ #endif
QApplication app(argc, argv);
MainWindow *win = new MainWindow();
QImage qi(":/thing.png");
@@ -13,7 +17,20 @@ int main(int argc, char **argv) {
return 1;
}
win->setWindowTitle("Meson Qt5 build test");
-
+ QLabel *label_stuff = win->findChild<QLabel *>("label_stuff");
+ if(label_stuff == nullptr) {
+ return 1;
+ }
+ int w = label_stuff->width();
+ int h = label_stuff->height();
+ label_stuff->setPixmap(QPixmap::fromImage(qi).scaled(w,h,Qt::KeepAspectRatio));
+ QLabel *label_stuff2 = win->findChild<QLabel *>("label_stuff2");
+ if(label_stuff2 == nullptr) {
+ return 1;
+ }
+ w = label_stuff2->width();
+ h = label_stuff2->height();
+ label_stuff2->setPixmap(QPixmap::fromImage(qi2).scaled(w,h,Qt::KeepAspectRatio));
win->show();
return app.exec();
return 0;
diff --git a/test cases/frameworks/4 qt/mainWindow.ui b/test cases/frameworks/4 qt/mainWindow.ui
index 2eb226a..c01b8bf 100644
--- a/test cases/frameworks/4 qt/mainWindow.ui
+++ b/test cases/frameworks/4 qt/mainWindow.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>270</width>
- <height>115</height>
+ <width>260</width>
+ <height>313</height>
</rect>
</property>
<property name="windowTitle">
@@ -27,6 +27,26 @@
<string>I am a button</string>
</property>
</widget>
+ <widget class="QLabel" name="label_stuff">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>112</y>
+ <width>241</width>
+ <height>91</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_stuff2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>212</y>
+ <width>241</width>
+ <height>91</height>
+ </rect>
+ </property>
+ </widget>
</widget>
</widget>
<resources/>
diff --git a/test cases/frameworks/4 qt/meson.build b/test cases/frameworks/4 qt/meson.build
index b817228..374707a 100644
--- a/test cases/frameworks/4 qt/meson.build
+++ b/test cases/frameworks/4 qt/meson.build
@@ -35,17 +35,26 @@ foreach qt : ['qt4', 'qt5']
prep = qtmodule.preprocess(
moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use.
ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol.
- qresources : ['stuff.qrc', 'stuff2.qrc'], # Resource file for rcc compiler.
method : get_option('method')
)
+ # Resource file(s) for rcc compiler
+ extra_cpp_args = []
+ if meson.is_unity()
+ extra_cpp_args += '-DUNITY_BUILD'
+ prep_rcc = qtmodule.preprocess(qt + '_unity_ressource', qresources : ['stuff.qrc', 'stuff2.qrc'], method : get_option('method'))
+ else
+ prep_rcc = qtmodule.preprocess(qresources : ['stuff.qrc', 'stuff2.qrc'], method : get_option('method'))
+ endif
+
# Test that setting a unique name with a positional argument works
- qtmodule.preprocess(qt + 'teststuff', qresources : ['stuff.qrc'], method : get_option('method'))
+ qtmodule.preprocess(qt + 'teststuff', qresources : ['stuff.qrc', 'stuff2.qrc'], method : get_option('method'))
qexe = executable(qt + 'app',
sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing.
- prep],
- dependencies : qtdep)
+ prep, prep_rcc],
+ dependencies : qtdep,
+ cpp_args: extra_cpp_args)
# We need a console test application because some test environments
# do not have an X server.