Skip to content

Commit 2826ee5

Browse files
danttiTheAssassin
authored andcommitted
Deduplicate Qt plugins deployment
1 parent ecc4a9d commit 2826ee5

37 files changed

+90
-239
lines changed

src/deployers/BasicPluginsDeployer.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ BasicPluginsDeployer::BasicPluginsDeployer(std::string moduleName,
2929
qtDataPath(std::move(qtDataPath)) {}
3030

3131
bool BasicPluginsDeployer::deploy() {
32-
// currently this is a no-op, but we might add more functionality later on, such as some kinds of default
33-
// attempts to copy data based on the moduleName
32+
for (const auto &pluginName : qtPluginsToBeDeployed()) {
33+
ldLog() << "Deploying" << pluginName << "plugins" << std::endl;
34+
for (fs::directory_iterator i(qtPluginsPath / pluginName); i != fs::directory_iterator(); ++i) {
35+
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins" / pluginName))
36+
return false;
37+
}
38+
}
39+
40+
return customDeploy();
41+
}
42+
43+
bool BasicPluginsDeployer::customDeploy() {
3444
return true;
3545
}
46+
47+
std::vector<std::string> BasicPluginsDeployer::qtPluginsToBeDeployed() const {
48+
return {};
49+
}

src/deployers/BasicPluginsDeployer.h

+19-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,25 @@ namespace linuxdeploy {
4949
virtual ~BasicPluginsDeployer() = default;
5050

5151
public:
52-
bool deploy() override;
52+
/**
53+
* This method deploys the plugins returned by \sa qtPluginsToBeDeployed()
54+
* and call \sa customDeploy() to finalize the deployment.
55+
*/
56+
bool deploy() override final;
57+
58+
protected:
59+
/**
60+
* The \sa deploy() method can deploy Qt plugins that follow the default
61+
* name and path scheme, but some modules are special so
62+
* they should write custom deployment code.
63+
*/
64+
virtual bool customDeploy();
65+
66+
/**
67+
* Returns a list of Qt plugin names that should be deployed and
68+
* follow the default name and path scheme.
69+
*/
70+
virtual std::vector<std::string> qtPluginsToBeDeployed() const;
5371
};
5472
}
5573
}

src/deployers/BearerPluginsDeployer.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010
using namespace linuxdeploy::plugin::qt;
1111
using namespace linuxdeploy::core::log;
1212

13-
namespace fs = std::filesystem;
14-
15-
bool BearerPluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
20-
ldLog() << "Deploying bearer plugins" << std::endl;
21-
22-
for (fs::directory_iterator i(qtPluginsPath / "bearer"); i != fs::directory_iterator(); ++i) {
23-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/bearer/"))
24-
return false;
25-
}
26-
27-
return true;
13+
std::vector<std::string> BearerPluginsDeployer::qtPluginsToBeDeployed() const {
14+
return {"bearer"};
2815
}

src/deployers/BearerPluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

src/deployers/GamepadPluginsDeployer.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010
using namespace linuxdeploy::plugin::qt;
1111
using namespace linuxdeploy::core::log;
1212

13-
namespace fs = std::filesystem;
14-
15-
bool GamepadPluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
20-
ldLog() << "Deploying Gamepad plugins" << std::endl;
21-
22-
for (fs::directory_iterator i(qtPluginsPath / "gamepads"); i != fs::directory_iterator(); ++i) {
23-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/gamepads/"))
24-
return false;
25-
}
26-
27-
return true;
13+
std::vector<std::string> GamepadPluginsDeployer::qtPluginsToBeDeployed() const {
14+
return {"gamepads"};
2815
}

src/deployers/GamepadPluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

src/deployers/LocationPluginsDeployer.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010
using namespace linuxdeploy::plugin::qt;
1111
using namespace linuxdeploy::core::log;
1212

13-
namespace fs = std::filesystem;
14-
15-
bool LocationPluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
20-
ldLog() << "Deploying Location plugins" << std::endl;
21-
22-
for (fs::directory_iterator i(qtPluginsPath / "geoservices"); i != fs::directory_iterator(); ++i) {
23-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/geoservices/"))
24-
return false;
25-
}
26-
27-
return true;
13+
std::vector<std::string> LocationPluginsDeployer::qtPluginsToBeDeployed() const {
14+
return {"geoservices"};
2815
}

