Skip to content

Commit

Permalink
Allow installation of extra platform plugins (#118)
Browse files Browse the repository at this point in the history
* Allow installation of extra platform plugins

Resolves #88

* Address review comments

* Update test
  • Loading branch information
asl authored Aug 26, 2022
1 parent 1353c5c commit 76a163b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
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

0 comments on commit 76a163b

Please sign in to comment.