Skip to content

Commit 9bdf51f

Browse files
committed
Allow to deploy specific platform plugins
1 parent 43c69b0 commit 9bdf51f

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Just like all linuxdeploy plugins, the Qt plugin's behavior can be configured so
5757
**Qt specific:**
5858
- `$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`)
5959
- `$EXTRA_QT_PLUGINS=pluginA;pluginB`: Plugins to deploy even if not found automatically by linuxdeploy-plugin-qt
60+
- `$PLATFORM_PLUGIN=pltformA.so;platformB.so`: Platforms to deploy, defaults to `libqxcb.so`. Platform must be available from `QT_INSTALL_PLUGINS/platforms`.
6061

6162
QML related:
6263
- `$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.

ci/test.sh

+11
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,15 @@ pushd linuxdeploy-plugin-qt-examples/QtWidgetsApplication
9292
"$LINUXDEPLOY_BIN" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
9393
mv -v *AppImage "$BUILD_DIR" || exit 1
9494
popd
95+
96+
mkdir build-platforms
97+
pushd build-platforms
98+
export PLATFORM_PLUGINS="libqoffscreen.so;libqxcb.so"
99+
qmake CONFIG+=release PREFIX=/usr ../QtWidgetsApplication.pro || exit 1
100+
INSTALL_ROOT="$PWD"/AppDir make install || exit 1
101+
102+
"$LINUXDEPLOY_BIN" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1
103+
APPIMAGE=(*AppImage)
104+
mv -v "${APPIMAGE[0]}" "$BUILD_DIR/offscreen-${APPIMAGE[0]}" || exit 1
105+
popd
95106
popd

src/deployers/PlatformPluginsDeployer.cpp

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
11
// library headers
22
#include <linuxdeploy/core/log.h>
3-
#include <boost/filesystem.hpp>
43

54
// local headers
65
#include "PlatformPluginsDeployer.h"
6+
#include "linuxdeploy/util/util.h"
77

88
using namespace linuxdeploy::plugin::qt;
99
using namespace linuxdeploy::core::log;
1010

1111
namespace bf = boost::filesystem;
1212

13+
PlatformPluginsDeployer::PlatformPluginsDeployer(std::string moduleName,
14+
core::appdir::AppDir& appDir,
15+
bf::path qtPluginsPath,
16+
bf::path qtLibexecsPath,
17+
bf::path installLibsPath,
18+
bf::path qtTranslationsPath,
19+
bf::path qtDataPath):
20+
BasicPluginsDeployer(std::move(moduleName),
21+
appDir,
22+
std::move(qtPluginsPath),
23+
std::move(qtLibexecsPath),
24+
std::move(installLibsPath),
25+
std::move(qtTranslationsPath),
26+
std::move(qtDataPath)) {
27+
// check if the platform plugins are set in env
28+
const auto* const platformPluginsFromEnvData = getenv("PLATFORM_PLUGINS");
29+
if (platformPluginsFromEnvData != nullptr)
30+
platformToDeploy = linuxdeploy::util::split(std::string(platformPluginsFromEnvData), ';');
31+
else {
32+
// default to libqxcb if nothing is provided
33+
platformToDeploy.emplace_back("libqxcb.so");
34+
}
35+
}
36+
1337
bool PlatformPluginsDeployer::deploy() {
1438
// calling the default code is optional, but it won't hurt for now
1539
if (!BasicPluginsDeployer::deploy())
1640
return false;
1741

1842
ldLog() << "Deploying platform plugins" << std::endl;
43+
for (auto& platform : platformToDeploy) {
44+
if (!appDir.deployLibrary(qtPluginsPath / "platforms" / platform, appDir.path() / "usr/plugins/platforms/"))
45+
return false;
46+
}
1947

20-
if (!appDir.deployLibrary(qtPluginsPath / "platforms/libqxcb.so", appDir.path() / "usr/plugins/platforms/"))
21-
return false;
2248

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

src/deployers/PlatformPluginsDeployer.h

+14-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ namespace linuxdeploy {
66
namespace plugin {
77
namespace qt {
88
class PlatformPluginsDeployer : public BasicPluginsDeployer {
9+
private:
10+
std::vector<std::string> platformToDeploy;
11+
912
public:
10-
// we can just use the base class's constructor
11-
using BasicPluginsDeployer::BasicPluginsDeployer;
13+
/**
14+
* Default constructor. Constructs a PlatformPluginsDeployer.
15+
*
16+
* @param moduleName
17+
*/
18+
explicit PlatformPluginsDeployer(std::string moduleName, core::appdir::AppDir& appDir,
19+
boost::filesystem::path qtPluginsPath,
20+
boost::filesystem::path qtLibexecsPath,
21+
boost::filesystem::path installLibsPath,
22+
boost::filesystem::path qtTranslationsPath,
23+
boost::filesystem::path qtDataPath);
1224

1325
bool deploy() override;
1426
};

0 commit comments

Comments
 (0)