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

Lines changed: 16 additions & 2 deletions
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

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: 2 additions & 15 deletions
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

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: 2 additions & 15 deletions
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

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/LocationPluginsDeployer.cpp

Lines changed: 2 additions & 15 deletions
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

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/Multimedia5PluginsDeployer.cpp

Lines changed: 2 additions & 22 deletions
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

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
}

0 commit comments

Comments
 (0)