Skip to content

Allow to deploy specific platform plugins #89

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

Open
wants to merge 1 commit 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
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
- `$PLATFORM_PLUGIN=pltformA.so;platformB.so`: Platforms to deploy, defaults to `libqxcb.so`. Platform must be available from `QT_INSTALL_PLUGINS/platforms`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should be plural, I suppose that's a typo.

I'd also rather not have people manually add libqxcb but deploy it by default. Therefore, the name should be $EXTRA_PLATFORM_PLUGINS.


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
11 changes: 11 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 29 additions & 3 deletions src/deployers/PlatformPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,50 @@
// library headers
#include <linuxdeploy/core/log.h>
#include <boost/filesystem.hpp>

// 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether it's a great idea to implement a custom constructor. Of course, software design wise, that's probably the way to go, given that we need to create that list below. However, it adds a fair amount of boilerplate code that will have to be maintained. What do you think about moving the evaluation of the environment variable into deploy()? I am undecided which version would be better in the long term.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like platformToDeploy is used at all outside of the deploy function, and that function is only called once per instance, so I think it could just be a local variable.

const auto* const platformPluginsFromEnvData = getenv("PLATFORM_PLUGINS");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said above, I'd rather enforce the deployment of libqxcb.so. Instead of PLATFORM_PLUGINS, I would like to have some EXTRA_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/"))
Expand Down
16 changes: 14 additions & 2 deletions src/deployers/PlatformPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@ namespace linuxdeploy {
namespace plugin {
namespace qt {
class PlatformPluginsDeployer : public BasicPluginsDeployer {
private:
std::vector<std::string> 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;
};
Expand Down