Skip to content

Commit

Permalink
Build v55 on Mac Part 1 (#295)...
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cztomczak committed Feb 24, 2017
1 parent 101a223 commit 6b24eb1
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 91 deletions.
9 changes: 4 additions & 5 deletions docs/Build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ requirements common for all platforms.
are supported.



### All platforms

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

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

To build CEF from sources run the automate.py tool using the --build-cef
flag. The automate script will use version information from the
Expand Down
12 changes: 10 additions & 2 deletions src/client_handler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@

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

SRC = client_handler.cpp cookie_visitor.cpp resource_handler.cpp \
web_request_client.cpp string_visitor.cpp request_context_handler.cpp \
task.cpp x11.cpp context_menu_handler.cpp display_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

ifeq ($(UNAME_S), Darwin)
OBJ += util_mac.o
endif
Expand Down Expand Up @@ -56,6 +60,10 @@ $(OUT): $(OBJ)
@echo [CLIENT HANDLER] Creating library $(OUT) from $(OBJ)...
ar rcs $(OUT) $(OBJ)

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

util_mac.o: util_mac.mm
@echo [CLIENT HANDLER] Building $@ from $<...
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
Expand Down
2 changes: 2 additions & 0 deletions src/client_handler/lifespan_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) 2016 CEF Python. See the Authors and License files.

#include "lifespan_handler.h"
#if defined(OS_WIN)
#include "dpi_aware.h"
#endif
#include "LOG_DEBUG.h"


Expand Down
2 changes: 1 addition & 1 deletion src/compile_time_constants.pxi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file was generated by setup.py
DEF UNAME_SYSNAME = "Windows"
DEF UNAME_SYSNAME = "Darwin"
DEF PY_MAJOR_VERSION = 2
2 changes: 1 addition & 1 deletion src/extern/cef/cef_mac.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include "compile_time_constants.pxi"

from libcpp cimport bool as cpp_bool

cdef extern from "include/internal/cef_linux.h":
cdef extern from "include/internal/cef_mac.h":

ctypedef void* CefWindowHandle
ctypedef void* CefCursorHandle
Expand Down
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=gnu++11']
COMPILE_OPTIMIZE_FLAGS = ['-flto', '-std=c++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=gnu++11']
'-std=c++11']
LINK_OPTIMIZE_FLAGS = ['-flto', '-Wl,--gc-sections']


Expand Down
26 changes: 16 additions & 10 deletions src/subprocess/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,33 @@ ifeq ($(UNAME_S), Linux)
-L./../../build/cef_linux64/lib \
-L./../../build/cef_linux32/lib
else ifeq ($(UNAME_S), Darwin)
LIB_DIRS = -L./../../build/cef_mac64/bin \
-L./../../build/cef_mac32/bin \
-L./../../build/cef_mac64/lib \
-L./../../build/cef_mac32/lib
LIB_DIRS = -F$(CEF_BIN) \
-L$(CEF_LIB)
endif

ifeq ($(UNAME_S), Linux)
CPP_FILES = print_handler_gtk.cpp
LIBS = -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0
else
LIBS = -lcef -lgobject-2.0 -lglib-2.0 -lgtk-x11-2.0
else ifeq ($(UNAME_S), Darwin)
CPP_FILES =
LIBS =
LIBS = -framework Chromium\ Embedded\ Framework
endif

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

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 =
endif


