Skip to content

Commit

Permalink
Build v55 on Mac Part 2 (#295)...
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cztomczak committed Feb 27, 2017
1 parent 6b24eb1 commit eeef09a
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 155 deletions.
2 changes: 2 additions & 0 deletions docs/Build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ requirements common for all platforms.

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


### All platforms
Expand Down
2 changes: 0 additions & 2 deletions src/__version__.pyx

This file was deleted.

12 changes: 6 additions & 6 deletions src/cefpython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,8 @@ END OF: CHANGES in CEF since v31..v47.
# Includes being made in other .pyx files are allowed to help
# IDE completion, but will be removed during cython compilation.

# Version file is generated by the compile.bat/compile.py script.
include "__version__.pyx"

include "compile_time_constants.pxi"


# -----------------------------------------------------------------------------
# IMPORTS

Expand Down Expand Up @@ -503,7 +499,11 @@ include "command_line.pyx"
include "app.pyx"
include "drag_data.pyx"
include "helpers.pyx"
include "image.pyx"

# Currently used only on Linux via DragData. Do not include on other
# platforms otherwise warning about unused function appears.
IF UNAME_SYSNAME == "Linux":
include "image.pyx"

# Handlers
include "handlers/browser_process_handler.pyx"
Expand Down Expand Up @@ -645,7 +645,7 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
if "resources_dir_path" not in applicationSettings:
applicationSettings["resources_dir_path"] = module_dir
if platform.system() == "Darwin":
applicationSettings["resources_dir_path"] = module_dir+"/Resources"
pass # TODO: Check if this needs to be set in v56+
if "browser_subprocess_path" not in applicationSettings:
applicationSettings["browser_subprocess_path"] = os.path.join(
module_dir, "subprocess")
Expand Down
37 changes: 17 additions & 20 deletions src/client_handler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@
# -Wall - show important warnings
# -Werror - treat warnings as errors

# Cython compiler options:
# Cython compiler options on Linux:
# -fPIC -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions \
# -Wl,-z,relro

UNAME_S = $(shell uname -s)
CC = g++
CCFLAGS = -fPIC -std=c++11 -Wall -Werror $(CEF_CCFLAGS)
CCFLAGS = -fPIC $(CEF_CCFLAGS)

ifeq ($(UNAME_S), Linux)
SRC_MORE = x11.cpp
else ifeq ($(UNAME_S), Darwin)
SRC_MORE = util_mac.mm
endif

SRC = client_handler.cpp cookie_visitor.cpp resource_handler.cpp \
web_request_client.cpp string_visitor.cpp request_context_handler.cpp \
task.cpp context_menu_handler.cpp display_handler.cpp \
download_handler.cpp focus_handler.cpp js_dialog_handler.cpp \
keyboard_handler.cpp lifespan_handler.cpp load_handler.cpp \
render_handler.cpp request_handler.cpp

OBJ = $(SRC:.cpp=.o)

ifeq ($(UNAME_S), Linux)
OBJ += x11.o
endif
render_handler.cpp request_handler.cpp \
$(SRC_MORE)

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

OUT = libclient_handler.a

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

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

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

x11.o: x11.cpp
.cpp.o:
@echo [CLIENT HANDLER] Building $@ from $<...
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@

util_mac.o: util_mac.mm
.mm.o:
@echo [CLIENT HANDLER] Building $@ from $<...
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@


clean:
@echo [CLIENT HANDLER] Cleaning...
Expand Down
5 changes: 2 additions & 3 deletions src/cpp_utils/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CC = g++
CCFLAGS = -g $(CEF_CCFLAGS)
CCFLAGS = -fPIC $(CEF_CCFLAGS)

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

.cpp.o:
$(CC) -fPIC $(INC) $(CCFLAGS) -c $< -o $@
$(CXX) $(INC) $(CCFLAGS) -c $< -o $@

$(OUT): $(OBJ)
ar rcs $(OUT) $(OBJ)
4 changes: 2 additions & 2 deletions src/linux/setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Fast mode disables optimization flags
FAST = True
print("FAST mode On")
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-std=c++11']
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-std=gnu++11']
LINK_OPTIMIZE_FLAGS = ['-flto']
else:
FAST = False
Expand All @@ -25,7 +25,7 @@
# prolongs compilation time significantly.
# More on the other flags: https://stackoverflow.com/questions/6687630/
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-fdata-sections', '-ffunction-sections',
'-std=c++11']
'-std=gnu++11']
LINK_OPTIMIZE_FLAGS = ['-flto', '-Wl,--gc-sections']


