Skip to content

Commit eeef09a

Browse files
committed
Build v55 on Mac Part 2 (cztomczak#295)...
Update build tools and makefiles. Link to libc++ and libc++abi to avoid undefined symbol error. Fix visibility: PyMODINIT_FUNC. Minimum Mac version: 10.7. Do not use ctypes.CDLL on Mac, load CEF framework statically. Both Mac and Linux: Add -DNDEBUG and -O3 optimization flags. libcef_dll_wrapper needs to be built using this command: cmake -G "Ninja" -DPROJECT_ARCH="x86_64" \ -DCMAKE_CXX_FLAGS="-stdlib=libc++" \ -DCMAKE_BUILD_TYPE=Release .. ninja libcef_dll_wrapper
1 parent 6b24eb1 commit eeef09a

File tree

12 files changed

+312
-155
lines changed

12 files changed

+312
-155
lines changed

docs/Build-instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ requirements common for all platforms.
196196

197197
* MacOS 10.9+, Xcode5+ and Xcode command line tools. Only 64-bit builds
198198
are supported.
199+
* Upgrade setuptools package to latest version otherwise there will be
200+
problems with Cython: `sudo pip install --upgrade setuptools`
199201

200202

201203
### All platforms

src/__version__.pyx

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/cefpython.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,8 @@ END OF: CHANGES in CEF since v31..v47.
246246
# Includes being made in other .pyx files are allowed to help
247247
# IDE completion, but will be removed during cython compilation.
248248

249-
# Version file is generated by the compile.bat/compile.py script.
250-
include "__version__.pyx"
251-
252249
include "compile_time_constants.pxi"
253250

254-
255251
# -----------------------------------------------------------------------------
256252
# IMPORTS
257253

@@ -503,7 +499,11 @@ include "command_line.pyx"
503499
include "app.pyx"
504500
include "drag_data.pyx"
505501
include "helpers.pyx"
506-
include "image.pyx"
502+
503+
# Currently used only on Linux via DragData. Do not include on other
504+
# platforms otherwise warning about unused function appears.
505+
IF UNAME_SYSNAME == "Linux":
506+
include "image.pyx"
507507

508508
# Handlers
509509
include "handlers/browser_process_handler.pyx"
@@ -645,7 +645,7 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
645645
if "resources_dir_path" not in applicationSettings:
646646
applicationSettings["resources_dir_path"] = module_dir
647647
if platform.system() == "Darwin":
648-
applicationSettings["resources_dir_path"] = module_dir+"/Resources"
648+
pass # TODO: Check if this needs to be set in v56+
649649
if "browser_subprocess_path" not in applicationSettings:
650650
applicationSettings["browser_subprocess_path"] = os.path.join(
651651
module_dir, "subprocess")

src/client_handler/Makefile

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,29 @@
44
# -Wall - show important warnings
55
# -Werror - treat warnings as errors
66

7-
# Cython compiler options:
7+
# Cython compiler options on Linux:
88
# -fPIC -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions \
99
# -Wl,-z,relro
1010

1111
UNAME_S = $(shell uname -s)
12-
CC = g++
13-
CCFLAGS = -fPIC -std=c++11 -Wall -Werror $(CEF_CCFLAGS)
12+
CCFLAGS = -fPIC $(CEF_CCFLAGS)
13+
14+
ifeq ($(UNAME_S), Linux)
15+
SRC_MORE = x11.cpp
16+
else ifeq ($(UNAME_S), Darwin)
17+
SRC_MORE = util_mac.mm
18+
endif
1419

1520
SRC = client_handler.cpp cookie_visitor.cpp resource_handler.cpp \
1621
web_request_client.cpp string_visitor.cpp request_context_handler.cpp \
1722
task.cpp context_menu_handler.cpp display_handler.cpp \
1823
download_handler.cpp focus_handler.cpp js_dialog_handler.cpp \
1924
keyboard_handler.cpp lifespan_handler.cpp load_handler.cpp \
20-
render_handler.cpp request_handler.cpp
21-
22-
OBJ = $(SRC:.cpp=.o)
23-
24-
ifeq ($(UNAME_S), Linux)
25-
OBJ += x11.o
26-
endif
25+
render_handler.cpp request_handler.cpp \
26+
$(SRC_MORE)
2727

28-
ifeq ($(UNAME_S), Darwin)
29-
OBJ += util_mac.o
30-
endif
28+
OBJ = $(filter %.o, $(SRC:.cpp=.o) $(SRC:.mm=.o))
29+
.SUFFIXES: .cpp .mm .o
3130

3231
OUT = libclient_handler.a
3332

@@ -52,21 +51,19 @@ INC = -I./../ -I./../common/ -I/usr/include/python2.7 \
5251
-I/usr/lib/gtk-2.0/gtk-unix-print-2.0 \
5352
-I/usr/lib/glib-2.0/include
5453

55-
.cpp.o:
56-
@echo [CLIENT HANDLER] Building $@ from $<...
57-
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
5854

5955
$(OUT): $(OBJ)
6056
@echo [CLIENT HANDLER] Creating library $(OUT) from $(OBJ)...
6157
ar rcs $(OUT) $(OBJ)
6258

63-
x11.o: x11.cpp
59+
.cpp.o:
6460
@echo [CLIENT HANDLER] Building $@ from $<...
65-
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
61+
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@
6662

67-
util_mac.o: util_mac.mm
63+
.mm.o:
6864
@echo [CLIENT HANDLER] Building $@ from $<...
69-
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
65+
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@
66+
7067

7168
clean:
7269
@echo [CLIENT HANDLER] Cleaning...

src/cpp_utils/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
CC = g++
2-
CCFLAGS = -g $(CEF_CCFLAGS)
1+
CCFLAGS = -fPIC $(CEF_CCFLAGS)
32

43
SRC = PaintBuffer.cpp
54
OBJ = $(SRC:.cpp=.o)
@@ -15,7 +14,7 @@ INC = -I./../ -I/usr/include/gtk-2.0 \
1514
-I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include
1615

1716
.cpp.o:
18-
$(CC) -fPIC $(INC) $(CCFLAGS) -c $< -o $@
17+
$(CXX) $(INC) $(CCFLAGS) -c $< -o $@
1918

2019
$(OUT): $(OBJ)
2120
ar rcs $(OUT) $(OBJ)

src/linux/setup/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Fast mode disables optimization flags
1717
FAST = True
1818
print("FAST mode On")
19-
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-std=c++11']
19+
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-std=gnu++11']
2020
LINK_OPTIMIZE_FLAGS = ['-flto']
2121
else:
2222
FAST = False
@@ -25,7 +25,7 @@
2525
# prolongs compilation time significantly.
2626
# More on the other flags: https://stackoverflow.com/questions/6687630/
2727
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-fdata-sections', '-ffunction-sections',
28-
'-std=c++11']
28+
'-std=gnu++11']
2929
LINK_OPTIMIZE_FLAGS = ['-flto', '-Wl,--gc-sections']
3030

