Browse Source

Add extra Qt plugins manually (#152)

Added posibility for developer to deploy aditional Qt plugins through a
list of plugins directories and plugins, relative path to the Qt plugins
directory
master
Verban Adrian 7 years ago
committed by probonopd
parent
commit
122eaca6d5
  1. 31
      tools/linuxdeployqt/main.cpp
  2. 31
      tools/linuxdeployqt/shared.cpp
  3. 1
      tools/linuxdeployqt/shared.h

31
tools/linuxdeployqt/main.cpp

@ -47,16 +47,20 @@ int main(int argc, char **argv)
qDebug() << "Usage: linuxdeployqt <app-binary|desktop file> [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=<path> : Let the given executable use the deployed libraries too";
qDebug() << " -qmldir=<path> : Scan for QML imports in the given path";
qDebug() << " -always-overwrite : Copy files even if the target file exists";
qDebug() << " -qmake=<path> : 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=<path> : Let the given executable use the deployed libraries";
qDebug() << " too";
qDebug() << " -qmldir=<path> : Scan for QML imports in the given path";
qDebug() << " -always-overwrite : Copy files even if the target file exists";
qDebug() << " -qmake=<path> : The qmake executable to use";
qDebug() << " -no-translations : Skip deployment of translations.";
qDebug() << " -extra-plugins=<list> : 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;

31
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) {

1
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
{

Loading…
Cancel
Save