Skip to content

Allow installation of extra platform plugins #118

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

Merged
merged 3 commits into from
Aug 26, 2022
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Just like all linuxdeploy plugins, the Qt plugin's behavior can be configured so
**Qt specific:**
- `$QMAKE=/path/to/my/qmake`: use another `qmake` binary to detect paths of plugins and other resources (usually doesn't need to be set manually, most Qt environments ship scripts changing `$PATH`)
- `$EXTRA_QT_PLUGINS=pluginA;pluginB`: Plugins to deploy even if not found automatically by linuxdeploy-plugin-qt
- `$EXTRA_PLATFORM_PLUGINS=platformA;platformB`: Platforms to deploy in addition to `libqxcb.so`. Platform must be available from `QT_INSTALL_PLUGINS/platforms`.

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.
Expand Down
10 changes: 10 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,14 @@ pushd linuxdeploy-plugin-qt-examples/QtWidgetsApplication
"$linuxdeploy_bin" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
mv -v *AppImage "$build_dir" || exit 1
popd

mkdir build-platforms
pushd build-platforms
export EXTRA_PLATFORM_PLUGINS="libqoffscreen.so;libqminimal.so"
qmake CONFIG+=release PREFIX=/usr ../QtWidgetsApplication.pro || exit 1
INSTALL_ROOT="$PWD"/AppDir make install || exit 1

env OUTPUT=platforms.AppImage "$linuxdeploy_bin" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
mv -v platforms.AppImage "$build_dir" || exit 1
popd
popd
12 changes: 12 additions & 0 deletions src/deployers/PlatformPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// library headers
#include <linuxdeploy/core/log.h>
#include <linuxdeploy/util/util.h>
#include <boost/filesystem.hpp>

// local headers
Expand All @@ -17,9 +18,20 @@ bool PlatformPluginsDeployer::deploy() {

ldLog() << "Deploying platform plugins" << std::endl;

// always deploy default platform
if (!appDir.deployLibrary(qtPluginsPath / "platforms/libqxcb.so", appDir.path() / "usr/plugins/platforms/"))
return false;

// deploy extra platform plugins, if any
const auto* const platformPluginsFromEnvData = getenv("EXTRA_PLATFORM_PLUGINS");
if (platformPluginsFromEnvData != nullptr) {
for (const auto& platformToDeploy : linuxdeploy::util::split(std::string(platformPluginsFromEnvData), ';')) {
ldLog() << "Deploying extra platform plugin: " << platformToDeploy << std::endl;
if (!appDir.deployLibrary(qtPluginsPath / "platforms" / platformToDeploy, appDir.path() / "usr/plugins/platforms/"))
return false;
}
}

for (bf::directory_iterator i(qtPluginsPath / "platforminputcontexts"); i != bf::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/platforminputcontexts/"))
return false;
Expand Down