aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlcachegen/qmlcachegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-01-02 13:08:40 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-01-04 14:13:49 +0000
commit21ffde85a1b4592d24785a3ba82817de05486060 (patch)
tree6d449f5df9bd6be92906f234c2438766d95c961e /tools/qmlcachegen/qmlcachegen.cpp
parent604e379338e7c9e17c929063148754a30077988c (diff)
Add option to retain sources when generating QML cache
By default any .qrc files are filtered and QML and JS sources dropped when generating the cache. The new QTQUICK_COMPILER_RETAINED_RESOURCES option allows the specification of .qrc files to be kept as they are. The source fils specified in them will be available to the application. Change-Id: If45bcd95c29fe4b91f5817573964ff55b1db8a00 Fixes: QTBUG-72430 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tools/qmlcachegen/qmlcachegen.cpp')
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index 1805dde5d2..b3c55e85e0 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -43,8 +43,12 @@
#include "resourcefilemapper.h"
+#include <algorithm>
+
int filterResourceFile(const QString &input, const QString &output);
-bool generateLoader(const QStringList &compiledFiles, const QString &output, const QStringList &resourceFileMappings, QString *errorString);
+bool generateLoader(const QStringList &compiledFiles, const QStringList &retainedFiles,
+ const QString &output, const QStringList &resourceFileMappings,
+ QString *errorString);
QString symbolNamespaceForPath(const QString &relativePath);
QSet<QString> illegalNames;
@@ -438,6 +442,8 @@ int main(int argc, char **argv)
parser.addOption(resourceFileMappingOption);
QCommandLineOption resourceOption(QStringLiteral("resource"), QCoreApplication::translate("main", "Qt resource file that might later contain one of the compiled files"), QCoreApplication::translate("main", "resource-file-name"));
parser.addOption(resourceOption);
+ QCommandLineOption retainOption(QStringLiteral("retain"), QCoreApplication::translate("main", "Qt resource file the contents of which should not be replaced by empty stubs"), QCoreApplication::translate("main", "resource-file-name"));
+ parser.addOption(retainOption);
QCommandLineOption resourcePathOption(QStringLiteral("resource-path"), QCoreApplication::translate("main", "Qt resource file path corresponding to the file being compiled"), QCoreApplication::translate("main", "resource-path"));
parser.addOption(resourcePathOption);
@@ -485,9 +491,13 @@ int main(int argc, char **argv)
if (target == GenerateLoader) {
ResourceFileMapper mapper(sources);
+ ResourceFileMapper retain(parser.values(retainOption));
Error error;
- if (!generateLoader(mapper.qmlCompilerFiles(), outputFileName, parser.values(resourceFileMappingOption), &error.message)) {
+ QStringList retainedFiles = retain.qmlCompilerFiles();
+ std::sort(retainedFiles.begin(), retainedFiles.end());
+ if (!generateLoader(mapper.qmlCompilerFiles(), retainedFiles, outputFileName,
+ parser.values(resourceFileMappingOption), &error.message)) {
error.augment(QLatin1String("Error generating loader stub: ")).print();
return EXIT_FAILURE;
}