diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-12 10:53:43 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-12 10:53:43 +0100 |
commit | 20a51e87fd15b8a6c1503b905399f7befe31114b (patch) | |
tree | 5a8667150568ed798d63eb165372c198549498c2 /tools | |
parent | 6c152bf27f94f01b2942b02e370df4fa01e0d40f (diff) | |
parent | 084dbb06d7b00c4a67edb6ce58956150036c35f2 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
.qmake.conf
Change-Id: I356ec83cf687bd2833f9a7c5e820d56b1efa8979
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlimportscanner/main.cpp | 16 | ||||
-rw-r--r-- | tools/qmlplugindump/main.cpp | 42 | ||||
-rw-r--r-- | tools/qmlplugindump/qmlplugindump.pro | 6 | ||||
-rw-r--r-- | tools/qmlplugindump/qmltypereader.cpp | 63 | ||||
-rw-r--r-- | tools/qmlplugindump/qmltypereader.h | 42 |
5 files changed, 158 insertions, 11 deletions
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index af6b272fc6..dcb9709bb8 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -85,7 +85,7 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con if (!importNode->fileName.isEmpty()) { QString name = importNode->fileName.toString(); import[QStringLiteral("name")] = name; - if (name.endsWith(QStringLiteral(".js"))) { + if (name.endsWith(QLatin1String(".js"))) { import[QStringLiteral("type")] = QStringLiteral("javascript"); } else { import[QStringLiteral("type")] = QStringLiteral("directory"); @@ -188,7 +188,7 @@ QVariantList findPathsForModuleImports(const QVariantList &imports) for (int i = 0; i < importsCopy.length(); ++i) { QVariantMap import = qvariant_cast<QVariantMap>(importsCopy[i]); - if (import[QStringLiteral("type")] == QStringLiteral("module")) { + if (import[QStringLiteral("type")] == QLatin1String("module")) { QString path = resolveImportPath(import.value(QStringLiteral("name")).toString(), import.value(QStringLiteral("version")).toString()); if (!path.isEmpty()) import[QStringLiteral("path")] = path; @@ -319,9 +319,9 @@ QVariantList findQmlImportsInFile(const QString &filePath) QFile f; if (f.open(stdin, QIODevice::ReadOnly)) imports = findQmlImportsInQmlCode(QLatin1String("<stdin>"), QString::fromUtf8(f.readAll())); - } else if (filePath.endsWith(QStringLiteral(".qml"))) { + } else if (filePath.endsWith(QLatin1String(".qml"))) { imports = findQmlImportsInQmlFile(filePath); - } else if (filePath.endsWith(QStringLiteral(".js"))) { + } else if (filePath.endsWith(QLatin1String(".js"))) { imports = findQmlImportsInJavascriptFile(filePath); } @@ -382,10 +382,10 @@ QVariantList findQmlImportsInDirectory(const QString &qmlDir) continue; // skip obvious build output directories - if (path.contains(QStringLiteral("Debug-iphoneos")) || path.contains(QStringLiteral("Release-iphoneos")) || - path.contains(QStringLiteral("Debug-iphonesimulator")) || path.contains(QStringLiteral("Release-iphonesimulator")) + if (path.contains(QLatin1String("Debug-iphoneos")) || path.contains(QLatin1String("Release-iphoneos")) || + path.contains(QLatin1String("Debug-iphonesimulator")) || path.contains(QLatin1String("Release-iphonesimulator")) #ifdef Q_OS_WIN - || path.contains(QStringLiteral("/release/")) || path.contains(QStringLiteral("/debug/")) + || path.contains(QLatin1String("/release/")) || path.contains(QLatin1String("/debug/")) #endif ){ continue; @@ -404,7 +404,7 @@ QSet<QString> importModulePaths(QVariantList imports) { QVariantMap import = qvariant_cast<QVariantMap>(importVariant); QString path = import.value(QStringLiteral("path")).toString(); QString type = import.value(QStringLiteral("type")).toString(); - if (type == QStringLiteral("module") && !path.isEmpty()) + if (type == QLatin1String("module") && !path.isEmpty()) ret.insert(QDir(path).canonicalPath()); } return ret; diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 776e19fdf4..7870e3a9df 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -51,9 +51,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 @@ -728,7 +730,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( @@ -982,6 +984,7 @@ int main(int argc, char *argv[]) QString pluginImportVersion; bool relocatable = true; QString dependenciesFile; + QString mergeFile; enum Action { Uri, Path, Builtins }; Action action = Uri; { @@ -1000,6 +1003,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") @@ -1061,6 +1071,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()) @@ -1210,6 +1240,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); @@ -1236,6 +1273,9 @@ int main(int argc, char *argv[]) if (pluginImportUri.isEmpty()) dumper.writeEasingCurve(); + // Insert merge file. + qml.write(mergeComponents); + qml.writeEndObject(); qml.writeEndDocument(); diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro index 6fdcd349d1..e45a7fad83 100644 --- a/tools/qmlplugindump/qmlplugindump.pro +++ b/tools/qmlplugindump/qmlplugindump.pro @@ -6,10 +6,12 @@ QTPLUGIN.platforms = qminimal SOURCES += \ main.cpp \ - qmlstreamwriter.cpp + qmlstreamwriter.cpp \ + qmltypereader.cpp HEADERS += \ - qmlstreamwriter.h + qmlstreamwriter.h \ + qmltypereader.h macx { # Prevent qmlplugindump from popping up in the dock when launched. diff --git a/tools/qmlplugindump/qmltypereader.cpp b/tools/qmlplugindump/qmltypereader.cpp new file mode 100644 index 0000000000..67ba415388 --- /dev/null +++ b/tools/qmlplugindump/qmltypereader.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmltypereader.h" + +#include <QFileInfo> +#include <QFile> +#include <QRegularExpression> + +#include <iostream> + +QStringList readQmlTypes(const QString &filename) { + QRegularExpression re("import QtQuick.tooling 1.2.*Module {\\s*dependencies:\\[([^\\]]*)\\](.*)}", + QRegularExpression::DotMatchesEverythingOption); + if (!QFileInfo(filename).exists()) { + std::cerr << "Non existing file: " << filename.toStdString() << std::endl; + return QStringList(); + } + QFile f(filename); + if (!f.open(QFileDevice::ReadOnly)) { + std::cerr << "Error in opening file " << filename.toStdString() << " : " + << f.errorString().toStdString() << std::endl; + return QStringList(); + } + QByteArray fileData = f.readAll(); + QString data(fileData); + QRegularExpressionMatch m = re.match(data); + if (m.lastCapturedIndex() != 2) { + std::cerr << "Malformed file: " << filename.toStdString() << std::endl; + return QStringList(); + } + return m.capturedTexts(); +} diff --git a/tools/qmlplugindump/qmltypereader.h b/tools/qmlplugindump/qmltypereader.h new file mode 100644 index 0000000000..b995566e0b --- /dev/null +++ b/tools/qmlplugindump/qmltypereader.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLTYPEREADER_H +#define QMLTYPEREADER_H + +#include <QString> +#include <QStringList> + +QStringList readQmlTypes(const QString &filename); + +#endif // QMLTYPEREADER_H |