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..d28825c 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/")) { + 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"});