subprocess:
# -fPIC is required only for libraries included by Cython.
@echo [SUBPROCESS] Building the 'subprocess' executable
g++ $(CCFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
g++ $(CCFLAGS) $(MACFLAGS) $(INC) $(LIB_DIRS) main.cpp cefpython_app.cpp \
v8function_handler.cpp v8utils.cpp javascript_callback.cpp \
$(CPP_FILES) \
$(LIBS) -lcef -lcef_dll_wrapper -o subprocess -Wl,-rpath,.
$(LIBS) -lcef_dll_wrapper -o subprocess -Wl,-rpath,.
2 changes: 1 addition & 1 deletion src/subprocess/Makefile-libcefpythonapp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

ifeq ($(UNAME_S), Linux)
Expand Down
102 changes: 102 additions & 0 deletions src/version/cef_version_mac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file is generated by the make_version_header.py tool.
//

#ifndef CEF_INCLUDE_CEF_VERSION_H_
#define CEF_INCLUDE_CEF_VERSION_H_

#define CEF_VERSION "3.2883.1553.g80bd606"
#define CEF_VERSION_MAJOR 3
#define CEF_COMMIT_NUMBER 1553
#define CEF_COMMIT_HASH "80bd6062d7ac4c5fd1d7bc7ee78e8e59d4a040aa"
#define COPYRIGHT_YEAR 2017

#define CHROME_VERSION_MAJOR 55
#define CHROME_VERSION_MINOR 0
#define CHROME_VERSION_BUILD 2883
#define CHROME_VERSION_PATCH 87

#define DO_MAKE_STRING(p) #p
#define MAKE_STRING(p) DO_MAKE_STRING(p)

#ifndef APSTUDIO_HIDDEN_SYMBOLS

#include "include/internal/cef_export.h"

#ifdef __cplusplus
extern "C" {
#endif

// The API hash is created by analyzing CEF header files for C API type
// definitions. The hash value will change when header files are modified
// in a way that may cause binary incompatibility with other builds. The
// universal hash value will change if any platform is affected whereas the
// platform hash values will change only if that particular platform is
// affected.
#define CEF_API_HASH_UNIVERSAL "87b7eefcb86c87b28f86bfd7919f7d7a6cffc0d8"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "00823905486d7b7222da5654fe35d2d15f65543a"
#elif defined(OS_MACOSX)
#define CEF_API_HASH_PLATFORM "f0180f006643782254250f34e858b98110a40e6e"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "14b19454a4231fa10a77b8955954dc95f073af6b"
#endif

// Returns CEF version information for the libcef library. The |entry|
// parameter describes which version component will be returned:
// 0 - CEF_VERSION_MAJOR
// 1 - CEF_COMMIT_NUMBER
// 2 - CHROME_VERSION_MAJOR
// 3 - CHROME_VERSION_MINOR
// 4 - CHROME_VERSION_BUILD
// 5 - CHROME_VERSION_PATCH
///
CEF_EXPORT int cef_version_info(int entry);

///
// Returns CEF API hashes for the libcef library. The returned string is owned
// by the library and should not be freed. The |entry| parameter describes which
// hash value will be returned:
// 0 - CEF_API_HASH_PLATFORM
// 1 - CEF_API_HASH_UNIVERSAL
// 2 - CEF_COMMIT_HASH
///
CEF_EXPORT const char* cef_api_hash(int entry);

#ifdef __cplusplus
}
#endif

#endif // APSTUDIO_HIDDEN_SYMBOLS

#endif // CEF_INCLUDE_CEF_VERSION_H_
12 changes: 9 additions & 3 deletions tools/automate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Usage:
automate.py (--prebuilt-cef | --build-cef)
[--fast-build FAST_BUILD]
[--force-chromium-update FORCE_CHROMIUM_UPDATE]
[--no-cef-update NO_CEF_UPDATE]
[--cef-branch BRANCH] [--cef-commit COMMIT]
Expand All @@ -34,6 +35,7 @@
binaries for Linux are built on Ubuntu.
--build-cef Whether to build CEF from sources with the
cefpython patches applied.
--fast-build Fast build with is_official_build=False
--force-chromium-update Force Chromium update (gclient sync etc).
--no-cef-update Do not update CEF sources (by default both cef/
directories are deleted on every run).
Expand Down Expand Up @@ -73,6 +75,7 @@ class Options(object):
# From command-line
prebuilt_cef = False
build_cef = False
fast_build = False
force_chromium_update = False
no_cef_update = False
cef_branch = ""
Expand Down Expand Up @@ -354,8 +357,11 @@ def build_cef_projects():
print("[automate.py] Build cefclient, cefsimple, ceftests")
# Cmake
command = prepare_build_command()
command.extend(["cmake", "-G", "Ninja",
"-DCMAKE_BUILD_TYPE="+Options.build_type, ".."])
command.extend(["cmake", "-G", "Ninja"])
command.append("-DCMAKE_BUILD_TYPE="+Options.build_type)
if MAC:
command.append("-DPROJECT_ARCH=x86_64")
command.append("..")
run_command(command, Options.build_cefclient_dir)
print("[automate.py] OK")
# Ninja
Expand Down Expand Up @@ -695,7 +701,7 @@ def getenv():
# To perform an official build set GYP_DEFINES=buildtype=Official.
# This will disable debugging code and enable additional link-time
# optimizations in Release builds.
if Options.release_build:
if Options.release_build and not Options.fast_build:
env["GN_DEFINES"] += " is_official_build=true"
# Modifications to automate-git.py
env["CEFPYTHON_NINJA_JOBS"] = str(Options.ninja_jobs)
Expand Down
Loading

0 comments on commit 6b24eb1

Please sign in to comment.