From 9bdf51fd2cb992b88e9fc2c33563ab52cf89c982 Mon Sep 17 00:00:00 2001 From: Dorian Date: Mon, 22 Mar 2021 11:56:57 +0000 Subject: [PATCH] Allow to deploy specific platform plugins --- README.md | 1 + ci/test.sh | 11 ++++++++ src/deployers/PlatformPluginsDeployer.cpp | 32 ++++++++++++++++++++--- src/deployers/PlatformPluginsDeployer.h | 16 ++++++++++-- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5b6965e..8f8f65a 100644 --- a/README.md +++ b/README.md @@ -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 +- `$PLATFORM_PLUGIN=pltformA.so;platformB.so`: Platforms to deploy, defaults 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. diff --git a/ci/test.sh b/ci/test.sh index 3db5961..11ef66e 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -92,4 +92,15 @@ 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 PLATFORM_PLUGINS="libqoffscreen.so;libqxcb.so" + qmake CONFIG+=release PREFIX=/usr ../QtWidgetsApplication.pro || exit 1 + INSTALL_ROOT="$PWD"/AppDir make install || exit 1 + + "$LINUXDEPLOY_BIN" --appdir "$PWD"/AppDir --plugin qt --output appimage || exit 1 + APPIMAGE=(*AppImage) + mv -v "${APPIMAGE[0]}" "$BUILD_DIR/offscreen-${APPIMAGE[0]}" || exit 1 + popd popd diff --git a/src/deployers/PlatformPluginsDeployer.cpp b/src/deployers/PlatformPluginsDeployer.cpp index 711ed4a..8ae6402 100644 --- a/src/deployers/PlatformPluginsDeployer.cpp +++ b/src/deployers/PlatformPluginsDeployer.cpp @@ -1,24 +1,50 @@ // library headers #include -#include // local headers #include "PlatformPluginsDeployer.h" +#include "linuxdeploy/util/util.h" using namespace linuxdeploy::plugin::qt; using namespace linuxdeploy::core::log; namespace bf = boost::filesystem; +PlatformPluginsDeployer::PlatformPluginsDeployer(std::string moduleName, + core::appdir::AppDir& appDir, + bf::path qtPluginsPath, + bf::path qtLibexecsPath, + bf::path installLibsPath, + bf::path qtTranslationsPath, + bf::path qtDataPath): + BasicPluginsDeployer(std::move(moduleName), + appDir, + std::move(qtPluginsPath), + std::move(qtLibexecsPath), + std::move(installLibsPath), + std::move(qtTranslationsPath), + std::move(qtDataPath)) { + // check if the platform plugins are set in env + const auto* const platformPluginsFromEnvData = getenv("PLATFORM_PLUGINS"); + if (platformPluginsFromEnvData != nullptr) + platformToDeploy = linuxdeploy::util::split(std::string(platformPluginsFromEnvData), ';'); + else { + // default to libqxcb if nothing is provided + platformToDeploy.emplace_back("libqxcb.so"); + } +} + bool PlatformPluginsDeployer::deploy() { // calling the default code is optional, but it won't hurt for now if (!BasicPluginsDeployer::deploy()) return false; ldLog() << "Deploying platform plugins" << std::endl; + for (auto& platform : platformToDeploy) { + if (!appDir.deployLibrary(qtPluginsPath / "platforms" / platform, appDir.path() / "usr/plugins/platforms/")) + return false; + } - if (!appDir.deployLibrary(qtPluginsPath / "platforms/libqxcb.so", 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/")) diff --git a/src/deployers/PlatformPluginsDeployer.h b/src/deployers/PlatformPluginsDeployer.h index 20379f8..957df3b 100644 --- a/src/deployers/PlatformPluginsDeployer.h +++ b/src/deployers/PlatformPluginsDeployer.h @@ -6,9 +6,21 @@ namespace linuxdeploy { namespace plugin { namespace qt { class PlatformPluginsDeployer : public BasicPluginsDeployer { + private: + std::vector platformToDeploy; + public: - // we can just use the base class's constructor - using BasicPluginsDeployer::BasicPluginsDeployer; + /** + * Default constructor. Constructs a PlatformPluginsDeployer. + * + * @param moduleName + */ + explicit PlatformPluginsDeployer(std::string moduleName, core::appdir::AppDir& appDir, + boost::filesystem::path qtPluginsPath, + boost::filesystem::path qtLibexecsPath, + boost::filesystem::path installLibsPath, + boost::filesystem::path qtTranslationsPath, + boost::filesystem::path qtDataPath); bool deploy() override; };