From f90080704beb4bde91d05c4eec2c417f604385cb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Nov 2013 13:49:20 +0100 Subject: [PATCH] windeployqt: Introduce constants and functions for shared library suffixes. Change-Id: Ic0792d0935115ab8554288979adabd17ea8cf863 Reviewed-by: Joerg Bornemann --- src/windeployqt/main.cpp | 22 +++++++++++++++------- src/windeployqt/utils.cpp | 2 +- src/windeployqt/utils.h | 5 +++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp index 614f030..d8d4f8b 100644 --- a/src/windeployqt/main.cpp +++ b/src/windeployqt/main.cpp @@ -444,7 +444,7 @@ static bool findDependentQtLibraries(const QString &qtBinDir, const QString &bin class DllDirectoryFileEntryFunction { public: explicit DllDirectoryFileEntryFunction(bool debug, const QString &prefix = QLatin1String("*")) : - m_nameFilter(QStringList(prefix + (debug ? QStringLiteral("d.dll") : QStringLiteral(".dll")))), + m_nameFilter(DllDirectoryFileEntryFunction::nameFilter(debug, prefix)), m_dllDebug(debug) {} QStringList operator()(const QDir &dir) const @@ -467,6 +467,15 @@ public: } private: + static QStringList nameFilter(bool debug, const QString &prefix) + { + QString result = prefix; + if (debug) + result += QLatin1Char('d'); + result += QLatin1String(windowsSharedLibrarySuffix); + return QStringList(result); + } + const NameFilterFileEntryFunction m_nameFilter; const bool m_dllDebug; }; @@ -543,9 +552,9 @@ QStringList findQtPlugins(unsigned usedQtModules, } else { filter = QLatin1String("*"); } - const QStringList plugins = platform == Unix ? - NameFilterFileEntryFunction(QStringList(filter + QStringLiteral(".so")))(subDir) : - DllDirectoryFileEntryFunction(debug, filter)(subDir); + const QStringList plugins = (platform & WindowsBased) ? + DllDirectoryFileEntryFunction(debug, filter)(subDir) : + NameFilterFileEntryFunction(QStringList(filter + sharedLibrarySuffix(platform)))(subDir); foreach (const QString &plugin, plugins) { const QString pluginPath = subDir.absoluteFilePath(plugin); if (isPlatformPlugin) @@ -642,12 +651,11 @@ static QString libraryPath(const QString &libraryLocation, const char *name, Pla result += QLatin1String(name); if (debug) result += QLatin1Char('d'); - result += QStringLiteral(".dll"); } else if (platform & UnixBased) { result += QStringLiteral("lib"); result += QLatin1String(name); - result += QStringLiteral(".so"); } + result += sharedLibrarySuffix(platform); return result; } @@ -697,7 +705,7 @@ static DeployResult deploy(const Options &options, const QString icuVersion = icuLibs.front().mid(index, numberExpression.matchedLength()); if (optVerboseLevel > 1) std::printf("Adding ICU version %s\n", qPrintable(icuVersion)); - icuLibs.push_back(QStringLiteral("icudt") + icuVersion + QStringLiteral(".dll")); + icuLibs.push_back(QStringLiteral("icudt") + icuVersion + QLatin1String(windowsSharedLibrarySuffix)); } foreach (const QString &icuLib, icuLibs) { const QString icuPath = findInPath(icuLib); diff --git a/src/windeployqt/utils.cpp b/src/windeployqt/utils.cpp index aa18785..c054fa7 100644 --- a/src/windeployqt/utils.cpp +++ b/src/windeployqt/utils.cpp @@ -762,7 +762,7 @@ bool readPeExecutable(const QString &peExecutableFileName, QString *errorMessage QString findD3dCompiler(Platform platform, unsigned wordSize) { const QString prefix = QStringLiteral("D3Dcompiler_"); - const QString suffix = QStringLiteral(".dll"); + const QString suffix = QLatin1String(windowsSharedLibrarySuffix); // Get the DLL from Kit 8.0 onwards const QString kitDir = QString::fromLocal8Bit(qgetenv("WindowsSdkDir")); if (!kitDir.isEmpty()) { diff --git a/src/windeployqt/utils.h b/src/windeployqt/utils.h index 208216c..5f789c6 100644 --- a/src/windeployqt/utils.h +++ b/src/windeployqt/utils.h @@ -101,6 +101,11 @@ QString findSdkTool(const QString &tool); inline QString normalizeFileName(const QString &name) { return name; } #endif // !Q_OS_WIN +static const char windowsSharedLibrarySuffix[] = ".dll"; +static const char unixSharedLibrarySuffix[] = ".so"; + +inline QString sharedLibrarySuffix(Platform platform) { return QLatin1String((platform & WindowsBased) ? windowsSharedLibrarySuffix : unixSharedLibrarySuffix); } + bool createSymbolicLink(const QFileInfo &source, const QString &target, QString *errorMessage); bool createDirectory(const QString &directory, QString *errorMessage); QString findInPath(const QString &file); -- 2.7.4