aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-12-14 12:43:08 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-12-15 09:40:16 +0000
commit193f3f02aae324ba7273e368b528b437da46caac (patch)
tree39c436f0a6ca7c7b3fcfd71febc4dfb941c11ed2
parent8eaef2035c2af7205e823eb9503721c29b0136a1 (diff)
Fix qtquickcompiler support for QML files in subdirectories
The input to the look-up function is a relative file path, not necessarily just a file name as the code assumed. Task-number: QBS-1261 Change-Id: Iaad4629ea92f327edc3dca7f012d82a00669994f Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r--changelogs/changes-1.10.1.md1
-rw-r--r--src/lib/qtprofilesetup/templates/quick.qbs6
-rw-r--r--tests/auto/blackbox/testdata-qt/quick-compiler/main.cpp18
-rw-r--r--tests/auto/blackbox/testdata-qt/quick-compiler/qml.qrc5
-rw-r--r--tests/auto/blackbox/testdata-qt/quick-compiler/qml/subdir/test.qml5
-rw-r--r--tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs23
-rw-r--r--tests/auto/blackbox/tst_blackboxqt.cpp12
-rw-r--r--tests/auto/blackbox/tst_blackboxqt.h1
8 files changed, 68 insertions, 3 deletions
diff --git a/changelogs/changes-1.10.1.md b/changelogs/changes-1.10.1.md
index 8e6773490..e23d39c29 100644
--- a/changelogs/changes-1.10.1.md
+++ b/changelogs/changes-1.10.1.md
@@ -1,4 +1,5 @@
# Important bugfixes
* Fix crash when the "original" value is misused (QBS-1255).
+* Fix qtquickcompiler support for qml files in subdirectories (QBS-1261).
* Fix GCC support for "bare metal" systems (QBS-1263).
* Fix race condition when creating Inno Setup, NSIS, or WiX installers.
diff --git a/src/lib/qtprofilesetup/templates/quick.qbs b/src/lib/qtprofilesetup/templates/quick.qbs
index 5358a684f..8079c9af9 100644
--- a/src/lib/qtprofilesetup/templates/quick.qbs
+++ b/src/lib/qtprofilesetup/templates/quick.qbs
@@ -143,15 +143,15 @@ QtModule {
var cmd;
var loaderFlags = [];
- function findOutput(fileName) {
+ function findOutput(relFilePath) {
for (var k in outputs) {
for (var i in outputs[k]) {
- if (outputs[k][i].fileName === fileName)
+ if (outputs[k][i].filePath.endsWith(relFilePath))
return outputs[k][i];
}
}
throw new Error("Qt Quick compiler rule: Cannot find output artifact "
- + fileName + ".");
+ + relFilePath + ".");
}
infos.forEach(function (info) {
diff --git a/tests/auto/blackbox/testdata-qt/quick-compiler/main.cpp b/tests/auto/blackbox/testdata-qt/quick-compiler/main.cpp
new file mode 100644
index 000000000..1fe8944f3
--- /dev/null
+++ b/tests/auto/blackbox/testdata-qt/quick-compiler/main.cpp
@@ -0,0 +1,18 @@
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+#if defined(Q_OS_WIN)
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
+
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/qml/subdir/test.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+
+ return app.exec();
+}
diff --git a/tests/auto/blackbox/testdata-qt/quick-compiler/qml.qrc b/tests/auto/blackbox/testdata-qt/quick-compiler/qml.qrc
new file mode 100644
index 000000000..12ede6046
--- /dev/null
+++ b/tests/auto/blackbox/testdata-qt/quick-compiler/qml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/subdir/test.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/blackbox/testdata-qt/quick-compiler/qml/subdir/test.qml b/tests/auto/blackbox/testdata-qt/quick-compiler/qml/subdir/test.qml
new file mode 100644
index 000000000..9c36e13c5
--- /dev/null
+++ b/tests/auto/blackbox/testdata-qt/quick-compiler/qml/subdir/test.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Item {
+
+}
diff --git a/tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs b/tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs
new file mode 100644
index 000000000..372ee069b
--- /dev/null
+++ b/tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs
@@ -0,0 +1,23 @@
+import qbs
+
+CppApplication {
+ Depends { name: "Qt.quick" }
+
+ cpp.cxxLanguageVersion: "c++11"
+
+ Probe {
+ id: qtQuickCompilerProbe
+ property bool hasCompiler: Qt.quick.compilerAvailable
+ configure: {
+ if (hasCompiler)
+ console.info("compiler available");
+ else
+ console.info("compiler not available");
+ }
+ }
+
+ files: [
+ "main.cpp",
+ "qml.qrc",
+ ]
+}
diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp
index 501991a03..c21924b25 100644
--- a/tests/auto/blackbox/tst_blackboxqt.cpp
+++ b/tests/auto/blackbox/tst_blackboxqt.cpp
@@ -259,6 +259,18 @@ void TestBlackboxQt::qtKeywords()
QCOMPARE(runQbs(params), 0);
}
+void TestBlackboxQt::quickCompiler()
+{
+ QDir::setCurrent(testDataDir + "/quick-compiler");
+ QCOMPARE(runQbs(), 0);
+ const bool hasCompiler = m_qbsStdout.contains("compiler available");
+ const bool doesNotHaveCompiler = m_qbsStdout.contains("compiler not available");
+ QVERIFY2(hasCompiler || doesNotHaveCompiler, m_qbsStdout.constData());
+ QCOMPARE(m_qbsStdout.contains("compiling test_qml.cpp"), hasCompiler);
+ if (doesNotHaveCompiler)
+ QSKIP("qtquickcompiler not available");
+}
+
void TestBlackboxQt::qtScxml()
{
QDir::setCurrent(testDataDir + "/qtscxml");
diff --git a/tests/auto/blackbox/tst_blackboxqt.h b/tests/auto/blackbox/tst_blackboxqt.h
index 1a9d83e1e..90461c06b 100644
--- a/tests/auto/blackbox/tst_blackboxqt.h
+++ b/tests/auto/blackbox/tst_blackboxqt.h
@@ -56,6 +56,7 @@ private slots:
void qmlDebugging();
void qobjectInObjectiveCpp();
void qtKeywords();
+ void quickCompiler();
void qtScxml();
void removeMocHeaderFromFileList();
void staticQtPluginLinking();