-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathWebEnginePluginsDeployer.cpp
71 lines (52 loc) · 2.2 KB
/
WebEnginePluginsDeployer.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
// system headers
#include <filesystem>
#include <fstream>
// library headers
#include <linuxdeploy/log/log.h>
#include <util.h>
// local headers
#include "WebEnginePluginsDeployer.h"
using namespace linuxdeploy::plugin::qt;
using namespace linuxdeploy::log;
namespace fs = std::filesystem;
bool WebEnginePluginsDeployer::doDeploy() {
ldLog() << "Deploying web engine plugins" << std::endl;
const auto newLibexecPath = appDir.path() / "usr/libexec/";
// make sure directory is there before trying to write a qt.conf file
fs::create_directories(newLibexecPath);
for (fs::directory_iterator i(qtLibexecsPath); i != fs::directory_iterator(); ++i) {
auto &entry = *i;
const std::string prefix = "QtWeb";
auto fileName = entry.path().filename();
// skip files which don't start with prefix
if (!strStartsWith(fileName.string(), prefix))
continue;
if (!appDir.deployExecutable(*i, newLibexecPath))
return false;
}
for (const auto &fileName : {"qtwebengine_resources.pak",
"qtwebengine_devtools_resources.pak",
"qtwebengine_resources_100p.pak",
"qtwebengine_resources_200p.pak",
"icudtl.dat",
"v8_context_snapshot.bin"}) {
auto path = qtDataPath / "resources" / fileName;
if (fs::is_regular_file(path))
appDir.deployFile(path, appDir.path() / "usr/resources/");
}
if (fs::is_directory(qtTranslationsPath / "qtwebengine_locales")) {
for (fs::directory_iterator i(qtTranslationsPath / "qtwebengine_locales"); i != fs::directory_iterator(); ++i) {
appDir.deployFile(*i, appDir.path() / "usr/translations/qtwebengine_locales/");
}
}
const auto qtConfPath = newLibexecPath / "qt.conf";
std::ofstream ofs(qtConfPath.string());
if (!ofs) {
ldLog() << LD_ERROR << "Failed to open" << qtConfPath << "for writing" << std::endl;
return false;
}
ofs << "# generated by linuxdeploy" << std::endl
<< "[Paths]" << std::endl
<< "Prefix = ../" << std::endl;
return true;
}