Skip to content

Commit 5843744

Browse files
authored
Merge pull request #253 from saidinesh5/master
Added support for -excludeLibs command line option
2 parents a0886e3 + 572bf78 commit 5843744

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

tools/linuxdeployqt/main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ int main(int argc, char **argv)
8282
qInfo() << " -no-copy-copyright-files : Skip deployment of copyright files.";
8383
qInfo() << " -extra-plugins=<list> : List of extra plugins which should be deployed,";
8484
qInfo() << " separated by comma.";
85+
qInfo() << " -exclude-libs=<list> : List of libraries which should be excluded,";
86+
qInfo() << " separated by comma.";
8587
qInfo() << " -version : Print version statement and exit.";
8688
qInfo() << "";
8789
qInfo() << "linuxdeployqt takes an application as input and makes it";
@@ -207,6 +209,7 @@ int main(int argc, char **argv)
207209
QStringList qmlDirs;
208210
QString qmakeExecutable;
209211
extern QStringList extraQtPlugins;
212+
extern QStringList excludeLibs;
210213
extern bool copyCopyrightFiles;
211214

212215
/* FHS-like mode is for an application that has been installed to a $PREFIX which is otherwise empty, e.g., /path/to/usr.
@@ -416,6 +419,10 @@ int main(int argc, char **argv)
416419
LogDebug() << "Argument found:" << argument;
417420
int index = argument.indexOf("=");
418421
extraQtPlugins = QString(argument.mid(index + 1)).split(",");
422+
} else if (argument.startsWith("-exclude-libs=")) {
423+
LogDebug() << "Argument found:" << argument;
424+
int index = argument.indexOf("=");
425+
excludeLibs = QString(argument.mid(index + 1)).split(",");
419426
} else if (argument.startsWith("--")) {
420427
LogError() << "Error: arguments must not start with --, only -:" << argument << "\n";
421428
return 1;
@@ -432,6 +439,11 @@ int main(int argc, char **argv)
432439
}
433440
}
434441

442+
if (!excludeLibs.isEmpty())
443+
{
444+
qWarning() << "WARNING: Excluding the following libraries might break the AppImage. Please double-check the list:" << excludeLibs;
445+
}
446+
435447
DeploymentInfo deploymentInfo = deployQtLibraries(appDirPath, additionalExecutables,
436448
qmakeExecutable);
437449

tools/linuxdeployqt/shared.cpp

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ int qtDetected = 0;
5858
bool qtDetectionComplete = 0; // As long as Qt is not detected yet, ldd may encounter "not found" messages, continue anyway
5959
bool deployLibrary = false;
6060
QStringList extraQtPlugins;
61+
QStringList excludeLibs;
6162
bool copyCopyrightFiles = true;
6263

6364
using std::cout;
@@ -478,6 +479,7 @@ LibraryInfo parseLddLibraryLine(const QString &line, const QString &appDirPath,
478479
#else
479480
excludelist << EXCLUDELIST;
480481
#endif
482+
excludelist += excludeLibs;
481483

482484
LogDebug() << "excludelist:" << excludelist;
483485
if (! trimmed.contains("libicu")) {
@@ -671,10 +673,13 @@ QList<LibraryInfo> getQtLibrariesForPaths(const QStringList &paths, const QStrin
671673
QSet<QString> existing;
672674

673675
foreach (const QString &path, paths) {
674-
foreach (const LibraryInfo &info, getQtLibraries(path, appDirPath, rpaths)) {
675-
if (!existing.contains(info.libraryPath)) { // avoid duplicates
676-
existing.insert(info.libraryPath);
677-
result << info;
676+
if (!excludeLibs.contains(QFileInfo(path).baseName()))
677+
{
678+
foreach (const LibraryInfo &info, getQtLibraries(path, appDirPath, rpaths)) {
679+
if (!existing.contains(info.libraryPath)) { // avoid duplicates
680+
existing.insert(info.libraryPath);
681+
result << info;
682+
}
678683
}
679684
}
680685
}
@@ -1022,7 +1027,7 @@ DeploymentInfo deployQtLibraries(QList<LibraryInfo> libraries,
10221027
deploymentInfo.qtPath = library.libraryDirectory;
10231028
}
10241029

1025-
if(library.libraryName.contains("libQt") and library.libraryName.contains("Widgets.so")) {
1030+
if(library.libraryName.contains("libQt") and library.libraryName.contains("Widgets.so")) {
10261031
deploymentInfo.requiresQtWidgetsLibrary = true;
10271032
}
10281033

@@ -1399,23 +1404,26 @@ void deployPlugins(const AppDirInfo &appDirInfo, const QString &pluginSourcePath
13991404
foreach (const QString &plugin, pluginList) {
14001405
sourcePath = pluginSourcePath + "/" + plugin;
14011406
destinationPath = pluginDestinationPath + "/" + plugin;
1402-
QDir dir;
1403-
dir.mkpath(QFileInfo(destinationPath).path());
1404-
QList<LibraryInfo> libraries = getQtLibraries(sourcePath, appDirInfo.path, deploymentInfo.rpathsUsed);
1405-
LogDebug() << "Deploying plugin" << sourcePath;
1406-
if (copyFilePrintStatus(sourcePath, destinationPath)) {
1407-
runStrip(destinationPath);
1408-
deployQtLibraries(libraries, appDirInfo.path, QStringList() << destinationPath, deploymentInfo.useLoaderPath);
1409-
/* See whether this makes any difference */
1410-
// Find out the relative path to the lib/ directory and set it as the rpath
1411-
QDir dir(destinationPath);
1412-
QString relativePath = dir.relativeFilePath(appDirInfo.path + "/" + libraries[0].libraryDestinationDirectory);
1413-
relativePath.remove(0, 3); // remove initial '../'
1414-
changeIdentification("$ORIGIN/" + relativePath, QFileInfo(destinationPath).canonicalFilePath());
1407+
if(!excludeLibs.contains(QFileInfo(sourcePath).baseName()))
1408+
{
1409+
QDir dir;
1410+
dir.mkpath(QFileInfo(destinationPath).path());
1411+
QList<LibraryInfo> libraries = getQtLibraries(sourcePath, appDirInfo.path, deploymentInfo.rpathsUsed);
1412+
LogDebug() << "Deploying plugin" << sourcePath;
1413+
if (copyFilePrintStatus(sourcePath, destinationPath)) {
1414+
runStrip(destinationPath);
1415+
deployQtLibraries(libraries, appDirInfo.path, QStringList() << destinationPath, deploymentInfo.useLoaderPath);
1416+
/* See whether this makes any difference */
1417+
// Find out the relative path to the lib/ directory and set it as the rpath
1418+
QDir dir(destinationPath);
1419+
QString relativePath = dir.relativeFilePath(appDirInfo.path + "/" + libraries[0].libraryDestinationDirectory);
1420+
relativePath.remove(0, 3); // remove initial '../'
1421+
changeIdentification("$ORIGIN/" + relativePath, QFileInfo(destinationPath).canonicalFilePath());
14151422

1423+
}
1424+
LogDebug() << "copyCopyrightFile:" << sourcePath;
1425+
copyCopyrightFile(sourcePath);
14161426
}
1417-
LogDebug() << "copyCopyrightFile:" << sourcePath;
1418-
copyCopyrightFile(sourcePath);
14191427
}
14201428
}
14211429

tools/linuxdeployqt/shared.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extern bool bundleAllButCoreLibs;
4646
extern bool fhsLikeMode;
4747
extern QString fhsPrefix;
4848
extern QStringList extraQtPlugins;
49+
extern QStringList excludeLibs;
4950

5051
class LibraryInfo
5152
{

0 commit comments

Comments
 (0)