-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathPlatformPluginsDeployer.cpp
110 lines (91 loc) · 5.44 KB
/
PlatformPluginsDeployer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// library headers
#include <linuxdeploy/core/log.h>
// local headers
#include "PlatformPluginsDeployer.h"
#include "linuxdeploy/util/util.h"
using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;
namespace bf = boost::filesystem;
PlatformPluginsDeployer::PlatformPluginsDeployer(std::string moduleName,
core::appdir::AppDir& appDir,
bf::path qtPluginsPath,
bf::path qtLibexecsPath,
bf::path installLibsPath,
bf::path qtTranslationsPath,
bf::path qtDataPath):
BasicPluginsDeployer(std::move(moduleName),
appDir,
std::move(qtPluginsPath),
std::move(qtLibexecsPath),
std::move(installLibsPath),
std::move(qtTranslationsPath),
std::move(qtDataPath)) {
// check if the platform plugins are set in env
const auto* const platformPluginsFromEnvData = getenv("PLATFORM_PLUGINS");
if (platformPluginsFromEnvData != nullptr)
platformToDeploy = linuxdeploy::util::split(std::string(platformPluginsFromEnvData), ';');
else {
// default to libqxcb if nothing is provided
platformToDeploy.emplace_back("libqxcb.so");
}
}
bool PlatformPluginsDeployer::deploy() {
// calling the default code is optional, but it won't hurt for now
if (!BasicPluginsDeployer::deploy())
return false;
ldLog() << "Deploying platform plugins" << std::endl;
for (auto& platform : platformToDeploy) {
if (!appDir.deployLibrary(qtPluginsPath / "platforms" / platform, appDir.path() / "usr/plugins/platforms/"))
return false;
}
for (bf::directory_iterator i(qtPluginsPath / "platforminputcontexts"); i != bf::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/platforminputcontexts/"))
return false;
}
for (bf::directory_iterator i(qtPluginsPath / "imageformats"); i != bf::directory_iterator(); ++i) {
if (!appDir.deployLibrary(*i, appDir.path() / "usr/plugins/imageformats/"))
return false;
}
// TODO: platform themes -- https://github.com/probonopd/linuxdeployqt/issues/236
const bf::path platformThemesPath = qtPluginsPath / "platformthemes";
const bf::path stylesPath = qtPluginsPath / "styles";
const bf::path platformThemesDestination = appDir.path() / "usr/plugins/platformthemes/";
const bf::path stylesDestination = appDir.path() / "usr/plugins/styles/";
if (getenv("DEPLOY_PLATFORM_THEMES") != nullptr) {
ldLog() << LD_WARNING << "Deploying all platform themes and styles [experimental feature]" << std::endl;
if (bf::is_directory(platformThemesPath))
for (bf::directory_iterator i(platformThemesPath); i != bf::directory_iterator(); ++i)
if (!appDir.deployLibrary(*i, platformThemesDestination))
return false;
if (bf::is_directory(stylesPath))
for (bf::directory_iterator i(stylesPath); i != bf::directory_iterator(); ++i)
if (!appDir.deployLibrary(*i, stylesDestination))
return false;
} else {
ldLog() << "Trying to deploy Gtk 2 platform theme and/or style" << std::endl;
// according to probono, only the files shall be deployed, not their dependencies
// either loading succeeds, then the system Gtk shall be used anyway, otherwise loading fails and Qt will fall
// back to the default UI theme
// we don't care whether this works (it's an experimental feature), therefore we ignore the return values
const auto libqgtk2Path = platformThemesPath / "libqgtk2.so";
const auto libqgtk3Path = platformThemesPath / "libqgtk3.so";
const auto libqxdgPath = platformThemesPath / "libqxdgdesktopportal.so";
for (const auto &file : {libqgtk2Path, libqgtk3Path, libqxdgPath}) {
// we need to check whether the files exist at least, otherwise the deferred deployment operation fails
if (bf::is_regular_file(file)) {
ldLog() << "Attempting to deploy" << file.filename() << "found at path" << file.parent_path() << std::endl;
appDir.deployFile(file, platformThemesDestination);
} else {
ldLog() << "Could not find" << file.filename() << "on system, skipping deployment" << std::endl;
}
}
const auto libqgtk2stylePath = stylesPath / "libqgtk2style.so";
if (bf::is_regular_file(libqgtk2stylePath)) {
ldLog() << "Attempting to deploy" << libqgtk2stylePath.filename() << "found at path" << libqgtk2stylePath << std::endl;
appDir.deployFile(libqgtk2stylePath, stylesDestination);
} else {
ldLog() << "Could not find" << libqgtk2stylePath.filename() << "on system, skipping deployment" << std::endl;
}
}
return true;
}