Skip to content

Commit

Permalink
Deploy Qt plugins with default deployStandardQtPlugins() function
Browse files Browse the repository at this point in the history
  • Loading branch information
dantti authored and TheAssassin committed Aug 3, 2024
1 parent 2826ee5 commit 0a29e02
Show file tree
Hide file tree
Showing 36 changed files with 70 additions and 114 deletions.
20 changes: 11 additions & 9 deletions src/deployers/BasicPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,23 @@ BasicPluginsDeployer::BasicPluginsDeployer(std::string moduleName,
qtDataPath(std::move(qtDataPath)) {}

bool BasicPluginsDeployer::deploy() {
for (const auto &pluginName : qtPluginsToBeDeployed()) {
ldLog() << "Deploying" << pluginName << "plugins" << std::endl;
// currently this is a no-op, but we might add more functionality later on, such as some kinds of default
// attempts to copy data based on the moduleName
return doDeploy();
}

bool BasicPluginsDeployer::deployStandardQtPlugins(const std::vector<std::string>& plugins)
{
for (const auto &pluginName : plugins) {
ldLog() << "Deploying Qt" << pluginName << "plugins" << std::endl;
for (fs::directory_iterator i(qtPluginsPath / pluginName); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins" / pluginName))
return false;
}
}

return customDeploy();
}

bool BasicPluginsDeployer::customDeploy() {
return true;
}

std::vector<std::string> BasicPluginsDeployer::qtPluginsToBeDeployed() const {
return {};
bool BasicPluginsDeployer::doDeploy() {
return true;
}
15 changes: 7 additions & 8 deletions src/deployers/BasicPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,23 @@ namespace linuxdeploy {

public:
/**
* This method deploys the plugins returned by \sa qtPluginsToBeDeployed()
* and call \sa customDeploy() to finalize the deployment.
* This method might make some deployment preparation and calls \sa doDeploy() to finalize the deployment.
*/
bool deploy() override final;

protected:
/**
* The \sa deploy() method can deploy Qt plugins that follow the default
* name and path scheme, but some modules are special so
* they should write custom deployment code.
* This method does the actual moduleName deployment, where any special case should be handled and
* \sa deployStandardQtPlugins () method should be called to deploy Qt plugins that follow the default
* name and path scheme.
*/
virtual bool customDeploy();
virtual bool doDeploy();

/**
* Returns a list of Qt plugin names that should be deployed and
* Deploys a list of Qt plugin that should be deployed and
* follow the default name and path scheme.
*/
virtual std::vector<std::string> qtPluginsToBeDeployed() const;
bool deployStandardQtPlugins(const std::vector<std::string>& plugins);
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/BearerPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "BearerPluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> BearerPluginsDeployer::qtPluginsToBeDeployed() const {
return {"bearer"};
bool BearerPluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"bearer"});
}
2 changes: 1 addition & 1 deletion src/deployers/BearerPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/GamepadPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "GamepadPluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> GamepadPluginsDeployer::qtPluginsToBeDeployed() const {
return {"gamepads"};
bool GamepadPluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"gamepads"});
}
2 changes: 1 addition & 1 deletion src/deployers/GamepadPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/LocationPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "LocationPluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> LocationPluginsDeployer::qtPluginsToBeDeployed() const {
return {"geoservices"};
bool LocationPluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"geoservices"});
}
2 changes: 1 addition & 1 deletion src/deployers/LocationPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/Multimedia5PluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "Multimedia5PluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> Multimedia5PluginsDeployer::qtPluginsToBeDeployed() const {
return {"mediaservice", "audio"};
bool Multimedia5PluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"mediaservice", "audio"});
}
2 changes: 1 addition & 1 deletion src/deployers/Multimedia5PluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/deployers/Multimedia6PluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ using namespace linuxdeploy::core::log;

namespace fs = std::filesystem;

