From 4b8dac88581f225fa49bd5bb94fd6315e946dfff Mon Sep 17 00:00:00 2001 From: Pablo Duboue Date: Sun, 24 Dec 2023 08:13:17 -0800 Subject: [PATCH] Allow recursive folder addition of executables (closes #379) --- BUILDING.md | 4 ++-- README.md | 2 ++ tools/linuxdeployqt/main.cpp | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 1c98d0ec..6c4bc0a6 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -4,7 +4,7 @@ If you just would like to bundle your application for x86_64 platforms, it is no So, if you are on another platform (e.g. i686, ARM) or would like to compile from source, here are the steps: -* Get and build linuxdeployqt e.g., using Qt 5.7.0 (you could use this [Qt Creator AppImage](https://bintray.com/probono/AppImages/QtCreator#files) for this) +* Get and build linuxdeployqt e.g., using Qt 5.7.0 (before you could use this [Qt Creator AppImage](https://bintray.com/probono/AppImages/QtCreator#files) for this, but it is no longer available) ``` sudo apt-get -y install git g++ libgl1-mesa-dev @@ -22,7 +22,7 @@ make sudo make install ``` -* Build and install [patchelf](https://nixos.org/patchelf.html) (a small utility to modify the dynamic linker and RPATH of ELF executables; similar to `install_name_tool` on macOS). To learn more about this, see http://blog.qt.io/blog/2011/10/28/rpath-and-runpath/ +* Build and install [patchelf](https://nixos.org/patchelf.html) (a small utility to modify the dynamic linker and RPATH of ELF executables; similar to `install_name_tool` on macOS). To learn more about this, see http://blog.qt.io/blog/2011/10/28/rpath-and-runpath/. Also available as Debian package `patchelf`. ``` wget https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2 diff --git a/README.md b/README.md index 18d3e847..b2e10003 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ Options: searching for libraries. -executable= : Let the given executable use the deployed libraries too + -executable-dir= : Let all the executables in the folder (recursive) use + the deployed libraries too -extra-plugins= : List of extra plugins which should be deployed, separated by comma. -no-copy-copyright-files : Skip deployment of copyright files. diff --git a/tools/linuxdeployqt/main.cpp b/tools/linuxdeployqt/main.cpp index 98d4b589..810ba60d 100644 --- a/tools/linuxdeployqt/main.cpp +++ b/tools/linuxdeployqt/main.cpp @@ -63,6 +63,7 @@ int main(int argc, char **argv) extern QStringList librarySearchPath; extern bool alwaysOwerwriteEnabled; QStringList additionalExecutables; + QStringList additionalExecutablesDir; bool qmldirArgumentUsed = false; bool skipTranslations = false; bool skipGlibcCheck = false; @@ -120,6 +121,13 @@ int main(int argc, char **argv) LogError() << "Could not parse verbose level"; else logLevel = number; + } else if (argument.startsWith(QByteArray("-executable-dir"))) { + LogDebug() << "Argument found:" << argument; + int index = argument.indexOf('='); + if (index == -1) + LogError() << "Missing executable folder path"; + else + additionalExecutablesDir << argument.mid(index+1); } else if (argument.startsWith(QByteArray("-executable"))) { LogDebug() << "Argument found:" << argument; int index = argument.indexOf('='); @@ -228,6 +236,8 @@ int main(int argc, char **argv) qInfo() << " searching for libraries."; qInfo() << " -executable= : Let the given executable use the deployed libraries"; qInfo() << " too"; + qInfo() << " -executable-dir= : Let all the executables in the folder (recursive) use"; + qInfo() << " the deployed libraries too"; qInfo() << " -extra-plugins= : List of extra plugins which should be deployed,"; qInfo() << " separated by comma."; qInfo() << " -no-copy-copyright-files : Skip deployment of copyright files."; @@ -496,6 +506,19 @@ int main(int argc, char **argv) qWarning() << "WARNING: Excluding the following libraries might break the AppImage. Please double-check the list:" << excludeLibs; } + // recurse folders for additional executables + for(const auto& folder : additionalExecutablesDir) { + QString directoryToBeSearched = QDir::cleanPath(QFileInfo(folder).absolutePath()); + QDirIterator it(directoryToBeSearched, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + if((it.fileInfo().isFile()) && (it.fileInfo().isExecutable())){ + qDebug() << "Found additional executable:" << it.fileInfo().canonicalFilePath(); + additionalExecutables << it.fileInfo().absoluteFilePath(); + } + } + } + DeploymentInfo deploymentInfo = deployQtLibraries(appDirPath, additionalExecutables, qmakeExecutable);