Skip to content

Commit 6b24eb1

Browse files
committed
Build v55 on Mac Part 1 (cztomczak#295)...
Successfully built the cefpython module. There are still some warnings and issues to resolve, but it looks good. Update makefiles. Update installer setup for Mac. Update Mac requirements in build instructions. Add --fast-build option to automate.py.
1 parent 101a223 commit 6b24eb1

File tree

13 files changed

+226
-91
lines changed

13 files changed

+226
-91
lines changed

docs/Build-instructions.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ requirements common for all platforms.
198198
are supported.
199199

200200

201-
202201
### All platforms
203202

204203
* Install dependencies for the automate.py tool by executing:
@@ -267,10 +266,10 @@ python ../tools/build.py xx.x
267266

268267
Building CEF from sources is a very long process that can take several
269268
hours depending on your CPU speed and the platform you're building on.
270-
If you would like to speed up the process you could modify automate.py
271-
tool and remove the `is_official_build=true` flag which slows down
272-
builds significantly (PR to add an option for that is welcome).
273-
You can optionally set how many parallel ninja jobs to run (by default cores/2) with the --ninja-jobs flag passed to automate.py.
269+
To speed up the process you can pass the --fast-build flag, however
270+
in such case result binaries won't be optimized.
271+
You can optionally set how many parallel ninja jobs to run (by default
272+
cores/2) with the --ninja-jobs flag passed to automate.py.
274273

275274
To build CEF from sources run the automate.py tool using the --build-cef
276275
flag. The automate script will use version information from the

src/client_handler/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@
1010

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

1515
SRC = client_handler.cpp cookie_visitor.cpp resource_handler.cpp \
1616
web_request_client.cpp string_visitor.cpp request_context_handler.cpp \
17-
task.cpp x11.cpp context_menu_handler.cpp display_handler.cpp \
17+
task.cpp context_menu_handler.cpp display_handler.cpp \
1818
download_handler.cpp focus_handler.cpp js_dialog_handler.cpp \
1919
keyboard_handler.cpp lifespan_handler.cpp load_handler.cpp \
2020
render_handler.cpp request_handler.cpp
2121

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

24+
ifeq ($(UNAME_S), Linux)
25+
OBJ += x11.o
26+
endif
27+
2428
ifeq ($(UNAME_S), Darwin)
2529
OBJ += util_mac.o
2630
endif
@@ -56,6 +60,10 @@ $(OUT): $(OBJ)
5660
@echo [CLIENT HANDLER] Creating library $(OUT) from $(OBJ)...
5761
ar rcs $(OUT) $(OBJ)
5862

63+
x11.o: x11.cpp
64+
@echo [CLIENT HANDLER] Building $@ from $<...
65+
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
66+
5967
util_mac.o: util_mac.mm
6068
@echo [CLIENT HANDLER] Building $@ from $<...
6169
$(CC) $(CCFLAGS) $(INC) -c $< -o $@

src/client_handler/lifespan_handler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright (c) 2016 CEF Python. See the Authors and License files.
22

33
#include "lifespan_handler.h"
4+
#if defined(OS_WIN)
45
#include "dpi_aware.h"
6+
#endif
57
#include "LOG_DEBUG.h"
68

79

src/compile_time_constants.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file was generated by setup.py
2-
DEF UNAME_SYSNAME = "Windows"
2+
DEF UNAME_SYSNAME = "Darwin"
33
DEF PY_MAJOR_VERSION = 2

src/extern/cef/cef_mac.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include "compile_time_constants.pxi"
66

77
from libcpp cimport bool as cpp_bool
88

9-
cdef extern from "include/internal/cef_linux.h":
9+
cdef extern from "include/internal/cef_mac.h":
1010

1111
ctypedef void* CefWindowHandle
1212
ctypedef void* CefCursorHandle

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=gnu++11']
19+
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-std=c++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=gnu++11']
28+
'-std=c++11']
2929
LINK_OPTIMIZE_FLAGS = ['-flto', '-Wl,--gc-sections']
3030

3131

