From 07f1dcc26ee98cc49f767cb92e7185e96e6ef254 Mon Sep 17 00:00:00 2001 From: jkennedyvz <65985482+jkennedyvz@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:06:00 -0700 Subject: [PATCH 1/2] Add option to exclude specific plugins and handle missing dependencies as warnings --- README.md | 2 ++ src/deployers/SqlPluginsDeployer.cpp | 25 +++++++++++++++++++++++-- src/main.cpp | 3 +++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9780f80..9ccc744 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,9 @@ Just like all linuxdeploy plugins, the Qt plugin's behavior can be configured so - `$EXTRA_QT_PLUGINS=pluginA;pluginB`: Plugins to deploy even if not found automatically by linuxdeploy-plugin-qt - example: `EXTRA_QT_PLUGINS=svg;` if you want to use the module [QtSvg](https://doc.qt.io/qt-5/qtsvg-index.html) - `$EXTRA_PLATFORM_PLUGINS=platformA;platformB`: Platforms to deploy in addition to `libqxcb.so`. Platform must be available from `QT_INSTALL_PLUGINS/platforms`. +- `$EXCLUDE_QT_PLUGINS=pluginA;pluginB`: Specify Qt plugins to exclude from deployment. Useful for excluding specific SQL drivers or other plugins not needed by the application. QML related: - `$QML_SOURCES_PATHS`: directory containing the application's QML files — useful/needed if QML files are "baked" into the binaries. `$QT_INSTALL_QML` is prepended to this list internally. - `$QML_MODULES_PATHS`: extra directories containing imported QML files (normally doesn't need to be specified). +- Missing dependencies of a plugin are now handled as a non-fatal error, emitting a warning instead. This allows the build process to continue even if some plugins have unmet dependencies, which can be particularly useful for plugins that are not essential for the application's functionality. diff --git a/src/deployers/SqlPluginsDeployer.cpp b/src/deployers/SqlPluginsDeployer.cpp index 6d0111b..d2880be 100644 --- a/src/deployers/SqlPluginsDeployer.cpp +++ b/src/deployers/SqlPluginsDeployer.cpp @@ -1,5 +1,6 @@ // system headers #include +#include // Include set for handling exclusions // library headers #include @@ -19,9 +20,29 @@ bool SqlPluginsDeployer::deploy() { ldLog() << "Deploying SQL plugins" << std::endl; + // Retrieve the list of plugins to exclude from the environment + std::set excludedPlugins; + if (const char* env_p = std::getenv("LINUXDEPLOY_EXCLUDE_SQL_PLUGINS")) { + std::string excluded(env_p); + std::istringstream iss(excluded); + std::string plugin; + while (std::getline(iss, plugin, ';')) { + excludedPlugins.insert(plugin); + } + } + for (fs::directory_iterator i(qtPluginsPath / "sqldrivers"); i != fs::directory_iterator(); ++i) { - if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/sqldrivers/")) - return false; + // Check if the current plugin is in the list of excluded plugins + if (excludedPlugins.find(i->path().filename().string()) != excludedPlugins.end()) { + ldLog() << "Excluding SQL plugin:" << i->path().filename() << std::endl; + continue; // Skip deploying this plugin + } + + // Attempt to deploy the plugin, emitting a warning instead of failing on missing dependencies + if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/sqldrivers/", true)) { + ldLog() << LD_WARNING << "Could not deploy SQL plugin due to missing dependencies:" << i->path().filename() << std::endl; + continue; // Proceed with the next plugin instead of returning false + } } return true; diff --git a/src/main.cpp b/src/main.cpp index 5076d6a..f851bd1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,6 +40,9 @@ int main(const int argc, const char *const *const argv) { args::ValueFlagList extraPlugins(parser, "plugin", "Extra Qt plugin to deploy (specified by name, filename or path)", {'p', "extra-plugin"}); + args::ValueFlagList excludePlugins(parser, "plugin", + "Qt plugin to exclude from deployment (specified by name, filename or path)", + {'e', "exclude-plugin"}); args::Flag pluginType(parser, "", "Print plugin type and exit", {"plugin-type"}); args::Flag pluginApiVersion(parser, "", "Print plugin API version and exit", {"plugin-api-version"}); From f74b3089c7b918a886e890b3bfe27f75e6a4c1e3 Mon Sep 17 00:00:00 2001 From: jkennedyvz <65985482+jkennedyvz@users.noreply.github.com> Date: Mon, 3 Jun 2024 23:41:09 -0700 Subject: [PATCH 2/2] Fix incorrect number of arguments in deployLibrary call --- src/deployers/SqlPluginsDeployer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deployers/SqlPluginsDeployer.cpp b/src/deployers/SqlPluginsDeployer.cpp index d2880be..d28825c 100644 --- a/src/deployers/SqlPluginsDeployer.cpp +++ b/src/deployers/SqlPluginsDeployer.cpp @@ -39,7 +39,7 @@ bool SqlPluginsDeployer::deploy() { } // Attempt to deploy the plugin, emitting a warning instead of failing on missing dependencies - if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/sqldrivers/", true)) { + if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/sqldrivers/")) { ldLog() << LD_WARNING << "Could not deploy SQL plugin due to missing dependencies:" << i->path().filename() << std::endl; continue; // Proceed with the next plugin instead of returning false }