3131

src/subprocess/Makefile

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,18 @@ ifeq ($(UNAME_S), Linux)
4141
LIBS = -lcef -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0
4242
else ifeq ($(UNAME_S), Darwin)
4343
CPP_FILES =
44-
LIBS = -framework Chromium\ Embedded\ Framework
45-
endif
46-
47-
48-
CCFLAGS = -g -std=c++11 -Wall -Werror -DRENDERER_PROCESS $(CEF_CCFLAGS)
49-
50-
ifeq ($(UNAME_S), Darwin)
51-
MACFLAGS = -O3 -DNDEBUG -stdlib=libstdc++ \
52-
-Wl,-search_paths_first -Wl,-ObjC -Wl,-pie -Wl,-dead_strip
53-
else
54-
MACFLAGS =
44+
# Include framework before libcef_dll_wrapper
45+
LIBS = -framework "Chromium Embedded Framework"
5546
endif
5647

48+
CCFLAGS = -DRENDERER_PROCESS $(CEF_CCFLAGS)
5749

5850
subprocess:
5951
# -fPIC is required only for libraries included by Cython.
6052
@echo [SUBPROCESS] Building the 'subprocess' executable
61-
g++ $(CCFLAGS) $(MACFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
53+
$(CXX) $(CCFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
6254
v8function_handler.cpp v8utils.cpp javascript_callback.cpp \
6355
$(CPP_FILES) \
64-
$(LIBS) -lcef_dll_wrapper -o subprocess -Wl,-rpath,.
56+
$(CEF_LINK_FLAGS) \
57+
$(LIBS) -lcef_dll_wrapper \
58+
-o subprocess -Wl,-rpath,.

src/subprocess/Makefile-libcefpythonapp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,25 @@
99
# -Wl,-z,relro
1010

1111
UNAME_S = $(shell uname -s)
12-
CC = g++
13-
CCFLAGS = -fPIC -std=c++11 -Wall -Werror -DBROWSER_PROCESS \
14-
$(CEF_CCFLAGS)
12+
CCFLAGS = -fPIC -DBROWSER_PROCESS $(CEF_CCFLAGS)
1513

1614
ifeq ($(UNAME_S), Linux)
17-
CPP_FILES = print_handler_gtk.cpp \
18-
main_message_loop/main_message_loop_external_pump_linux.cpp
15+
SRC_MORE = print_handler_gtk.cpp \
16+
main_message_loop/main_message_loop_external_pump_linux.cpp
1917
else ifeq ($(UNAME_S), Darwin)
20-
CPP_FILES = \
21-
main_message_loop/main_message_loop_external_pump_mac.mm
22-
else
23-
CPP_FILES =
18+
SRC_MORE = main_message_loop/main_message_loop_external_pump_mac.mm
2419
endif
2520

26-
2721
SRC = cefpython_app.cpp v8function_handler.cpp v8utils.cpp \
2822
javascript_callback.cpp \
2923
main_message_loop/main_message_loop.cpp \
3024
main_message_loop/main_message_loop_std.cpp \
3125
main_message_loop/main_message_loop_external_pump.cpp \
32-
$(CPP_FILES)
33-
OBJ = $(SRC:.cpp=.o)
26+
$(SRC_MORE)
27+
28+
OBJ = $(filter %.o, $(SRC:.cpp=.o) $(SRC:.mm=.o))
29+
.SUFFIXES: .cpp .mm .o
30+
3431
OUT = libcefpythonapp.a
3532

3633
INC = -I./../ -I./../common/ -I/usr/include/python2.7 \
@@ -54,10 +51,14 @@ INC = -I./../ -I./../common/ -I/usr/include/python2.7 \
5451
-I/usr/lib/gtk-2.0/gtk-unix-print-2.0 \
5552
-I/usr/lib/glib-2.0/include
5653

57-
.cpp.o:
58-
@echo [CEFPYTHONAPP] Building $@ from $<...
59-
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
60-
6154
$(OUT): $(OBJ)
6255
@echo [CEFPYTHONAPP] Creating library $(OUT) from $(OBJ)...
6356
ar rcs $(OUT) $(OBJ)
57+
58+
.cpp.o:
59+
@echo [CEFPYTHONAPP] Building $@ from $<...
60+
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@
61+
62+
.mm.o:
63+
@echo [CEFPYTHONAPP] Building $@ from $<...
64+
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@

0 commit comments

Comments
 (0)