Skip to content

Deduplicate Qt plugins deployment #175

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

Merged
merged 2 commits into from
Aug 3, 2024
Merged
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
16 changes: 16 additions & 0 deletions src/deployers/BasicPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,21 @@ BasicPluginsDeployer::BasicPluginsDeployer(std::string moduleName,
bool BasicPluginsDeployer::deploy() {
// 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 true;
}

bool BasicPluginsDeployer::doDeploy() {
return true;
}
19 changes: 18 additions & 1 deletion src/deployers/BasicPluginsDeployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,24 @@ namespace linuxdeploy {
virtual ~BasicPluginsDeployer() = default;

public:
bool deploy() override;
/**
* This method might make some deployment preparation and calls \sa doDeploy() to finalize the deployment.
*/
bool deploy() override final;

protected:
/**
* 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 doDeploy();

/**
* Deploys a list of Qt plugin that should be deployed and
* follow the default name and path scheme.
*/
bool deployStandardQtPlugins(const std::vector<std::string>& plugins);
};
}
}
Expand Down
21 changes: 2 additions & 19 deletions src/deployers/BearerPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +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;

namespace fs = std::filesystem;

bool BearerPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

ldLog() << "Deploying bearer plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "bearer"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/bearer/"))
return false;
}

return true;
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;

bool deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
21 changes: 2 additions & 19 deletions src/deployers/GamepadPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +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;

namespace fs = std::filesystem;

bool GamepadPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

ldLog() << "Deploying Gamepad plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "gamepads"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/gamepads/"))
return false;
}

return true;
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;

bool deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
21 changes: 2 additions & 19 deletions src/deployers/LocationPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +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;

namespace fs = std::filesystem;

bool LocationPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

ldLog() << "Deploying Location plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "geoservices"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/geoservices/"))
return false;
}

return true;
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;

bool deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
28 changes: 2 additions & 26 deletions src/deployers/Multimedia5PluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,35 +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;

namespace fs = std::filesystem;

bool Multimedia5PluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

ldLog() << "Deploying mediaservice plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "mediaservice"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/mediaservice/"))
return false;
}

ldLog() << "Deploying audio plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "audio"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/audio/"))
return false;
}

return true;
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;

bool deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
16 changes: 3 additions & 13 deletions src/deployers/Multimedia6PluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,11 @@ using namespace linuxdeploy::core::log;

namespace fs = std::filesystem;

bool Multimedia6PluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

bool Multimedia6PluginsDeployer::doDeploy() {
if (fs::exists(qtPluginsPath / "multimedia")) {
ldLog() << "Deploying multimedia plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "multimedia"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/multimedia/"))
return false;
}
return deployStandardQtPlugins({"multimedia"});
} else {
ldLog() << LD_WARNING << "Missing Qt 6 multimedia plugins, skipping." << std::endl;
return true;
}

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;

bool deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
16 changes: 3 additions & 13 deletions src/deployers/PlatformPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ using namespace linuxdeploy::core::log;

namespace fs = std::filesystem;

bool PlatformPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

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

// always deploy default platform
Expand All @@ -32,16 +28,10 @@ bool PlatformPluginsDeployer::deploy() {
if (!appDir.deployLibrary(qtPluginsPath / "platforms" / platformToDeploy, appDir.path() / "usr/plugins/platforms/"))
return false;
}
}

for (fs::directory_iterator i(qtPluginsPath / "platforminputcontexts"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/platforminputcontexts/"))
return false;
}

for (fs::directory_iterator i(qtPluginsPath / "imageformats"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/imageformats/"))
return false;
if (!deployStandardQtPlugins({"platforminputcontexts", "imageformats"})) {
return false;
}

// TODO: platform themes -- https://github.com/probonopd/linuxdeployqt/issues/236
Expand Down
2 changes: 1 addition & 1 deletion src/deployers/PlatformPluginsDeployer.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 deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/deployers/PluginsDeployerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ std::vector<std::shared_ptr<PluginsDeployer>> PluginsDeployerFactory::getDeploye
}

if (moduleName == "multimedia") {
if (qtMajorVersion < 6) {
if (qtMajorVersion < 6) {
return {getInstance<Multimedia5PluginsDeployer>(moduleName)};
} else {
} else {
return {getInstance<Multimedia6PluginsDeployer>(moduleName)};
}
}
Expand Down
21 changes: 2 additions & 19 deletions src/deployers/PositioningPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +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;

namespace fs = std::filesystem;

bool PositioningPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

ldLog() << "Deploying positioning plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "position"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/position/"))
return false;
}

return true;
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;

bool deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
21 changes: 2 additions & 19 deletions src/deployers/PrintSupportPluginsDeployer.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +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;

namespace fs = std::filesystem;

bool PrintSupportPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

ldLog() << "Deploying printsupport plugins" << std::endl;

for (fs::directory_iterator i(qtPluginsPath / "printsupport"); i != fs::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/printsupport/"))
return false;
}

return true;
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;

bool deploy() override;
bool doDeploy() override;
};
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/deployers/QmlPluginsDeployer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ using namespace linuxdeploy::plugin::qt;

namespace fs = std::filesystem;

bool QmlPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;

bool QmlPluginsDeployer::doDeploy() {
try {
deployQml(appDir, qtInstallQmlPath);
} catch (const QmlImportScannerError &) {
Expand Down
Loading