Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7aa0ee1

Browse files
committed
[[ BrowserWidget ]] Relocate linux cef helper process
Move the (rev|lib)browser-cefprocess executable to the same folder as the engine executable, so the icudtl.dat file (whose location in libcef is hardcoded) can be shared between them.
1 parent 8cc3c1c commit 7aa0ee1

File tree

5 files changed

+164
-145
lines changed

5 files changed

+164
-145
lines changed

libbrowser/src/libbrowser_cef_lnx.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -219,33 +219,17 @@ bool MCCefPlatformCreateBrowser(void *p_display, void *p_window_id, MCCefBrowser
219219

220220
////////////////////////////////////////////////////////////////////////////////
221221

222-
#define CEF_PATH_PREFIX "CEF"
222+
#define CEF_PATH_PREFIX "Externals/CEF"
223223

224-
extern bool MCCefLinuxGetExecutablePath(char *&r_path);
224+
const char *MCCefPlatformGetExecutableFolder(void);
225+
bool MCCefLinuxAppendPath(const char *p_base, const char *p_path, char *&r_path);
225226

226227
const char *MCCefPlatformGetCefFolder(void)
227228
{
228229
static char *s_cef_path = nil;
229230

230231
if (s_cef_path == nil)
231-
{
232-
bool t_success;
233-
t_success = true;
234-
235-
if (t_success)
236-
t_success = MCCefLinuxGetExecutablePath(s_cef_path);
237-
238-
if (t_success)
239-
{
240-
// remove last component from path
241-
uint32_t t_index;
242-
if (MCCStringLastIndexOf(s_cef_path, '/', t_index))
243-
s_cef_path[t_index] = '\0';
244-
245-
// Append the name of the folder containing the CEF components
246-
MCCStringAppend(s_cef_path, "/" CEF_PATH_PREFIX);
247-
}
248-
}
232+
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetExecutableFolder(), CEF_PATH_PREFIX, s_cef_path);
249233

250234
MCLog("libbrowser cef folder: %s", s_cef_path);
251235

libbrowser/src/libbrowser_cefprocess_lnx.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,17 @@ int main(int argc, char *argv[])
6060

6161
////////////////////////////////////////////////////////////////////////////////
6262

63-
extern bool MCCefLinuxGetExecutablePath(char *&r_path);
63+
#define CEF_PATH_PREFIX "Externals/CEF"
64+
65+
const char *MCCefPlatformGetExecutableFolder(void);
66+
bool MCCefLinuxAppendPath(const char *p_base, const char *p_path, char *&r_path);
6467

6568
const char *MCCefPlatformGetCefFolder(void)
6669
{
67-
static char *s_cef_path = nil;
70+
static char *s_cef_path = nil;
6871

6972
if (s_cef_path == nil)
70-
{
71-
bool t_success;
72-
t_success = MCCefLinuxGetExecutablePath(s_cef_path);
73-
if (t_success)
74-
{
75-
// remove end component from path
76-
uint32_t t_index;
77-
if (MCCStringLastIndexOf(s_cef_path, '/', t_index))
78-
s_cef_path[t_index] = '\0';
79-
}
80-
}
73+
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetExecutableFolder(), CEF_PATH_PREFIX, s_cef_path);
8174

8275
MCLog("libbrowser-cefprocess cef folder: %s", s_cef_path);
8376

libbrowser/src/libbrowser_cefshared_lnx.cpp

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#include <sys/stat.h>
2323
#include <unistd.h>
2424

25+
const char *MCCefPlatformGetExecutableFolder(void);
26+
const char *MCCefPlatformGetCefFolder();
27+
28+
////////////////////////////////////////////////////////////////////////////////
29+
2530
bool MCCefLinuxAppendPath(const char *p_base, const char *p_path, char *&r_path)
2631
{
2732
if (p_base == nil)
@@ -34,6 +39,46 @@ bool MCCefLinuxAppendPath(const char *p_base, const char *p_path, char *&r_path)
3439

3540
////////////////////////////////////////////////////////////////////////////////
3641

42+
const char *MCCefPlatformGetResourcesDirPath(void)
43+
{
44+
return MCCefPlatformGetCefFolder();
45+
}
46+
47+
// IM-2014-10-03: [[ revBrowserCEF ]] locales located in CEF subfolder relative to revbrowser external
48+
const char *MCCefPlatformGetLocalePath(void)
49+
{
50+
static char *s_locale_path = nil;
51+
52+
if (s_locale_path == nil)
53+
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetCefFolder(), "locales", s_locale_path);
54+
55+
return s_locale_path;
56+
}
57+
58+
// IM-2015-10-16: [[ BrowserWidget ]] relocate subprocess exe next to application exe so hardcoded "icudtl.dat" file can be shared.
59+
const char *MCCefPlatformGetSubProcessName(void)
60+
{
61+
static char *s_exe_path = nil;
62+
63+
if (s_exe_path == nil)
64+
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetExecutableFolder(), "libbrowser-cefprocess", s_exe_path);
65+
66+
return s_exe_path;
67+
}
68+
69+
// IM-2014-10-03: [[ revBrowserCEF ]] libcef library located in CEF subfolder relative to revbrowser external
70+
const char *MCCefPlatformGetCefLibraryPath(void)
71+
{
72+
static char *s_lib_path = nil;
73+
74+
if (s_lib_path == nil)
75+
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetCefFolder(), "libcef.so", s_lib_path);
76+
77+
return s_lib_path;
78+
}
79+
80+
////////////////////////////////////////////////////////////////////////////////
81+
3782
static bool get_link_size(const char *p_path, uint32_t &r_size)
3883
{
3984
if (p_path == nil)
@@ -80,58 +125,37 @@ static bool get_link_path(const char *p_link, char *&r_path)
80125
t_buffer[t_link_size] = '\0';
81126
r_path = t_buffer;
82127
}
83-
else if (t_buffer != NULL)
128+
else
84129
MCBrowserMemoryDeallocate(t_buffer);
85130

