aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlplugindump/main.cpp
diff options
context:
space:
mode:
authorMarco Benelli <marco.benelli@theqtcompany.com>2016-01-08 11:25:47 +0100
committerMarco Benelli <marco.benelli@theqtcompany.com>2016-02-02 14:58:21 +0000
commit7b38d8e0025aba6366fd2f222838cf99f6bd15f3 (patch)
tree1b464c69033a51d233176c414d52e953f85fbefb /tools/qmlplugindump/main.cpp
parent1929fee8e17e9ca66e7fe08faa9ed9fa7fdbb127 (diff)
qmlplugindump: option to merge qmltypes.
QtCreator does not handle dependencies between Qml types defined in different qmltypes files. Sometimes manual editing of qmltypes file is needed to let QtCreator find the missing type information. With the new -merge option it is possible to merge a qmltypes file to the output of qmlplugindump. Dependencies are correctly merged but components are simply added, so they could cause conflict. Change-Id: I6569339e4f05d37ea63fa2173983b4d595ae0ad6 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
Diffstat (limited to 'tools/qmlplugindump/main.cpp')
-rw-r--r--tools/qmlplugindump/main.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index fe92f80bad..393abc8883 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -56,9 +56,11 @@
#include <QtCore/private/qobject_p.h>
#include <QtCore/private/qmetaobject_p.h>
+#include <QRegularExpression>
#include <iostream>
#include <algorithm>
+#include "qmltypereader.h"
#include "qmlstreamwriter.h"
#ifdef QT_SIMULATOR
@@ -733,7 +735,7 @@ void sigSegvHandler(int) {
void printUsage(const QString &appName)
{
std::cerr << qPrintable(QString(
- "Usage: %1 [-v] [-noinstantiate] [-defaultplatform] [-[non]relocatable] [-dependencies <dependencies.json>] module.uri version [module/import/path]\n"
+ "Usage: %1 [-v] [-noinstantiate] [-defaultplatform] [-[non]relocatable] [-dependencies <dependencies.json>] [-merge <file-to-merge.qmltypes>] module.uri version [module/import/path]\n"
" %1 [-v] [-noinstantiate] -path path/to/qmldir/directory [version]\n"
" %1 [-v] -builtins\n"
"Example: %1 Qt.labs.folderlistmodel 2.0 /home/user/dev/qt-install/imports").arg(
@@ -987,6 +989,7 @@ int main(int argc, char *argv[])
QString pluginImportVersion;
bool relocatable = true;
QString dependenciesFile;
+ QString mergeFile;
enum Action { Uri, Path, Builtins };
Action action = Uri;
{
@@ -1005,6 +1008,13 @@ int main(int argc, char *argv[])
return EXIT_INVALIDARGUMENTS;
}
dependenciesFile = args.at(iArg);
+ } else if (arg == QLatin1String("--merge")
+ || arg == QLatin1String("-merge")) {
+ if (++iArg == args.size()) {
+ std::cerr << "missing merge file" << std::endl;
+ return EXIT_INVALIDARGUMENTS;
+ }
+ mergeFile = args.at(iArg);
} else if (arg == QLatin1String("--notrelocatable")
|| arg == QLatin1String("-notrelocatable")
|| arg == QLatin1String("--nonrelocatable")
@@ -1066,6 +1076,26 @@ int main(int argc, char *argv[])
QDir::setCurrent(pluginImportPath);
engine.addImportPath(pluginImportPath);
}
+
+ // Merge file.
+ QStringList mergeDependencies;
+ QString mergeComponents;
+ if (!mergeFile.isEmpty()) {
+ QStringList merge = readQmlTypes(mergeFile);
+ if (!merge.isEmpty()) {
+ QRegularExpression re("(\\w+\\.*\\w*\\s*\\d+\\.\\d+)");
+ QRegularExpressionMatchIterator i = re.globalMatch(merge[1]);
+ while (i.hasNext()) {
+ QRegularExpressionMatch m = i.next();
+ QString d = m.captured(1);
+ mergeDependencies << m.captured(1);
+ }
+ mergeComponents = merge [2];
+ }
+ }
+
+ // Dependencies.
+
bool calculateDependencies = !pluginImportUri.isEmpty() && !pluginImportVersion.isEmpty();
QStringList dependencies;
if (!dependenciesFile.isEmpty())
@@ -1215,6 +1245,13 @@ int main(int argc, char *argv[])
"// '%1 %2'\n"
"\n").arg(QFileInfo(args.at(0)).baseName(), args.mid(1).join(QLatin1Char(' '))));
qml.writeStartObject("Module");
+
+ // Insert merge dependencies.
+ if (!mergeDependencies.isEmpty()) {
+ dependencies << mergeDependencies;
+ }
+ compactDependencies(&dependencies);
+
QStringList quotedDependencies;
foreach (const QString &dep, dependencies)
quotedDependencies << enquote(dep);
@@ -1241,6 +1278,9 @@ int main(int argc, char *argv[])
if (pluginImportUri.isEmpty())
dumper.writeEasingCurve();
+ // Insert merge file.
+ qml.write(mergeComponents);
+
qml.writeEndObject();
qml.writeEndDocument();