summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-12-17 16:46:00 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-18 08:55:01 +0100
commit13d2c5a6a3f29d13341acd688988a75e40da1de6 (patch)
tree75ecad2314ca6542ba90e6c48ebaa253b335e240
parentc055110e19d3c8b889c52e54d1d9e6925bfc5f33 (diff)
downloadqttools-13d2c5a6a3f29d13341acd688988a75e40da1de6.tar.gz
windeployqt: Copy QML directory structure correctly.
Introduce a Module struct to QmlImportScanResult from which the relative/absolute install path can be derived (similar to macdeployqt). Task-number: QTBUG-35638 Change-Id: Ief69779f4ea8659b346bf364ec748cfe78eb6728 Reviewed-by: Andrew Knight <andrew.knight@digia.com>
-rw-r--r--src/windeployqt/main.cpp14
-rw-r--r--src/windeployqt/qmlutils.cpp56
-rw-r--r--src/windeployqt/qmlutils.h11
3 files changed, 72 insertions, 9 deletions
diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp
index dc57f340b..23b64be3c 100644
--- a/src/windeployqt/main.cpp
+++ b/src/windeployqt/main.cpp
@@ -746,8 +746,8 @@ static DeployResult deploy(const Options &options,
}
if (optVerboseLevel >= 1) {
std::fputs("QML imports:\n", stdout);
- foreach (const QString &mod, qmlScanResult.modulesDirectories)
- std::printf(" %s\n", qPrintable(QDir::toNativeSeparators(mod)));
+ foreach (const QmlImportScanResult::Module &mod, qmlScanResult.modules)
+ std::printf(" '%s' %s\n", qPrintable(mod.name), qPrintable(QDir::toNativeSeparators(mod.sourcePath)));
if (optVerboseLevel >= 2) {
std::fputs("QML plugins:\n", stdout);
foreach (const QString &p, qmlScanResult.plugins)
@@ -851,8 +851,14 @@ static DeployResult deploy(const Options &options,
if (options.quickImports && (usesQuick1 || usesQml2)) {
const QmlDirectoryFileEntryFunction qmlFileEntryFunction(options.platform, isDebug);
if (usesQml2) {
- foreach (const QString &module, qmlScanResult.modulesDirectories) {
- if (!updateFile(module, qmlFileEntryFunction, options.directory, options.updateFileFlags, options.json, errorMessage))
+ foreach (const QmlImportScanResult::Module &module, qmlScanResult.modules) {
+ const QString installPath = module.installPath(options.directory);
+ if (optVerboseLevel > 1)
+ std::printf("Installing: '%s' from %s to %s\n",
+ qPrintable(module.name), qPrintable(module.sourcePath), qPrintable(QDir::toNativeSeparators(installPath)));
+ if (installPath != options.directory && !createDirectory(installPath, errorMessage))
+ return result;
+ if (!updateFile(module.sourcePath, qmlFileEntryFunction, installPath, options.updateFileFlags, options.json, errorMessage))
return result;
}
} // Quick 2
diff --git a/src/windeployqt/qmlutils.cpp b/src/windeployqt/qmlutils.cpp
index 1a2ea60b4..aef736364 100644
--- a/src/windeployqt/qmlutils.cpp
+++ b/src/windeployqt/qmlutils.cpp
@@ -52,6 +52,41 @@
QT_BEGIN_NAMESPACE
+// Return the relative install path, that is, for example for
+// module "QtQuick.Controls.Styles" in "path/qtbase/qml/QtQuick/Controls/Styles.3"
+// --> "QtQuick/Controls" suitable for updateFile() (cp -r semantics).
+QString QmlImportScanResult::Module::relativeInstallPath() const
+{
+ const QChar dot = QLatin1Char('.');
+ const QChar slash = QLatin1Char('/');
+
+ // Find relative path by module name.
+ if (!name.contains(dot))
+ return QString(); // "QtQuick.2" -> flat folder.
+ QString result = sourcePath;
+ QString pathComponent = name;
+ pathComponent.replace(dot, slash);
+ const int pos = result.lastIndexOf(pathComponent);
+ if (pos < 0)
+ return QString();
+ result.remove(0, pos);
+ // return base name.
+ const int lastSlash = result.lastIndexOf(slash);
+ if (lastSlash >= 0)
+ result.truncate(lastSlash);
+ return result;
+}
+
+QString QmlImportScanResult::Module::installPath(const QString &root) const
+{
+ QString result = root;
+ const QString relPath = relativeInstallPath();
+ if (!relPath.isEmpty())
+ result += QLatin1Char('/');
+ result += relPath;
+ return result;
+}
+
static QString qmlDirectoryRecursion(Platform platform, const QString &path)
{
QDir dir(path);
@@ -119,7 +154,11 @@ QmlImportScanResult runQmlImportScanner(const QString &directory, const QString
if (object.value(QStringLiteral("type")).toString() == QLatin1String("module")) {
const QString path = object.value(QStringLiteral("path")).toString();
if (!path.isEmpty()) {
- result.modulesDirectories.append(path);
+ QmlImportScanResult::Module module;
+ module.name = object.value(QStringLiteral("name")).toString();
+ module.className = object.value(QStringLiteral("classname")).toString();
+ module.sourcePath = path;
+ result.modules.append(module);
findFileRecursion(QDir(path), Platform(platform), debug, &result.plugins);
}
}
@@ -128,11 +167,20 @@ QmlImportScanResult runQmlImportScanner(const QString &directory, const QString
return result;
}
+static inline bool contains(const QList<QmlImportScanResult::Module> &modules, const QString &name)
+{
+ foreach (const QmlImportScanResult::Module &m, modules) {
+ if (m.name == name)
+ return true;
+ }
+ return false;
+}
+
void QmlImportScanResult::append(const QmlImportScanResult &other)
{
- foreach (const QString &module, other.modulesDirectories) {
- if (!modulesDirectories.contains(module))
- modulesDirectories.append(module);
+ foreach (const QmlImportScanResult::Module &module, other.modules) {
+ if (!contains(modules, module.name))
+ modules.append(module);
}
foreach (const QString &plugin, other.plugins) {
if (!plugins.contains(plugin))
diff --git a/src/windeployqt/qmlutils.h b/src/windeployqt/qmlutils.h
index ea8c7747d..1752d2717 100644
--- a/src/windeployqt/qmlutils.h
+++ b/src/windeployqt/qmlutils.h
@@ -49,11 +49,20 @@ QT_BEGIN_NAMESPACE
QString findQmlDirectory(int platform, const QString &startDirectoryName);
struct QmlImportScanResult {
+ struct Module {
+ QString relativeInstallPath() const;
+ QString installPath(const QString &root) const;
+
+ QString name;
+ QString className;
+ QString sourcePath;
+ };
+
QmlImportScanResult() : ok(false) {}
void append(const QmlImportScanResult &other);
bool ok;
- QStringList modulesDirectories;
+ QList<Module> modules;
QStringList plugins;
};