86131
return t_success;
87132
}
88133

89-
bool MCCefLinuxGetExecutablePath(char *&r_path)
134+
static bool get_exe_path_from_proc_fs(char *&r_path)
90135
{
91136
return get_link_path("/proc/self/exe", r_path);
92137
}
93138

94-
////////////////////////////////////////////////////////////////////////////////
95-
96-
const char *MCCefPlatformGetCefFolder();
139+
//////////
97140

98-
const char *MCCefPlatformGetResourcesDirPath(void)
141+
const char *MCCefPlatformGetExecutableFolder(void)
99142
{
100-
return MCCefPlatformGetCefFolder();
101-
}
102-
103-
// IM-2014-10-03: [[ revBrowserCEF ]] locales located in CEF subfolder relative to revbrowser external
104-
const char *MCCefPlatformGetLocalePath(void)
105-
{
106-
static char *s_locale_path = nil;
107-
108-
if (s_locale_path == nil)
109-
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetCefFolder(), "locales", s_locale_path);
110-
111-
return s_locale_path;
112-
}
113-
114-
// IM-2014-10-03: [[ revBrowserCEF ]] subprocess executable located in CEF subfolder relative to revbrowser external
115-
const char *MCCefPlatformGetSubProcessName(void)
116-
{
117-
static char *s_exe_path = nil;
143+
static char *s_exe_path = nil;
118144

119145
if (s_exe_path == nil)
120-
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetCefFolder(), "libbrowser-cefprocess", s_exe_path);
121-
146+
{
147+
bool t_success;
148+
t_success = get_exe_path_from_proc_fs(s_exe_path);
149+
if (t_success)
150+
{
151+
// remove library component from path
152+
uint32_t t_index;
153+
if (MCCStringLastIndexOf(s_exe_path, '/', t_index))
154+
s_exe_path[t_index] = '\0';
155+
}
156+
}
157+
122158
return s_exe_path;
123159
}
124160

125-
// IM-2014-10-03: [[ revBrowserCEF ]] libcef library located in CEF subfolder relative to revbrowser external
126-
const char *MCCefPlatformGetCefLibraryPath(void)
127-
{
128-
static char *s_lib_path = nil;
129-
130-
if (s_lib_path == nil)
131-
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetCefFolder(), "libcef.so", s_lib_path);
132-
133-
return s_lib_path;
134-
}
135-
136161
////////////////////////////////////////////////////////////////////////////////
137-

revbrowser/src/cefprocess_lnx.cpp

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include <include/cef_app.h>
1818

1919
#include <sys/types.h>
20-
#include <sys/stat.h>
21-
#include <unistd.h>
2220

2321
#include "core.h"
2422
#include "cefshared.h"
@@ -64,80 +62,15 @@ int main(int argc, char *argv[])
6462

6563
////////////////////////////////////////////////////////////////////////////////
6664

67-
bool get_link_size(const char *p_path, uint32_t &r_size)
68-
{
69-
if (p_path == nil)
70-
return false;
71-
72-
struct stat t_stat;
73-
if (lstat(p_path, &t_stat) == -1)
74-
return false;
75-
76-
r_size = t_stat.st_size;
77-
return true;
78-
}
79-
80-
bool get_link_path(const char *p_link, char *&r_path)
81-
{
82-
bool t_success;
83-
t_success = true;
84-
85-
char *t_buffer;
86-
t_buffer = nil;
87-
uint32_t t_buffer_size;
88-
t_buffer_size = 0;
89-
90-
uint32_t t_link_size;
91-
t_success = get_link_size(p_link, t_link_size);
92-
93-
while (t_success && t_link_size + 1 > t_buffer_size)
94-
{
95-
t_buffer_size = t_link_size + 1;
96-
t_success = MCMemoryReallocate(t_buffer, t_buffer_size, t_buffer);
97-
98-
if (t_success)
99-
{
100-
int32_t t_read;
101-
t_read = readlink(p_link, t_buffer, t_buffer_size);
102-
103-
t_success = t_read >= 0;
104-
t_link_size = t_read;
105-
}
106-
}
107-
108-
if (t_success)
109-
{
110-
t_buffer[t_link_size] = '\0';
111-
r_path = t_buffer;
112-
}
113-
else
114-
MCMemoryDeallocate(t_buffer);
115-
116-
return t_success;
117-
}
118-
119-
bool get_exe_path_from_proc_fs(char *&r_path)
120-
{
121-
return get_link_path("/proc/self/exe", r_path);
122-
}
123-
65+
const char *MCCefPlatformGetExecutableFolder(void);
66+
bool MCCefLinuxAppendPath(const char *p_base, const char *p_path, char *&r_path);
12467
const char *MCCefPlatformGetCefFolder(void)
12568
{
126-
static char *s_cef_path = nil;
69+
static char *s_cef_path = nil;
12770

12871
if (s_cef_path == nil)
129-
{
130-
bool t_success;
131-
t_success = get_exe_path_from_proc_fs(s_cef_path);
132-
if (t_success)
133-
{
134-
// remove library component from path
135-
uint32_t t_index;
136-
if (MCCStringLastIndexOf(s_cef_path, '/', t_index))
137-
s_cef_path[t_index] = '\0';
138-
}
139-
}
140-
72+
/* UNCHECKED */ MCCefLinuxAppendPath(MCCefPlatformGetExecutableFolder(), "Externals/CEF", s_cef_path);
73+
14174
return s_cef_path;
14275
}
14376

0 commit comments

Comments
 (0)