aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2016-12-22 13:41:45 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-08-03 09:53:01 +0000
commit4149ea709b8375e335b868bb0492de3710e14802 (patch)
treeb43152273d905403056a4c4569e09c15f0efc29e
parent3b95913c674edcdf94eea673aa81d4f670231555 (diff)
Add support for the Qt Quick compiler
Detect the availability of the Qt Quick compiler in qbs-setup-qt. Add a property bool Qt.quick.compilerAvailable that is true if the Qt Quick compiler is available in this Qt build. If the compiler is available, create an extended Qt.quick module with Qt Quick compiler rules. Create a standard module otherwise. The rules pick up Qt resource files tagged with Qt.quick.qrc and compile the referenced QML files. The remaining files are put into a new QRC file that is then passed to rcc. A prioritized file tagger is provided that automatically tags *.qrc files as "qt.quick.qrc" if the Qt quick compiler is available. [ChangeLog] Added support for the Qt Quick compiler. Task-number: QBS-749 Change-Id: I44e490e09796afeb5455ec50abc1e798f7eaf01a Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--doc/reference/modules/qt-modules.qdoc27
-rw-r--r--examples/compiled-qml/MainForm.ui.qml68
-rw-r--r--examples/compiled-qml/cheese.jpgbin0 -> 3029 bytes
-rw-r--r--examples/compiled-qml/main.cpp62
-rw-r--r--examples/compiled-qml/main.qml62
-rw-r--r--examples/compiled-qml/myapp.qbs65
-rw-r--r--examples/compiled-qml/qml.qrc7
-rw-r--r--src/lib/qtprofilesetup/qtenvironment.h1
-rw-r--r--src/lib/qtprofilesetup/qtprofilesetup.cpp13
-rw-r--r--src/lib/qtprofilesetup/templates.qrc2
-rw-r--r--src/lib/qtprofilesetup/templates/quick.js84
-rw-r--r--src/lib/qtprofilesetup/templates/quick.qbs189
12 files changed, 579 insertions, 1 deletions
diff --git a/doc/reference/modules/qt-modules.qdoc b/doc/reference/modules/qt-modules.qdoc
index 085e97ae7..9f6116683 100644
--- a/doc/reference/modules/qt-modules.qdoc
+++ b/doc/reference/modules/qt-modules.qdoc
@@ -143,7 +143,7 @@
\li quick
\li Qt Quick (2)
\li Provides the \c{Qt Quick} module (Qt Quick 2). For more information,
- see \l {quick Properties}.
+ see \l{quick Properties} and \l{quick File Tags}.
\row
\li qml
\li Qt QML
@@ -481,6 +481,11 @@
\li Default
\li Description
\row
+ \li compilerAvailable
+ \li \c{bool}
+ \li set by \c{qbs-setup-qt}
+ \li Specifies whether the Qt installation contains the Qt Quick compiler.
+ \row
\li qmlDebugging
\li \c{bool}
\li \c{false}
@@ -716,6 +721,26 @@
\li Source files with this tag serve as inputs to the QML plugin scanner.
\endtable
+ \section2 quick File Tags
+
+ \table
+ \header
+ \li Tag
+ \li Auto-tagged File Names
+ \li Since
+ \li Description
+ \row
+ \li \c{"qt.quick.qrc"}
+ \li \c{*.qrc}
+ \li 1.10
+ \li Qt resource files with this file tag will be picked up by the
+ Qt Quick compiler rule, and all QML files in the resource will be
+ compiled.
+
+ This file tag will only be added automatically if the Qt Quick
+ compiler is available.
+ \endtable
+
\section2 scxml File Tags
\table
diff --git a/examples/compiled-qml/MainForm.ui.qml b/examples/compiled-qml/MainForm.ui.qml
new file mode 100644
index 000000000..0b1653ebf
--- /dev/null
+++ b/examples/compiled-qml/MainForm.ui.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of Qbs.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+
+Rectangle {
+ property alias mouseArea: mouseArea
+
+ width: 360
+ height: 360
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ }
+
+ Image {
+ anchors.centerIn: parent
+ source: "cheese.jpg"
+ }
+}
diff --git a/examples/compiled-qml/cheese.jpg b/examples/compiled-qml/cheese.jpg
new file mode 100644
index 000000000..dea5795fd
--- /dev/null
+++ b/examples/compiled-qml/cheese.jpg
Binary files differ
diff --git a/examples/compiled-qml/main.cpp b/examples/compiled-qml/main.cpp
new file mode 100644
index 000000000..27074068f
--- /dev/null
+++ b/examples/compiled-qml/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of Qbs.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
diff --git a/examples/compiled-qml/main.qml b/examples/compiled-qml/main.qml
new file mode 100644
index 000000000..4b7c4dc77
--- /dev/null
+++ b/examples/compiled-qml/main.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of Qbs.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Window 2.2
+
+Window {
+ visible: true
+ MainForm {
+ anchors.fill: parent
+ mouseArea.onClicked: {
+ Qt.quit();
+ }
+ }
+}
diff --git a/examples/compiled-qml/myapp.qbs b/examples/compiled-qml/myapp.qbs
new file mode 100644
index 000000000..f2b04ec83
--- /dev/null
+++ b/examples/compiled-qml/myapp.qbs
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of Qbs.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import qbs
+
+CppApplication {
+ Depends { name: "Qt.quick" }
+
+ files: [
+ "main.cpp",
+ "qml.qrc"
+ ]
+
+ Group {
+ name: "QML Files"
+ files: ["*.qml"]
+ }
+}
diff --git a/examples/compiled-qml/qml.qrc b/examples/compiled-qml/qml.qrc
new file mode 100644
index 000000000..deb314e51
--- /dev/null
+++ b/examples/compiled-qml/qml.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>MainForm.ui.qml</file>
+ <file>cheese.jpg</file>
+ </qresource>
+</RCC>
diff --git a/src/lib/qtprofilesetup/qtenvironment.h b/src/lib/qtprofilesetup/qtenvironment.h
index 6b52ab934..d08846cfe 100644
--- a/src/lib/qtprofilesetup/qtenvironment.h
+++ b/src/lib/qtprofilesetup/qtenvironment.h
@@ -79,6 +79,7 @@ public:
Internal::Version msvcVersion;
bool staticBuild = false;
bool frameworkBuild = false;
+ bool hasQtQuickCompiler = false;
};
} // namespace qbs
diff --git a/src/lib/qtprofilesetup/qtprofilesetup.cpp b/src/lib/qtprofilesetup/qtprofilesetup.cpp
index 70c4fb395..4d4913eaa 100644
--- a/src/lib/qtprofilesetup/qtprofilesetup.cpp
+++ b/src/lib/qtprofilesetup/qtprofilesetup.cpp
@@ -221,6 +221,11 @@ static void replaceSpecialValues(QByteArray *content, const Profile &profile,
s << indent << "property string qmlImportsPath: "
<< pathToJSLiteral(qtEnvironment.qmlImportPath);
+ if (module.qbsName == QLatin1String("quick")) {
+ s << endl << indent << "property bool compilerAvailable: "
+ << toJSLiteral(qtEnvironment.hasQtQuickCompiler);
+ }
+
const QByteArray baIndent(4, ' ');
compilerDefines = "{\n"
+ baIndent + baIndent + "var result = " + compilerDefines + ";\n"
@@ -324,6 +329,10 @@ static void createModules(Profile &profile, Settings *settings,
}
} else if (module.qbsName == QLatin1String("phonon")) {
moduleTemplateFileName = QLatin1String("phonon.qbs");
+ } else if (module.qbsName == QLatin1String("quick")) {
+ moduleTemplateFileName = QLatin1String("quick.qbs");
+ copyTemplateFile(QLatin1String("quick.js"), qbsQtModuleDir, profile,
+ qtEnvironment, &allFiles);
} else if (module.isPlugin) {
moduleTemplateFileName = QLatin1String("plugin.qbs");
} else {
@@ -485,6 +494,10 @@ void doSetupQtProfile(const QString &profileName, Settings *settings,
Profile profile(profileName, settings);
profile.removeProfile();
+ if (QFileInfo::exists(qtEnvironment.mkspecBasePath
+ + QStringLiteral("/features/qtquickcompiler.prf"))) {
+ qtEnvironment.hasQtQuickCompiler = true;
+ }
createModules(profile, settings, qtEnvironment);
}
diff --git a/src/lib/qtprofilesetup/templates.qrc b/src/lib/qtprofilesetup/templates.qrc
index 9c706c574..5257eccec 100644
--- a/src/lib/qtprofilesetup/templates.qrc
+++ b/src/lib/qtprofilesetup/templates.qrc
@@ -15,5 +15,7 @@
<file>templates/qml.qbs</file>
<file>templates/qml.js</file>
<file>templates/qmlcache.qbs</file>
+ <file>templates/quick.js</file>
+ <file>templates/quick.qbs</file>
</qresource>
</RCC>
diff --git a/src/lib/qtprofilesetup/templates/quick.js b/src/lib/qtprofilesetup/templates/quick.js
new file mode 100644
index 000000000..0ab10606b
--- /dev/null
+++ b/src/lib/qtprofilesetup/templates/quick.js
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms and
+** conditions see http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+var FileInfo = require("qbs.FileInfo");
+var Process = require("qbs.Process");
+
+function scanQrc(qrcFilePath) {
+ var absInputDir = FileInfo.path(qrcFilePath);
+ var result = [];
+ var process = new Process();
+ try {
+ var rcc = FileInfo.joinPaths(product.Qt.core.binPath, 'rcc' + product.cpp.executableSuffix);
+ var exitCode = process.exec(rcc, ["--list", qrcFilePath], true);
+ for (;;) {
+ var line = process.readLine();
+ if (!line)
+ break;
+ line = line.trim();
+ line = FileInfo.relativePath(absInputDir, line);
+ result.push(line);
+ }
+ } finally {
+ process.close();
+ }
+ return result;
+}
+
+function qtQuickCompilerOutputName(filePath) {
+ var str = filePath.replace('/', '_');
+ var i = str.lastIndexOf('.');
+ if (i != -1)
+ str = str.substr(0, i) + '_' + str.substr(i + 1);
+ str += ".cpp";
+ return str;
+}
+
+function qtQuickResourceFileOutputName(fileName) {
+ return fileName.replace(/\.qrc$/, "_qtquickcompiler.qrc");
+}
+
+function contentFromQrc(qrcFilePath) {
+ var filesInQrc = scanQrc(qrcFilePath);
+ var qmlJsFiles = filesInQrc.filter(function (filePath) {
+ return (/\.(js|qml)$/).test(filePath);
+ } );
+ var content = {};
+ if (filesInQrc.length - qmlJsFiles.length > 0) {
+ content.newQrcFileName = qtQuickResourceFileOutputName(input.fileName);
+ }
+ content.qmlJsFiles = qmlJsFiles.map(function (filePath) {
+ return {
+ input: filePath,
+ output: qtQuickCompilerOutputName(filePath)
+ };
+ });
+ return content;
+}
diff --git a/src/lib/qtprofilesetup/templates/quick.qbs b/src/lib/qtprofilesetup/templates/quick.qbs
new file mode 100644
index 000000000..c3c4f9783
--- /dev/null
+++ b/src/lib/qtprofilesetup/templates/quick.qbs
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms and
+** conditions see http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+import qbs
+import qbs.Process
+import qbs.FileInfo
+import qbs.TextFile
+import '../QtModule.qbs' as QtModule
+import 'quick.js' as QC
+
+QtModule {
+ qtModuleName: @name@
+ Depends { name: "Qt"; submodules: @dependencies@.concat("qml-private") }
+
+ hasLibrary: @has_library@
+ staticLibsDebug: @staticLibsDebug@
+ staticLibsRelease: @staticLibsRelease@
+ dynamicLibsDebug: @dynamicLibsDebug@
+ dynamicLibsRelease: @dynamicLibsRelease@
+ linkerFlagsDebug: @linkerFlagsDebug@
+ linkerFlagsRelease: @linkerFlagsRelease@
+ frameworksDebug: @frameworksDebug@
+ frameworksRelease: @frameworksRelease@
+ frameworkPathsDebug: @frameworkPathsDebug@
+ frameworkPathsRelease: @frameworkPathsRelease@
+ libNameForLinkerDebug: @libNameForLinkerDebug@
+ libNameForLinkerRelease: @libNameForLinkerRelease@
+ libFilePathDebug: @libFilePathDebug@
+ libFilePathRelease: @libFilePathRelease@
+ cpp.defines: @defines@
+ cpp.includePaths: @includes@
+ cpp.libraryPaths: @libraryPaths@
+ @special_properties@
+ Scanner {
+ condition: compilerAvailable
+ inputs: 'qt.quick.qrc'
+ searchPaths: [FileInfo.path(input.filePath)]
+ scan: QC.scanQrc(input.filePath)
+ }
+
+ FileTagger {
+ condition: compilerAvailable
+ patterns: "*.qrc"
+ fileTags: ["qt.quick.qrc"]
+ priority: 100
+ }
+
+ Rule {
+ condition: compilerAvailable
+ inputs: ["qt.quick.qrc"]
+ Artifact {
+ filePath: input.fileName + ".json"
+ fileTags: ["qt.quick.qrcinfo"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.silent = true;
+ cmd.sourceCode = function() {
+ var content = QC.contentFromQrc(input.filePath);
+ content.qrcFilePath = input.filePath;
+
+ var tf = new TextFile(output.filePath, TextFile.WriteOnly);
+ tf.write(JSON.stringify(content));
+ tf.close();
+ }
+ return cmd;
+ }
+ }
+
+ Rule {
+ condition: compilerAvailable
+ inputs: ["qt.quick.qrcinfo"]
+ outputFileTags: ["cpp", "qrc"]
+ multiplex: true
+ outputArtifacts: {
+ var infos = [];
+ inputs["qt.quick.qrcinfo"].forEach(function (input) {
+ var tf = new TextFile(input.filePath, TextFile.ReadOnly);
+ infos.push(JSON.parse(tf.readAll()));
+ tf.close();
+ });
+
+ var result = [];
+ infos.forEach(function (info) {
+ if (info.newQrcFileName) {
+ result.push({
+ filePath: info.newQrcFileName,
+ fileTags: ["qrc"]
+ });
+ }
+ info.qmlJsFiles.forEach(function (qmlJsFile) {
+ result.push({
+ filePath: qmlJsFile.output,
+ fileTags: ["cpp"]
+ });
+ });
+ });
+ result.push({
+ filePath: "qtquickcompiler_loader.cpp",
+ fileTags: ["cpp"]
+ });
+ return result;
+ }
+ prepare: {
+ var infos = [];
+ inputs["qt.quick.qrcinfo"].forEach(function (input) {
+ var tf = new TextFile(input.filePath, TextFile.ReadOnly);
+ infos.push(JSON.parse(tf.readAll()));
+ tf.close();
+ });
+
+ var cmds = [];
+ var qmlCompiler = FileInfo.joinPaths(product.Qt.core.binPath,
+ "qtquickcompiler" + product.cpp.executableSuffix);
+ var cmd;
+ var loaderFlags = [];
+
+ function findOutput(fileName) {
+ for (var k in outputs) {
+ for (var i in outputs[k]) {
+ if (outputs[k][i].fileName === fileName)
+ return outputs[k][i];
+ }
+ }
+ throw new Error("Qt Quick compiler rule: Cannot find output artifact "
+ + fileName + ".");
+ }
+
+ infos.forEach(function (info) {
+ if (info.newQrcFileName) {
+ loaderFlags.push("--resource-file-mapping="
+ + FileInfo.fileName(info.qrcFilePath)
+ + ":" + info.newQrcFileName);
+ cmd = new Command(qmlCompiler, ["--filter-resource-file",
+ info.qrcFilePath,
+ findOutput(info.newQrcFileName).filePath]);
+ cmd.description = "generating " + info.newQrcFileName;
+ cmds.push(cmd);
+ } else {
+ loaderFlags.push("--resource-file-mapping=" + info.qrcFilePath);
+ }
+ info.qmlJsFiles.forEach(function (qmlJsFile) {
+ cmd = new Command(qmlCompiler, [
+ "--resource=" + info.qrcFilePath,
+ qmlJsFile.input,
+ findOutput(qmlJsFile.output).filePath]);
+ cmd.description = "generating " + qmlJsFile.output;
+ cmd.workingDirectory = FileInfo.path(info.qrcFilePath);
+ cmds.push(cmd);
+ });
+ });
+
+ cmd = new Command(qmlCompiler, loaderFlags.concat(
+ infos.map(function (info) { return info.qrcFilePath; }),
+ findOutput("qtquickcompiler_loader.cpp").filePath
+ ));
+ cmd.description = "generating loader source";
+ cmds.push(cmd);
+ return cmds;
+ }
+ }
+}