forked from linuxdeploy/linuxdeploy-plugin-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlatformPluginsDeployer.cpp
82 lines (64 loc) · 3.46 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
// library headers
#include <linuxdeploy/core/log.h>
#include <linuxdeploy/util/util.h>
#include <boost/filesystem.hpp>
// local headers
#include "PlatformPluginsDeployer.h"
using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::core::log;
namespace bf = boost::filesystem;
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;
// always deploy default platform
if (!appDir.deployLibrary(qtPluginsPath / "platforms/libqxcb.so", appDir.path() / "usr/plugins/platforms/"))
return false;
// deploy extra platform plugins, if any
const auto* const platformPluginsFromEnvData = getenv("EXTRA_PLATFORM_PLUGINS");
if (platformPluginsFromEnvData != nullptr) {
for (const auto& platformToDeploy : linuxdeploy::util::split(std::string(platformPluginsFromEnvData), ';')) {
ldLog() << "Deploying extra platform plugin: " << platformToDeploy << std::endl;
if (!appDir.deployLibrary(qtPluginsPath / "platforms" / platformToDeploy, 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 platform themes and style" << std::endl;
const auto libqxdgPath = platformThemesPath / "libqxdgdesktopportal.so";
for (const auto &file : {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;
}
}
}
return true;
}