Skip to content

Commit d00970d

Browse files
committed
Deduplicate Qt plugins deployment
1 parent babb58d commit d00970d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+486
-497
lines changed

src/deployers/BasicPluginsDeployer.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,26 @@ BasicPluginsDeployer::BasicPluginsDeployer(std::string moduleName,
2828
qtTranslationsPath(std::move(qtTranslationsPath)),
2929
qtDataPath(std::move(qtDataPath)) {}
3030

31-
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
31+
bool BasicPluginsDeployer::deploy()
32+
{
33+
for (const auto &pluginName : qtPluginsToBeDeployed()) {
34+
ldLog() << "Deploying" << pluginName << "plugins" << std::endl;
35+
for (fs::directory_iterator i(qtPluginsPath / pluginName); i != fs::directory_iterator();
36+
++i) {
37+
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins" / pluginName))
38+
return false;
39+
}
40+
}
41+
42+
return customDeploy();
43+
}
44+
45+
bool BasicPluginsDeployer::customDeploy()
46+
{
3447
return true;
3548
}
49+
50+
std::vector<std::string> BasicPluginsDeployer::qtPluginsToBeDeployed() const
51+
{
52+
return {};
53+
}

src/deployers/BasicPluginsDeployer.h

Lines changed: 19 additions & 1 deletion
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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@
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+
{
15+
return {"bearer"};
2816
}

src/deployers/BearerPluginsDeployer.h

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@
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+
{
15+
return {"gamepads"};
2816
}

src/deployers/GamepadPluginsDeployer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
namespace linuxdeploy {
66
namespace plugin {
77
namespace qt {
8-
class GamepadPluginsDeployer : public BasicPluginsDeployer {
8+
class GamepadPluginsDeployer : public BasicPluginsDeployer
9+
{
910
public:
1011
// we can just use the base class's constructor
1112
using BasicPluginsDeployer::BasicPluginsDeployer;
1213

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

src/deployers/LocationPluginsDeployer.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@
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+
{
15+
return {"geoservices"};
2816
}

src/deployers/LocationPluginsDeployer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
namespace linuxdeploy {
66
namespace plugin {
77
namespace qt {
8-
class LocationPluginsDeployer : public BasicPluginsDeployer {
8+
class LocationPluginsDeployer : public BasicPluginsDeployer
9+
{
910
public:
1011
// we can just use the base class's constructor
1112
using BasicPluginsDeployer::BasicPluginsDeployer;
1213

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

src/deployers/Multimedia5PluginsDeployer.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,7 @@
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+
{
15+
return {"mediaservice", "audio"};
3516
}

src/deployers/Multimedia5PluginsDeployer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
namespace linuxdeploy {
66
namespace plugin {
77
namespace qt {
8-
class Multimedia5PluginsDeployer : public BasicPluginsDeployer {
8+
class Multimedia5PluginsDeployer : public BasicPluginsDeployer
9+
{
910
public:
1011
// we can just use the base class's constructor
1112
using BasicPluginsDeployer::BasicPluginsDeployer;
1213

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

0 commit comments

Comments
 (0)