src/subprocess/Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,33 @@ ifeq ($(UNAME_S), Linux)
3232
-L./../../build/cef_linux64/lib \
3333
-L./../../build/cef_linux32/lib
3434
else ifeq ($(UNAME_S), Darwin)
35-
LIB_DIRS = -L./../../build/cef_mac64/bin \
36-
-L./../../build/cef_mac32/bin \
37-
-L./../../build/cef_mac64/lib \
38-
-L./../../build/cef_mac32/lib
35+
LIB_DIRS = -F$(CEF_BIN) \
36+
-L$(CEF_LIB)
3937
endif
4038

4139
ifeq ($(UNAME_S), Linux)
4240
CPP_FILES = print_handler_gtk.cpp
43-
LIBS = -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0
44-
else
41+
LIBS = -lcef -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0
42+
else ifeq ($(UNAME_S), Darwin)
4543
CPP_FILES =
46-
LIBS =
44+
LIBS = -framework Chromium\ Embedded\ Framework
4745
endif
4846

49-
CCFLAGS = -g -std=gnu++11 -Wall -Werror -DRENDERER_PROCESS $(CEF_CCFLAGS)
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 =
55+
endif
5056

5157

5258
subprocess:
5359
# -fPIC is required only for libraries included by Cython.
5460
@echo [SUBPROCESS] Building the 'subprocess' executable
55-
g++ $(CCFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
61+
g++ $(CCFLAGS) $(MACFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
5662
v8function_handler.cpp v8utils.cpp javascript_callback.cpp \
5763
$(CPP_FILES) \
58-
$(LIBS) -lcef -lcef_dll_wrapper -o subprocess -Wl,-rpath,.
64+
$(LIBS) -lcef_dll_wrapper -o subprocess -Wl,-rpath,.

src/subprocess/Makefile-libcefpythonapp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
UNAME_S = $(shell uname -s)
1212
CC = g++
13-
CCFLAGS = -fPIC -std=gnu++11 -Wall -Werror -DBROWSER_PROCESS \
13+
CCFLAGS = -fPIC -std=c++11 -Wall -Werror -DBROWSER_PROCESS \
1414
$(CEF_CCFLAGS)
1515

1616
ifeq ($(UNAME_S), Linux)

src/version/cef_version_mac.h

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions are
5+
// met:
6+
//
7+
// * Redistributions of source code must retain the above copyright
8+
// notice, this list of conditions and the following disclaimer.
9+
// * Redistributions in binary form must reproduce the above
10+
// copyright notice, this list of conditions and the following disclaimer
11+
// in the documentation and/or other materials provided with the
12+
// distribution.
13+
// * Neither the name of Google Inc. nor the name Chromium Embedded
14+
// Framework nor the names of its contributors may be used to endorse
15+
// or promote products derived from this software without specific prior
16+
// written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
//
30+
// ---------------------------------------------------------------------------
31+
//
32+
// This file is generated by the make_version_header.py tool.
33+
//
34+
35+
#ifndef CEF_INCLUDE_CEF_VERSION_H_
36+
#define CEF_INCLUDE_CEF_VERSION_H_
37+
38+
#define CEF_VERSION "3.2883.1553.g80bd606"
39+
#define CEF_VERSION_MAJOR 3
40+
#define CEF_COMMIT_NUMBER 1553
41+
#define CEF_COMMIT_HASH "80bd6062d7ac4c5fd1d7bc7ee78e8e59d4a040aa"
42+
#define COPYRIGHT_YEAR 2017
43+
44+
#define CHROME_VERSION_MAJOR 55
45+
#define CHROME_VERSION_MINOR 0
46+
#define CHROME_VERSION_BUILD 2883
47+
#define CHROME_VERSION_PATCH 87
48+
49+
#define DO_MAKE_STRING(p) #p
50+
#define MAKE_STRING(p) DO_MAKE_STRING(p)
51+
52+
#ifndef APSTUDIO_HIDDEN_SYMBOLS
53+
54+
#include "include/internal/cef_export.h"
55+
56+
#ifdef __cplusplus
57+
extern "C" {
58+
#endif
59+
60+
// The API hash is created by analyzing CEF header files for C API type
61+
// definitions. The hash value will change when header files are modified
62+
// in a way that may cause binary incompatibility with other builds. The
63+
// universal hash value will change if any platform is affected whereas the
64+
// platform hash values will change only if that particular platform is
65+
// affected.
66+
#define CEF_API_HASH_UNIVERSAL "87b7eefcb86c87b28f86bfd7919f7d7a6cffc0d8"
67+
#if defined(OS_WIN)
68+
#define CEF_API_HASH_PLATFORM "00823905486d7b7222da5654fe35d2d15f65543a"
69+
#elif defined(OS_MACOSX)
70+
#define CEF_API_HASH_PLATFORM "f0180f006643782254250f34e858b98110a40e6e"
71+
#elif defined(OS_LINUX)
72+
#define CEF_API_HASH_PLATFORM "14b19454a4231fa10a77b8955954dc95f073af6b"
73+
#endif
74+
75+
// Returns CEF version information for the libcef library. The |entry|
76+
// parameter describes which version component will be returned:
77+
// 0 - CEF_VERSION_MAJOR
78+
// 1 - CEF_COMMIT_NUMBER
79+
// 2 - CHROME_VERSION_MAJOR
80+
// 3 - CHROME_VERSION_MINOR
81+
// 4 - CHROME_VERSION_BUILD
82+
// 5 - CHROME_VERSION_PATCH
83+
///
84+
CEF_EXPORT int cef_version_info(int entry);
85+
86+
///
87+
// Returns CEF API hashes for the libcef library. The returned string is owned
88+
// by the library and should not be freed. The |entry| parameter describes which
89+
// hash value will be returned:
90+
// 0 - CEF_API_HASH_PLATFORM
91+
// 1 - CEF_API_HASH_UNIVERSAL
92+
// 2 - CEF_COMMIT_HASH
93+
///
94+
CEF_EXPORT const char* cef_api_hash(int entry);
95+
96+
#ifdef __cplusplus
97+
}
98+
#endif
99+
100+
#endif // APSTUDIO_HIDDEN_SYMBOLS
101+
102+
#endif // CEF_INCLUDE_CEF_VERSION_H_

tools/automate.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
Usage:
2222
automate.py (--prebuilt-cef | --build-cef)
23+
[--fast-build FAST_BUILD]
2324
[--force-chromium-update FORCE_CHROMIUM_UPDATE]
2425
[--no-cef-update NO_CEF_UPDATE]
2526
[--cef-branch BRANCH] [--cef-commit COMMIT]
@@ -34,6 +35,7 @@
3435
binaries for Linux are built on Ubuntu.
3536
--build-cef Whether to build CEF from sources with the
3637
cefpython patches applied.
38+
--fast-build Fast build with is_official_build=False
3739
--force-chromium-update Force Chromium update (gclient sync etc).
3840
--no-cef-update Do not update CEF sources (by default both cef/
3941
directories are deleted on every run).
@@ -73,6 +75,7 @@ class Options(object):
7375
# From command-line
7476
prebuilt_cef = False
7577
build_cef = False
78+
fast_build = False
7679
force_chromium_update = False
7780
no_cef_update = False
7881
cef_branch = ""
@@ -354,8 +357,11 @@ def build_cef_projects():
354357
print("[automate.py] Build cefclient, cefsimple, ceftests")
355358
# Cmake
356359
command = prepare_build_command()
357-
command.extend(["cmake", "-G", "Ninja",
358-
"-DCMAKE_BUILD_TYPE="+Options.build_type, ".."])
360+
command.extend(["cmake", "-G", "Ninja"])
361+
command.append("-DCMAKE_BUILD_TYPE="+Options.build_type)
362+
if MAC:
363+
command.append("-DPROJECT_ARCH=x86_64")
364+
command.append("..")
359365
run_command(command, Options.build_cefclient_dir)
360366
print("[automate.py] OK")
361367
# Ninja
@@ -695,7 +701,7 @@ def getenv():
695701
# To perform an official build set GYP_DEFINES=buildtype=Official.
696702
# This will disable debugging code and enable additional link-time
697703
# optimizations in Release builds.
698-
if Options.release_build:
704+
if Options.release_build and not Options.fast_build:
699705
env["GN_DEFINES"] += " is_official_build=true"
700706
# Modifications to automate-git.py
701707
env["CEFPYTHON_NINJA_JOBS"] = str(Options.ninja_jobs)

0 commit comments

Comments
 (0)