src/deployers/LocationPluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

src/deployers/Multimedia5PluginsDeployer.cpp

+2-22
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,6 @@
1010
using namespace linuxdeploy::plugin::qt;
1111
using namespace linuxdeploy::core::log;
1212

13-
namespace fs = std::filesystem;
14-
15-
bool Multimedia5PluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
20-
ldLog() << "Deploying mediaservice plugins" << std::endl;
21-
22-
for (fs::directory_iterator i(qtPluginsPath / "mediaservice"); i != fs::directory_iterator(); ++i) {
23-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/mediaservice/"))
24-
return false;
25-
}
26-
27-
ldLog() << "Deploying audio plugins" << std::endl;
28-
29-
for (fs::directory_iterator i(qtPluginsPath / "audio"); i != fs::directory_iterator(); ++i) {
30-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/audio/"))
31-
return false;
32-
}
33-
34-
return true;
13+
std::vector<std::string> Multimedia5PluginsDeployer::qtPluginsToBeDeployed() const {
14+
return {"mediaservice", "audio"};
3515
}

src/deployers/Multimedia5PluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

src/deployers/Multimedia6PluginsDeployer.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,11 @@ using namespace linuxdeploy::core::log;
1212

1313
namespace fs = std::filesystem;
1414

15-
bool Multimedia6PluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
15+
std::vector<std::string> Multimedia6PluginsDeployer::qtPluginsToBeDeployed() const {
2016
if (fs::exists(qtPluginsPath / "multimedia")) {
21-
ldLog() << "Deploying multimedia plugins" << std::endl;
22-
23-
for (fs::directory_iterator i(qtPluginsPath / "multimedia"); i != fs::directory_iterator(); ++i) {
24-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/multimedia/"))
25-
return false;
26-
}
17+
return {"multimedia"};
2718
} else {
2819
ldLog() << LD_WARNING << "Missing Qt 6 multimedia plugins, skipping." << std::endl;
20+
return {};
2921
}
30-
31-
return true;
3222
}

src/deployers/Multimedia6PluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

src/deployers/PlatformPluginsDeployer.cpp

+5-15
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ using namespace linuxdeploy::core::log;
1313

1414
namespace fs = std::filesystem;
1515

16-
bool PlatformPluginsDeployer::deploy() {
17-
// calling the default code is optional, but it won't hurt for now
18-
if (!BasicPluginsDeployer::deploy())
19-
return false;
20-
16+
bool PlatformPluginsDeployer::customDeploy() {
2117
ldLog() << "Deploying platform plugins" << std::endl;
2218

2319
// always deploy default platform
@@ -32,16 +28,6 @@ bool PlatformPluginsDeployer::deploy() {
3228
if (!appDir.deployLibrary(qtPluginsPath / "platforms" / platformToDeploy, appDir.path() / "usr/plugins/platforms/"))
3329
return false;
3430
}
35-
}
36-
37-
for (fs::directory_iterator i(qtPluginsPath / "platforminputcontexts"); i != fs::directory_iterator(); ++i) {
38-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/platforminputcontexts/"))
39-
return false;
40-
}
41-
42-
for (fs::directory_iterator i(qtPluginsPath / "imageformats"); i != fs::directory_iterator(); ++i) {
43-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/imageformats/"))
44-
return false;
4531
}
4632

4733
// TODO: platform themes -- https://github.com/probonopd/linuxdeployqt/issues/236
@@ -82,3 +68,7 @@ bool PlatformPluginsDeployer::deploy() {
8268

8369
return true;
8470
}
71+
72+
std::vector<std::string> PlatformPluginsDeployer::qtPluginsToBeDeployed() const {
73+
return {"platforminputcontexts", "imageformats"};
74+
}

src/deployers/PlatformPluginsDeployer.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
bool customDeploy() override;
14+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1415
};
1516
}
1617
}

