diff --git a/tools/linuxdeployqt/main.cpp b/tools/linuxdeployqt/main.cpp index 2701543..745c651 100644 --- a/tools/linuxdeployqt/main.cpp +++ b/tools/linuxdeployqt/main.cpp @@ -47,16 +47,20 @@ int main(int argc, char **argv) qDebug() << "Usage: linuxdeployqt [options]"; qDebug() << ""; qDebug() << "Options:"; - qDebug() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug"; - qDebug() << " -no-plugins : Skip plugin deployment"; - qDebug() << " -appimage : Create an AppImage (implies -bundle-non-qt-libs)"; - qDebug() << " -no-strip : Don't run 'strip' on the binaries"; - qDebug() << " -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries"; - qDebug() << " -executable= : Let the given executable use the deployed libraries too"; - qDebug() << " -qmldir= : Scan for QML imports in the given path"; - qDebug() << " -always-overwrite : Copy files even if the target file exists"; - qDebug() << " -qmake= : The qmake executable to use"; - qDebug() << " -no-translations : Skip deployment of translations."; + qDebug() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default),"; + qDebug() << " 2 = normal, 3 = debug"; + qDebug() << " -no-plugins : Skip plugin deployment"; + qDebug() << " -appimage : Create an AppImage (implies -bundle-non-qt-libs)"; + qDebug() << " -no-strip : Don't run 'strip' on the binaries"; + qDebug() << " -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries"; + qDebug() << " -executable= : Let the given executable use the deployed libraries"; + qDebug() << " too"; + qDebug() << " -qmldir= : Scan for QML imports in the given path"; + qDebug() << " -always-overwrite : Copy files even if the target file exists"; + qDebug() << " -qmake= : The qmake executable to use"; + qDebug() << " -no-translations : Skip deployment of translations."; + qDebug() << " -extra-plugins= : List of extra plugins which should be deployed,"; + qDebug() << " separated by comma."; qDebug() << ""; qDebug() << "linuxdeployqt takes an application as input and makes it"; qDebug() << "self-contained by copying in the Qt libraries and plugins that"; @@ -173,13 +177,14 @@ int main(int argc, char **argv) extern bool bundleAllButCoreLibs; extern bool fhsLikeMode; extern QString fhsPrefix; - extern bool alwaysOwerwriteEnabled; extern QStringList librarySearchPath; + extern bool alwaysOwerwriteEnabled; QStringList additionalExecutables; bool qmldirArgumentUsed = false; bool skipTranslations = false; QStringList qmlDirs; QString qmakeExecutable; + extern QStringList extraQtPlugins; /* FHS-like mode is for an application that has been installed to a $PREFIX which is otherwise empty, e.g., /path/to/usr. * In this case, we want to construct an AppDir in /path/to. */ @@ -381,6 +386,10 @@ int main(int argc, char **argv) } else if (argument == QByteArray("-no-translations")) { LogDebug() << "Argument found:" << argument; skipTranslations = true; + } else if (argument.startsWith("-extra-plugins=")) { + LogDebug() << "Argument found:" << argument; + int index = argument.indexOf("="); + extraQtPlugins = QString(argument.mid(index+1)).split(","); } else if (argument.startsWith("-")) { LogError() << "Unknown argument" << argument << "\n"; return 1; diff --git a/tools/linuxdeployqt/shared.cpp b/tools/linuxdeployqt/shared.cpp index bbb6bde..3dbc924 100644 --- a/tools/linuxdeployqt/shared.cpp +++ b/tools/linuxdeployqt/shared.cpp @@ -57,6 +57,7 @@ int logLevel = 1; int qtDetected = 0; bool qtDetectionComplete = 0; // As long as Qt is not detected yet, ldd may encounter "not found" messages, continue anyway bool deployLibrary = false; +QStringList extraQtPlugins; using std::cout; using std::endl; @@ -1336,6 +1337,36 @@ void deployPlugins(const AppDirInfo &appDirInfo, const QString &pluginSourcePath recursiveCopy(sourcePath, destinationPath); } + if (!extraQtPlugins.isEmpty()) { + LogNormal() << "Deploying extra plugins."; + foreach (const QString &plugin, extraQtPlugins) { + QDir pluginDirectory(pluginSourcePath + "/" + plugin); + if (pluginDirectory.exists()) { + //If it is a plugin directory we will deploy the entire directory + QStringList plugins = pluginDirectory.entryList(QStringList() << QStringLiteral("*.so")); + foreach (const QString &pluginFile, plugins) { + pluginList.append(plugin + "/" + pluginFile); + LogDebug() << plugin + "/" + pluginFile << "appended"; + } + } + else { + //If it isn't a directory we asume it is an explicit plugin and we will try to deploy that + if (!pluginList.contains(plugin)) { + if (QFile::exists(pluginSourcePath + "/" + plugin)) { + pluginList.append(plugin); + LogDebug() << plugin << "appended"; + } + else { + LogDebug() << "The plugin" << plugin << "was already deployed." ; + } + } + else { + LogWarning() << "The plugin" << pluginSourcePath + "/" + plugin << "could not be found. Please check spelling and try again!"; + } + } + } + } + LogNormal() << "pluginList after having detected hopefully all required plugins:" << pluginList; foreach (const QString &plugin, pluginList) { diff --git a/tools/linuxdeployqt/shared.h b/tools/linuxdeployqt/shared.h index ddebd54..5e0b212 100644 --- a/tools/linuxdeployqt/shared.h +++ b/tools/linuxdeployqt/shared.h @@ -45,6 +45,7 @@ extern bool runStripEnabled; extern bool bundleAllButCoreLibs; extern bool fhsLikeMode; extern QString fhsPrefix; +extern QStringList extraQtPlugins; class LibraryInfo {