diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-04-28 14:07:51 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-06 08:41:45 +0200 |
commit | 9758c7764e0e134cb4e626ad601c95da3f8d2aa1 (patch) | |
tree | b9af324a741405655009749bb562d794c7bf48ff | |
parent | 5d2ffacdfd718cc1cc64c76e74048854f1b59192 (diff) | |
download | qttools-9758c7764e0e134cb4e626ad601c95da3f8d2aa1.tar.gz |
No longer deploy image files and sources of QML imports.
These files can be omitted for the Qt Quick Controls and
Qt Quick Dialogs modules.
Task-number: QTBUG-28766
Task-number: QTBUG-31565
Change-Id: Id02939a7124cd5db83d81dcc59663ddf4d091f70
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r-- | src/windeployqt/main.cpp | 22 | ||||
-rw-r--r-- | src/windeployqt/utils.h | 27 |
2 files changed, 41 insertions, 8 deletions
diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp index b0972e22f..6e72d56d6 100644 --- a/src/windeployqt/main.cpp +++ b/src/windeployqt/main.cpp @@ -571,14 +571,23 @@ private: // QML import trees: DLLs (matching debgug) and .qml/,js, etc. class QmlDirectoryFileEntryFunction { public: - explicit QmlDirectoryFileEntryFunction(Platform platform, bool debug) - : m_qmlNameFilter(QStringList() << QStringLiteral("*.js") << QStringLiteral("qmldir") << QStringLiteral("*.qml") << QStringLiteral("*.qmltypes") << QStringLiteral("*.png")) + explicit QmlDirectoryFileEntryFunction(Platform platform, bool debug, bool skipQmlSources = false) + : m_qmlNameFilter(QmlDirectoryFileEntryFunction::qmlNameFilters(skipQmlSources)) , m_dllFilter(platform, debug) {} QStringList operator()(const QDir &dir) const { return m_dllFilter(dir) + m_qmlNameFilter(dir); } private: + static inline QStringList qmlNameFilters(bool skipQmlSources) + { + QStringList result; + result << QStringLiteral("qmldir") << QStringLiteral("*.qmltypes"); + if (!skipQmlSources) + result << QStringLiteral("*.js") << QStringLiteral("*.qml") << QStringLiteral("*.png"); + return result; + } + NameFilterFileEntryFunction m_qmlNameFilter; DllDirectoryFileEntryFunction m_dllFilter; }; @@ -1048,7 +1057,14 @@ static DeployResult deploy(const Options &options, << QDir::toNativeSeparators(installPath) << '\n'; if (installPath != options.directory && !createDirectory(installPath, errorMessage)) return result; - if (!updateFile(module.sourcePath, qmlFileEntryFunction, installPath, options.updateFileFlags, options.json, errorMessage)) + const bool updateResult = module.sourcePath.contains(QLatin1String("QtQuick/Controls")) + || module.sourcePath.contains(QLatin1String("QtQuick/Dialogs")) ? + updateFile(module.sourcePath, QmlDirectoryFileEntryFunction(options.platform, isDebug, true), + installPath, options.updateFileFlags | RemoveEmptyQmlDirectories, + options.json, errorMessage) : + updateFile(module.sourcePath, qmlFileEntryFunction, installPath, options.updateFileFlags, + options.json, errorMessage); + if (!updateResult) return result; } } // Quick 2 diff --git a/src/windeployqt/utils.h b/src/windeployqt/utils.h index a69036158..8a520c7e1 100644 --- a/src/windeployqt/utils.h +++ b/src/windeployqt/utils.h @@ -201,7 +201,8 @@ extern int optVerboseLevel; // to obtain the files. enum UpdateFileFlag { ForceUpdateFile = 0x1, - SkipUpdateFile = 0x2 + SkipUpdateFile = 0x2, + RemoveEmptyQmlDirectories = 0x4 }; template <class DirectoryFileEntryFunction> @@ -257,6 +258,7 @@ bool updateFile(const QString &sourceFileName, } // Source is symbolic link if (sourceFileInfo.isDir()) { + bool created = false; if (targetFileInfo.exists()) { if (!targetFileInfo.isDir()) { *errorMessage = QString::fromLatin1("%1 already exists and is not a directory.") @@ -267,10 +269,13 @@ bool updateFile(const QString &sourceFileName, QDir d(targetDirectory); if (optVerboseLevel) std::wcout << "Creating " << targetFileName << ".\n"; - if (!(flags & SkipUpdateFile) && !d.mkdir(sourceFileInfo.fileName())) { - *errorMessage = QString::fromLatin1("Cannot create directory %1 under %2.") - .arg(sourceFileInfo.fileName(), QDir::toNativeSeparators(targetDirectory)); - return false; + if (!(flags & SkipUpdateFile)) { + created = d.mkdir(sourceFileInfo.fileName()); + if (!created) { + *errorMessage = QString::fromLatin1("Cannot create directory %1 under %2.") + .arg(sourceFileInfo.fileName(), QDir::toNativeSeparators(targetDirectory)); + return false; + } } } // Recurse into directory @@ -280,6 +285,18 @@ bool updateFile(const QString &sourceFileName, foreach (const QString &entry, allEntries) if (!updateFile(sourceFileName + QLatin1Char('/') + entry, directoryFileEntryFunction, targetFileName, flags, json, errorMessage)) return false; + // Remove empty directories, for example QML import folders for which the filter did not match. + if (created && (flags & RemoveEmptyQmlDirectories)) { + QDir d(targetFileName); + const QStringList entries = d.entryList(QStringList(), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + if (entries.isEmpty() || (entries.size() == 1 && entries.first() == QLatin1String("qmldir"))) { + if (!d.removeRecursively()) { + *errorMessage = QString::fromLatin1("Cannot remove empty directory %1.") + .arg(QDir::toNativeSeparators(targetFileName)); + return false; + } + } + } return true; } // Source is directory. |