src/deployers/PluginsDeployerFactory.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ std::vector<std::shared_ptr<PluginsDeployer>> PluginsDeployerFactory::getDeploye
7373
}
7474

7575
if (moduleName == "multimedia") {
76-
if (qtMajorVersion < 6) {
76+
if (qtMajorVersion < 6) {
7777
return {getInstance<Multimedia5PluginsDeployer>(moduleName)};
78-
} else {
78+
} else {
7979
return {getInstance<Multimedia6PluginsDeployer>(moduleName)};
8080
}
8181
}

src/deployers/PositioningPluginsDeployer.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010
using namespace linuxdeploy::plugin::qt;
1111
using namespace linuxdeploy::core::log;
1212

13-
namespace fs = std::filesystem;
14-
15-
bool PositioningPluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
20-
ldLog() << "Deploying positioning plugins" << std::endl;
21-
22-
for (fs::directory_iterator i(qtPluginsPath / "position"); i != fs::directory_iterator(); ++i) {
23-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/position/"))
24-
return false;
25-
}
26-
27-
return true;
13+
std::vector<std::string> PositioningPluginsDeployer::qtPluginsToBeDeployed() const {
14+
return {"position"};
2815
}

src/deployers/PositioningPluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

src/deployers/PrintSupportPluginsDeployer.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010
using namespace linuxdeploy::plugin::qt;
1111
using namespace linuxdeploy::core::log;
1212

13-
namespace fs = std::filesystem;
14-
15-
bool PrintSupportPluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
20-
ldLog() << "Deploying printsupport plugins" << std::endl;
21-
22-
for (fs::directory_iterator i(qtPluginsPath / "printsupport"); i != fs::directory_iterator(); ++i) {
23-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/printsupport/"))
24-
return false;
25-
}
26-
27-
return true;
13+
std::vector<std::string> PrintSupportPluginsDeployer::qtPluginsToBeDeployed() const {
14+
return {"printsupport"};
2815
}

src/deployers/PrintSupportPluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

src/deployers/QmlPluginsDeployer.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ using namespace linuxdeploy::plugin::qt;
88

99
namespace fs = std::filesystem;
1010

11-
bool QmlPluginsDeployer::deploy() {
12-
// calling the default code is optional, but it won't hurt for now
13-
if (!BasicPluginsDeployer::deploy())
14-
return false;
15-
11+
bool QmlPluginsDeployer::customDeploy() {
1612
try {
1713
deployQml(appDir, qtInstallQmlPath);
1814
} catch (const QmlImportScannerError &) {

src/deployers/QmlPluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
bool customDeploy() override;
1414
};
1515
}
1616
}

src/deployers/Qt3DPluginsDeployer.cpp

+2-20
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,6 @@
1010
using namespace linuxdeploy::plugin::qt;
1111
using namespace linuxdeploy::core::log;
1212

13-
namespace fs = std::filesystem;
14-
15-
bool Qt3DPluginsDeployer::deploy() {
16-
// calling the default code is optional, but it won't hurt for now
17-
if (!BasicPluginsDeployer::deploy())
18-
return false;
19-
20-
ldLog() << "Deploying Qt 3D plugins" << std::endl;
21-
22-
for (fs::directory_iterator i(qtPluginsPath / "geometryloaders"); i != fs::directory_iterator(); ++i) {
23-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/geometryloaders/"))
24-
return false;
25-
}
26-
27-
for (fs::directory_iterator i(qtPluginsPath / "sceneparsers"); i != fs::directory_iterator(); ++i) {
28-
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/sceneparsers/"))
29-
return false;
30-
}
31-
32-
return true;
13+
std::vector<std::string> Qt3DPluginsDeployer::qtPluginsToBeDeployed() const {
14+
return {"geometryloaders", "sceneparsers"};
3315
}

src/deployers/Qt3DPluginsDeployer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace linuxdeploy {
1010
// we can just use the base class's constructor
1111
using BasicPluginsDeployer::BasicPluginsDeployer;
1212

13-
bool deploy() override;
13+
std::vector<std::string> qtPluginsToBeDeployed() const override;
1414
};
1515
}
1616
}

0 commit comments

Comments
 (0)