Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to exclude specific plugins and handle missing dependencies as warnings #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
25 changes: 23 additions & 2 deletions src/deployers/SqlPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// system headers
#include <filesystem>
#include <set> // Include set for handling exclusions

// library headers
#include <linuxdeploy/core/log.h>
Expand All @@ -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<std::string> 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;
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ int main(const int argc, const char *const *const argv) {
args::ValueFlagList<std::string> extraPlugins(parser, "plugin",
"Extra Qt plugin to deploy (specified by name, filename or path)",
{'p', "extra-plugin"});
args::ValueFlagList<std::string> 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"});
Expand Down