diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-06-01 17:35:04 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-06-05 07:34:56 +0000 |
commit | 9c79f93d68baee8ed98e7cad81253f29e529a3a3 (patch) | |
tree | 91107f80bac3ceb57e82b81154765cad465ddecc | |
parent | b3e1e3e3b307e60924dcf3cf308488a362de88f0 (diff) |
Fix the qmlcachegen functionality
The qmlcache module was broken in an impressive number of ways:
- We forgot to adapt the Probe to a5cc49f2c6.
- The return value of the validate property is never evaluated;
you have to throw an error for it to have an effect.
- From 5.11 on, qmlcachegen does not support the
--target-architecture option anymore.
Task-number: QBS-1353
Change-Id: I770ddc18ad2519c1d5db83bee9634717b1768d67
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | src/lib/qtprofilesetup/templates/qmlcache.qbs | 26 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs | 10 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackboxqt.cpp | 6 |
3 files changed, 37 insertions, 5 deletions
diff --git a/src/lib/qtprofilesetup/templates/qmlcache.qbs b/src/lib/qtprofilesetup/templates/qmlcache.qbs index 246486c53..9111eb500 100644 --- a/src/lib/qtprofilesetup/templates/qmlcache.qbs +++ b/src/lib/qtprofilesetup/templates/qmlcache.qbs @@ -1,14 +1,22 @@ +import qbs.File import qbs.FileInfo import qbs.Process +import qbs.Utilities Module { additionalProductTypes: ["qt.qml.qmlc", "qt.qml.jsc"] - validate: qmlcachegenProbe.found + validate: { + if (!qmlcachegenProbe.found) + throw "qmlcachegen unsupported for this target"; + } property string qmlCacheGenPath: FileInfo.joinPaths(Qt.core.binPath, "qmlcachegen") + (qbs.hostOS.contains("windows") ? ".exe" : "") + property bool supportsAllArchitectures: Utilities.versionCompare(Qt.core.version, "5.11") >= 0 property string installDir readonly property stringList _targetArgs: { + if (supportsAllArchitectures) + return []; function translateArch(arch) { if (arch === "x86") return "i386"; @@ -24,15 +32,25 @@ Module { Depends { name: "Qt.core" } Probe { id: qmlcachegenProbe + + property string arch: qbs.architecture + property string _qmlCacheGenPath: qmlCacheGenPath + property stringList targetArgs: _targetArgs + property bool _supportsAllArchitectures: supportsAllArchitectures + configure: { + if (_supportsAllArchitectures) { + found = File.exists(_qmlCacheGenPath); + return; + } var process = new Process(); found = false; try { - found = process.exec(qmlCacheGenPath, - _targetArgs.concat("--check-if-supported")) == 0; + found = process.exec(_qmlCacheGenPath, + targetArgs.concat("--check-if-supported")) == 0; if (!found) { var msg = "QML cache generation was requested but is unsupported on " - + "architecture '" + qbs.architecture + "'."; + + "architecture '" + arch + "'."; console.warn(msg); } } finally { diff --git a/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs b/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs index 398d3f4a9..5117557e1 100644 --- a/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs +++ b/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs @@ -1,4 +1,5 @@ import qbs +import qbs.Utilities CppApplication { name: "app" @@ -27,4 +28,13 @@ CppApplication { qbs.install: true qbs.installDir: "data" } + + Probe { + id: qtVersionProbe + property string qtVersion: Qt.core.version + configure: { + console.info("qmlcachegen must work: " + + (Utilities.versionCompare(qtVersion, "5.11") >= 0)) + } + } } diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp index 93eb68f80..03e52590b 100644 --- a/tests/auto/blackbox/tst_blackboxqt.cpp +++ b/tests/auto/blackbox/tst_blackboxqt.cpp @@ -77,7 +77,11 @@ void TestBlackboxQt::cachedQml() QDir::setCurrent(testDataDir + "/cached-qml"); QCOMPARE(runQbs(), 0); QString dataDir = relativeBuildDir() + "/install-root/data"; - if (QFile::exists(dataDir + "/main.cpp")) { + QVERIFY2(m_qbsStdout.contains("qmlcachegen must work: true") + || m_qbsStdout.contains("qmlcachegen must work: false"), + m_qbsStdout.constData()); + if (m_qbsStdout.contains("qmlcachegen must work: false") + && QFile::exists(dataDir + "/main.cpp")) { // If C++ source files were installed then Qt.qmlcache is not available. See project file. QSKIP("No QML cache files generated."); } |