std::vector<std::string> Multimedia6PluginsDeployer::qtPluginsToBeDeployed() const {
bool Multimedia6PluginsDeployer::doDeploy() {
if (fs::exists(qtPluginsPath / "multimedia")) {
return {"multimedia"};
return deployStandardQtPlugins({"multimedia"});
} else {
ldLog() << LD_WARNING << "Missing Qt 6 multimedia plugins, skipping." << std::endl;
return {};
return true;
}
}
2 changes: 1 addition & 1 deletion src/deployers/Multimedia6PluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/deployers/PlatformPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace linuxdeploy::core::log;

namespace fs = std::filesystem;

bool PlatformPluginsDeployer::customDeploy() {
bool PlatformPluginsDeployer::doDeploy() {
ldLog() << "Deploying platform plugins" << std::endl;

// always deploy default platform
Expand All @@ -30,6 +30,10 @@ bool PlatformPluginsDeployer::customDeploy() {
}
}

if (!deployStandardQtPlugins({"platforminputcontexts", "imageformats"})) {
return false;
}

// TODO: platform themes -- https://github.com/probonopd/linuxdeployqt/issues/236

const fs::path platformThemesPath = qtPluginsPath / "platformthemes";
Expand Down Expand Up @@ -68,7 +72,3 @@ bool PlatformPluginsDeployer::customDeploy() {

return true;
}

std::vector<std::string> PlatformPluginsDeployer::qtPluginsToBeDeployed() const {
return {"platforminputcontexts", "imageformats"};
}
3 changes: 1 addition & 2 deletions src/deployers/PlatformPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

bool customDeploy() override;
std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/PositioningPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "PositioningPluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> PositioningPluginsDeployer::qtPluginsToBeDeployed() const {
return {"position"};
bool PositioningPluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"position"});
}
2 changes: 1 addition & 1 deletion src/deployers/PositioningPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/PrintSupportPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "PrintSupportPluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> PrintSupportPluginsDeployer::qtPluginsToBeDeployed() const {
return {"printsupport"};
bool PrintSupportPluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"printsupport"});
}
2 changes: 1 addition & 1 deletion src/deployers/PrintSupportPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/deployers/QmlPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace linuxdeploy::plugin::qt;

namespace fs = std::filesystem;

bool QmlPluginsDeployer::customDeploy() {
bool QmlPluginsDeployer::doDeploy() {
try {
deployQml(appDir, qtInstallQmlPath);
} catch (const QmlImportScannerError &) {
Expand Down
2 changes: 1 addition & 1 deletion src/deployers/QmlPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

bool customDeploy() override;
bool doDeploy() override;
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/Qt3DPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "Qt3DPluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> Qt3DPluginsDeployer::qtPluginsToBeDeployed() const {
return {"geometryloaders", "sceneparsers"};
bool Qt3DPluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"geometryloaders", "sceneparsers"});
}
2 changes: 1 addition & 1 deletion src/deployers/Qt3DPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/deployers/SqlPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// system headers
#include <filesystem>

// library headers
#include <linuxdeploy/core/log.h>

// local headers
#include "SqlPluginsDeployer.h"

using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;

std::vector<std::string> SqlPluginsDeployer::qtPluginsToBeDeployed() const {
return {"sqldrivers"};
bool SqlPluginsDeployer::doDeploy() {
return deployStandardQtPlugins({"sqldrivers"});
}
2 changes: 1 addition & 1 deletion src/deployers/SqlPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

std::vector<std::string> qtPluginsToBeDeployed() const override;
bool doDeploy() override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/deployers/SvgPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace linuxdeploy::core::log;

namespace fs = std::filesystem;

bool SvgPluginsDeployer::customDeploy() {
bool SvgPluginsDeployer::doDeploy() {
ldLog() << "Deploying svg icon engine" << std::endl;

if (!appDir.deployLibrary(qtPluginsPath / "iconengines/libqsvgicon.so", appDir.path() / "usr/plugins/iconengines/"))
Expand Down
2 changes: 1 addition & 1 deletion src/deployers/SvgPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

bool customDeploy() override;
bool doDeploy() override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/deployers/TextToSpeechPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace linuxdeploy::core::log;

namespace fs = std::filesystem;

bool TextToSpeechPluginsDeployer::customDeploy() {
bool TextToSpeechPluginsDeployer::doDeploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/deployers/TextToSpeechPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace linuxdeploy {
// we can just use the base class's constructor
using BasicPluginsDeployer::BasicPluginsDeployer;

bool customDeploy() override;
bool doDeploy() override;
};
}
}
Expand Down
Loading

0 comments on commit 0a29e02

Please sign in to comment.