Expand Down
20 changes: 7 additions & 13 deletions src/subprocess/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,18 @@ ifeq ($(UNAME_S), Linux)
LIBS = -lcef -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0
else ifeq ($(UNAME_S), Darwin)
CPP_FILES =
LIBS = -framework Chromium\ Embedded\ Framework
endif


CCFLAGS = -g -std=c++11 -Wall -Werror -DRENDERER_PROCESS $(CEF_CCFLAGS)

ifeq ($(UNAME_S), Darwin)
MACFLAGS = -O3 -DNDEBUG -stdlib=libstdc++ \
-Wl,-search_paths_first -Wl,-ObjC -Wl,-pie -Wl,-dead_strip
else
MACFLAGS =
# Include framework before libcef_dll_wrapper
LIBS = -framework "Chromium Embedded Framework"
endif

CCFLAGS = -DRENDERER_PROCESS $(CEF_CCFLAGS)

subprocess:
# -fPIC is required only for libraries included by Cython.
@echo [SUBPROCESS] Building the 'subprocess' executable
g++ $(CCFLAGS) $(MACFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
$(CXX) $(CCFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
v8function_handler.cpp v8utils.cpp javascript_callback.cpp \
$(CPP_FILES) \
$(LIBS) -lcef_dll_wrapper -o subprocess -Wl,-rpath,.
$(CEF_LINK_FLAGS) \
$(LIBS) -lcef_dll_wrapper \
-o subprocess -Wl,-rpath,.
33 changes: 17 additions & 16 deletions src/subprocess/Makefile-libcefpythonapp
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,25 @@
# -Wl,-z,relro

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

ifeq ($(UNAME_S), Linux)
CPP_FILES = print_handler_gtk.cpp \
main_message_loop/main_message_loop_external_pump_linux.cpp
SRC_MORE = print_handler_gtk.cpp \
main_message_loop/main_message_loop_external_pump_linux.cpp
else ifeq ($(UNAME_S), Darwin)
CPP_FILES = \
main_message_loop/main_message_loop_external_pump_mac.mm
else
CPP_FILES =
SRC_MORE = main_message_loop/main_message_loop_external_pump_mac.mm
endif


SRC = cefpython_app.cpp v8function_handler.cpp v8utils.cpp \
javascript_callback.cpp \
main_message_loop/main_message_loop.cpp \
main_message_loop/main_message_loop_std.cpp \
main_message_loop/main_message_loop_external_pump.cpp \
$(CPP_FILES)
OBJ = $(SRC:.cpp=.o)
$(SRC_MORE)

OBJ = $(filter %.o, $(SRC:.cpp=.o) $(SRC:.mm=.o))
.SUFFIXES: .cpp .mm .o

OUT = libcefpythonapp.a

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

.cpp.o:
@echo [CEFPYTHONAPP] Building $@ from $<...
$(CC) $(CCFLAGS) $(INC) -c $< -o $@

$(OUT): $(OBJ)
@echo [CEFPYTHONAPP] Creating library $(OUT) from $(OBJ)...
ar rcs $(OUT) $(OBJ)

.cpp.o:
@echo [CEFPYTHONAPP] Building $@ from $<...
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@

.mm.o:
@echo [CEFPYTHONAPP] Building $@ from $<...
$(CXX) $(CCFLAGS) $(INC) -c $< -o $@
Loading

0 comments on commit eeef09a

Please sign in to comment.