aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2018-05-18 15:10:10 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2018-11-30 08:45:22 +0000
commit2e830e5e4fdafed981bb5d95cd0327d572b7a402 (patch)
treeb2f8b6ca00b1661e309e52d8e47e8a155fa1fcd8
parent6566e0c7a56b0c854514f38f020a04b90042deb8 (diff)
Support big Qt resources
[ChangeLog] Introduced the property Qt.core.enableBigResources for the creation of "big" Qt resources. Change-Id: Ic87aa70132240e67243c1cbe137583a371558261 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--doc/reference/modules/qt-core-module.qdoc9
-rw-r--r--share/qbs/modules/cpp/GenericGCC.qbs8
-rw-r--r--share/qbs/modules/cpp/windows-msvc.qbs12
-rw-r--r--src/lib/corelib/buildgraph/transformer.cpp13
-rw-r--r--src/lib/qtprofilesetup/templates/core.qbs56
-rw-r--r--tests/auto/blackbox/tst_blackboxqt.cpp29
6 files changed, 115 insertions, 12 deletions
diff --git a/doc/reference/modules/qt-core-module.qdoc b/doc/reference/modules/qt-core-module.qdoc
index 6bfa67f19..922b1889b 100644
--- a/doc/reference/modules/qt-core-module.qdoc
+++ b/doc/reference/modules/qt-core-module.qdoc
@@ -140,6 +140,15 @@
*/
/*!
+ \qmlproperty bool Qt.core::enableBigResources
+
+ Whether the Qt resource compiler is run in a two-pass fashion that supports
+ the creation of big resources.
+
+ \defaultvalue \c{false}
+*/
+
+/*!
\qmlproperty stringList Qt.core::config
Corresponds to the default value of qmake's \c CONFIG variable.
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs
index 79575ca2b..972555ed7 100644
--- a/share/qbs/modules/cpp/GenericGCC.qbs
+++ b/share/qbs/modules/cpp/GenericGCC.qbs
@@ -581,9 +581,13 @@ CppModule {
auxiliaryInputs: ["hpp"]
explicitlyDependsOn: ["c_pch", "cpp_pch", "objc_pch", "objcpp_pch"]
- outputFileTags: ["obj", "c_obj", "cpp_obj"]
+ outputFileTags: ["obj", "c_obj", "cpp_obj", "intermediate_obj"]
outputArtifacts: {
- var tags = ["obj"];
+ var tags;
+ if (input.fileTags.contains("cpp_intermediate_object"))
+ tags = ["intermediate_obj"];
+ else
+ tags = ["obj"];
if (inputs.c || inputs.objc)
tags.push("c_obj");
if (inputs.cpp || inputs.objcpp)
diff --git a/share/qbs/modules/cpp/windows-msvc.qbs b/share/qbs/modules/cpp/windows-msvc.qbs
index b22984a6e..8dd6dd2c0 100644
--- a/share/qbs/modules/cpp/windows-msvc.qbs
+++ b/share/qbs/modules/cpp/windows-msvc.qbs
@@ -173,9 +173,15 @@ CppModule {
auxiliaryInputs: ["hpp"]
explicitlyDependsOn: ["c_pch", "cpp_pch"]
- Artifact {
- fileTags: ['obj']
- filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + ".obj"
+ outputFileTags: ["obj", "intermediate_obj"]
+ outputArtifacts: {
+ var tags = input.fileTags.contains("cpp_intermediate_object")
+ ? ["intermediate_obj"]
+ : ["obj"];
+ return [{
+ fileTags: tags,
+ filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + ".obj"
+ }];
}
prepare: {
diff --git a/src/lib/corelib/buildgraph/transformer.cpp b/src/lib/corelib/buildgraph/transformer.cpp
index 0a067f6a4..ccde486ab 100644
--- a/src/lib/corelib/buildgraph/transformer.cpp
+++ b/src/lib/corelib/buildgraph/transformer.cpp
@@ -98,6 +98,18 @@ static QScriptValue js_baseDir(QScriptContext *ctx, QScriptEngine *engine,
return basedir;
}
+static QScriptValue js_children(QScriptContext *ctx, QScriptEngine *engine, const Artifact *artifact)
+{
+ Q_UNUSED(ctx);
+ QScriptValue sv = engine->newArray();
+ uint idx = 0;
+ for (const Artifact *parent : artifact->childArtifacts()) {
+ sv.setProperty(idx++, Transformer::translateFileConfig(static_cast<ScriptEngine *>(engine),
+ parent, QString()));
+ }
+ return sv;
+}
+
static void setArtifactProperty(QScriptValue &obj, const QString &name,
QScriptValue (*func)(QScriptContext *, QScriptEngine *, const Artifact *),
const Artifact *artifact)
@@ -118,6 +130,7 @@ QScriptValue Transformer::translateFileConfig(ScriptEngine *scriptEngine, const
setArtifactProperty(obj, StringConstants::completeBaseNameProperty(), js_completeBaseName,
artifact);
setArtifactProperty(obj, QStringLiteral("baseDir"), js_baseDir, artifact);
+ setArtifactProperty(obj, QStringLiteral("children"), js_children, artifact);
const QStringList fileTags = sorted(artifact->fileTags().toStringList());
scriptEngine->setObservedProperty(obj, StringConstants::fileTagsProperty(),
scriptEngine->toScriptValue(fileTags));
diff --git a/src/lib/qtprofilesetup/templates/core.qbs b/src/lib/qtprofilesetup/templates/core.qbs
index 1a83aab71..7abd7aa02 100644
--- a/src/lib/qtprofilesetup/templates/core.qbs
+++ b/src/lib/qtprofilesetup/templates/core.qbs
@@ -271,6 +271,7 @@ Module {
}
property bool combineMocOutput: cpp.combineCxxSources
+ property bool enableBigResources: false
Rule {
name: "QtCoreMocRuleCpp"
@@ -369,17 +370,60 @@ Module {
Rule {
inputs: ["qrc"]
+ outputFileTags: ["cpp", "cpp_intermediate_object"]
+ outputArtifacts: {
+ var artifact = {
+ filePath: "qrc_" + input.completeBaseName + ".cpp",
+ fileTags: ["cpp"]
+ };
+ if (input.Qt.core.enableBigResources)
+ artifact.fileTags.push("cpp_intermediate_object");
+ return [artifact];
+ }
+ prepare: {
+ var args = [input.filePath,
+ "-name", FileInfo.completeBaseName(input.filePath),
+ "-o", output.filePath];
+ if (input.Qt.core.enableBigResources)
+ args.push("-pass", "1");
+ var cmd = new Command(product.Qt.core.binPath + '/rcc', args);
+ cmd.description = "rcc "
+ + (input.Qt.core.enableBigResources ? "(pass 1) " : "")
+ + input.fileName;
+ cmd.highlight = 'codegen';
+ return cmd;
+ }
+ }
+ Rule {
+ inputs: ["intermediate_obj"]
Artifact {
- filePath: "qrc_" + input.completeBaseName + ".cpp"
- fileTags: ["cpp"]
+ filePath: input.completeBaseName + ".2.o"
+ fileTags: ["obj"]
}
prepare: {
+ function findChild(artifact, predicate) {
+ var children = artifact.children;
+ var len = children.length;
+ for (var i = 0; i < len; ++i) {
+ var child = children[i];
+ if (predicate(child))
+ return child;
+ child = findChild(child, predicate);
+ if (child)
+ return child;
+ }
+ return undefined;
+ }
+ var qrcArtifact = findChild(input, function(c) { return c.fileTags.contains("qrc"); });
+ var cppArtifact = findChild(input, function(c) { return c.fileTags.contains("cpp"); });
var cmd = new Command(product.Qt.core.binPath + '/rcc',
- [input.filePath, '-name',
- FileInfo.completeBaseName(input.filePath),
- '-o', output.filePath]);
- cmd.description = 'rcc ' + input.fileName;
+ [qrcArtifact.filePath,
+ "-temp", input.filePath,
+ "-name", FileInfo.completeBaseName(input.filePath),
+ "-o", output.filePath,
+ "-pass", "2"]);
+ cmd.description = "rcc (pass 2) " + qrcArtifact.fileName;
cmd.highlight = 'codegen';
return cmd;
}
diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp
index ce97979e7..3441255e2 100644
--- a/tests/auto/blackbox/tst_blackboxqt.cpp
+++ b/tests/auto/blackbox/tst_blackboxqt.cpp
@@ -447,6 +447,7 @@ void TestBlackboxQt::track_qrc()
QVERIFY2(!m_qbsStdout.contains("compiling test.cpp"), m_qbsStdout.constData());
const QString fileName = relativeExecutableFilePath("i");
QVERIFY2(regularFileExists(fileName), qPrintable(fileName));
+
QDateTime dt = QFileInfo(fileName).lastModified();
WAIT_FOR_NEW_TIMESTAMP();
{
@@ -459,16 +460,42 @@ void TestBlackboxQt::track_qrc()
REPLACE_IN_FILE("i.qbs", "//\"test.cpp\"", "\"test.cpp\"");
waitForFileUnlock();
QCOMPARE(runQbs(QbsRunParameters("run")), 0);
- QVERIFY2(m_qbsStdout.contains("rcc"), m_qbsStdout.constData());
+ QVERIFY2(m_qbsStdout.contains("rcc bla.qrc"), m_qbsStdout.constData());
QVERIFY2(m_qbsStdout.contains("compiling test.cpp"), m_qbsStdout.constData());
QVERIFY(regularFileExists(fileName));
QVERIFY(dt < QFileInfo(fileName).lastModified());
+
WAIT_FOR_NEW_TIMESTAMP();
touch("i.qbs");
QCOMPARE(runQbs(), 0);
QVERIFY2(m_qbsStdout.contains("Resolving"), m_qbsStdout.constData());
QVERIFY2(!m_qbsStdout.contains("rcc"), m_qbsStdout.constData());
QVERIFY2(!m_qbsStdout.contains("compiling test.cpp"), m_qbsStdout.constData());
+
+ // Turn on big resources.
+ WAIT_FOR_NEW_TIMESTAMP();
+ QCOMPARE(runQbs(QbsRunParameters("resolve", {"modules.Qt.core.enableBigResources:true"})), 0);
+ QCOMPARE(runQbs(QbsRunParameters("run")), 0);
+ QVERIFY2(m_qbsStdout.contains("rcc (pass 1) bla.qrc"), m_qbsStdout.constData());
+ QVERIFY2(m_qbsStdout.contains("rcc (pass 2) bla.qrc"), m_qbsStdout.constData());
+
+ // Check null build.
+ WAIT_FOR_NEW_TIMESTAMP();
+ QCOMPARE(runQbs(), 0);
+ QVERIFY2(m_qbsStdout.contains("Building"), m_qbsStdout.constData());
+ QVERIFY2(!m_qbsStdout.contains("rcc"), m_qbsStdout.constData());
+
+ // Turn off big resources.
+ WAIT_FOR_NEW_TIMESTAMP();
+ QCOMPARE(runQbs(QbsRunParameters("resolve", {"modules.Qt.core.enableBigResources:false"})), 0);
+ QCOMPARE(runQbs(QbsRunParameters("run")), 0);
+ QVERIFY2(m_qbsStdout.contains("rcc bla.qrc"), m_qbsStdout.constData());
+
+ // Check null build.
+ WAIT_FOR_NEW_TIMESTAMP();
+ QCOMPARE(runQbs(), 0);
+ QVERIFY2(m_qbsStdout.contains("Building"), m_qbsStdout.constData());
+ QVERIFY2(!m_qbsStdout.contains("rcc"), m_qbsStdout.constData());
}
void TestBlackboxQt::unmocable()