Skip to content

Commit 746d9a6

Browse files
committed
Update build instructions doc. Update automate.py for Linux...
Fix docopt options.
1 parent 169a1b2 commit 746d9a6

2 files changed

Lines changed: 86 additions & 47 deletions

File tree

‎docs/Build-instructions.md‎

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Build instructions
22

3+
NOTE: These instructions are for the master branch (Chrome 47).
4+
35
There are two types of builds you can perform. You can build
4-
PyCEF using the prebuilt CEF binaries. Or you can build both
5-
PyCEF and CEF from sources. Building CEF is a long process that
6+
CEF Python using the prebuilt CEF binaries. Or you can build both
7+
CEF Python and CEF from sources. Building CEF is a long process that
68
can take hours. In the tools/ directory there is the automate.py
7-
script that automates building. However before you can run it
9+
script that automates building CEF. However before you can run it
810
you must satisfy some requirements.
911

1012

1113
Table of contents:
1214
* [Requirements](#requirements)
13-
* [Build PyCEF using prebuilt CEF binaries](#build-pycef-using-prebuilt-cef-binaries)
14-
* [Build both PyCEF and CEF from sources](#build-both-pycef-and-cef-from-sources)
15+
* [Build CEF Python using prebuilt CEF binaries](#build-cefpython-using-prebuilt-cef-binaries)
16+
* [Build both CEF Python and CEF from sources](#build-both-cefpython-and-cef-from-sources)
1517
* [Build CEF manually](#build-cef-manually)
1618
* [How to patch](#how-to-patch)
1719
* [Ninja build slows down computer](#ninja-build-slows-down-computer)
@@ -32,8 +34,8 @@ __Windows__
3234
* For Python 3.5 - VS2015 compiler is required:
3335
https://docs.python.org/3.5/using/windows.html#compiling-python-on-windows
3436
* To build CEF from sources:
35-
* Use Win7 x64 or later. 32-bit OS'es are not supported. For more details see [here]
36-
(https://www.chromium.org/developers/how-tos/build-instructions-windows).
37+
* Use Win7 x64 or later. 32-bit OS'es are not supported. For more details
38+
see [here](https://www.chromium.org/developers/how-tos/build-instructions-windows).
3739
* For CEF branch >= 2704 install VS2015 Update 2 or later
3840
* For CEF branch < 2704 install VS2013 Update 4 or later
3941
* Install [CMake](https://cmake.org/) 2.8.12.1 or newer and add cmake.exe
@@ -42,9 +44,21 @@ __Windows__
4244
to PATH
4345
* You need about 16 GB of RAM during linking. If there is an error
4446
just add additional virtual memory.
45-
* For Python 2.7 copy "pycef/src/windows/stdint.h" to
47+
* For Python 2.7 copy "cefpython/src/windows/stdint.h" to
4648
"%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include\"
4749

50+
51+
__Linux__
52+
53+
* Building on Ubuntu 12.04 is supported up to branch 2526 (Chrome 47).
54+
For branches 2623 (Chrome 49) or later Ubuntu 14.04+ is required.
55+
* To build on Debian 7 see
56+
[cef/BuildingOnDebian7.md](https://bitbucket.org/chromiumembedded/cef/wiki/BuildingOnDebian7.md) and
57+
[cef/#1575](https://bitbucket.org/chromiumembedded/cef/issues/1575)
58+
* To perform a 32-bit Linux build on a 64-bit Linux system see
59+
[cef/#1804](https://bitbucket.org/chromiumembedded/cef/issues/1804)
60+
61+
4862
__All platforms__
4963

5064
* Install dependencies for the automate.py tool by executing:
@@ -53,7 +67,7 @@ __All platforms__
5367
requires a VS compiler - see instructions above for Windows.
5468

5569

56-
## Build PyCEF using prebuilt CEF binaries
70+
## Build CEF Python using prebuilt CEF binaries
5771

5872
Run the automate.py tool using the --prebuilt-cef flag:
5973
```
@@ -65,12 +79,13 @@ You should be fine by running it with the default options, but if you
6579
need to customize the build then use the --help flag to see more.
6680

6781

68-
## Build both PyCEF and CEF from sources
82+
## Build both CEF Python and CEF from sources
6983

70-
Run the automate.py tool using the --build-cef flag:
84+
Run the automate.py tool using the --build-cef flag. Specify cef branch
85+
and optionally how many parallel ninja jobs to run (by default cores/2).
7186
```
7287
cd tools/
73-
python automate.py --build-cef --cef-branch 2526
88+
python automate.py --build-cef --cef-branch 2526 --ninja-jobs 6
7489
```
7590

7691
You should be fine by running it with the default options, but if you
@@ -86,8 +101,8 @@ patches/ directory.
86101
On Linux before running any of CEF tools apply the issue73 patch
87102
first.
88103

89-
To build CEF follow the instructions on the Branches and
90-
Building CEF wiki page:
104+
To build CEF follow the instructions on the Branches and Building
105+
CEF wiki page:
91106
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
92107

93108
After it is successfully built - apply patches, rebuild and remake

‎tools/automate.py‎

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,23 @@
1111
automate.py (-h | --help) [type -h to show full description for options]
1212
1313
Options:
14-
-h --help Show this help message.
15-
--prebuilt-cef Whether to use prebuilt CEF binaries. Prebuilt
16-
binaries for Linux are built on Ubuntu.
17-
--build-cef Whether to build CEF from sources with the cefpython
18-
patches applied.
19-
--cef-branch CEF branch. Defaults to CHROME_VERSION_BUILD from
20-
"src/version/cef_version_{platform}.h" (TODO).
21-
--cef-commit CEF revision. Defaults to CEF_COMMIT_HASH from
22-
"src/version/cef_version_{platform}.h" (TODO).
23-
--build-dir Build directory.
24-
--cef-build-dir CEF build directory. By default same as --build-dir.
25-
--ninja-jobs How many CEF jobs to run in parallel. To speed up
26-
building set it to number of cores in your CPU.
27-
By default set to cpu_count / 2.
28-
--gyp-generators Set GYP_GENERATORS [default: ninja].
29-
--gyp-msvs-version Set GYP_MSVS_VERSION.
14+
-h --help Show this help message.
15+
--prebuilt-cef Whether to use prebuilt CEF binaries. Prebuilt
16+
binaries for Linux are built on Ubuntu.
17+
--build-cef Whether to build CEF from sources with the cefpython
18+
patches applied.
19+
--cef-branch=<b> CEF branch. Defaults to CHROME_VERSION_BUILD from
20+
"src/version/cef_version_{platform}.h" (TODO).
21+
--cef-commit=<c> CEF revision. Defaults to CEF_COMMIT_HASH from
22+
"src/version/cef_version_{platform}.h" (TODO).
23+
--build-dir=<dir1> Build directory.
24+
--cef-build-dir=<dir2> CEF build directory. By default same
25+
as --build-dir.
26+
--ninja-jobs=<jobs> How many CEF jobs to run in parallel. To speed up
27+
building set it to number of cores in your CPU.
28+
By default set to cpu_count / 2.
29+
--gyp-generators=<gen> Set GYP_GENERATORS [default: ninja].
30+
--gyp-msvs-version=<v> Set GYP_MSVS_VERSION.
3031
3132
"""
3233

@@ -118,12 +119,6 @@ def setup_options(docopt_args):
118119
usage = __doc__
119120
for key in docopt_args:
120121
value = docopt_args[key]
121-
if key.startswith("--"):
122-
match = re.search(r"\[%s\s+([^\]]+)\]" % (re.escape(key),),
123-
usage)
124-
if match:
125-
arg_key = match.group(1)
126-
value = docopt_args[arg_key]
127122
key2 = key.replace("--", "").replace("-", "_")
128123
if hasattr(Options, key2) and value is not None:
129124
setattr(Options, key2, value)
@@ -153,6 +148,8 @@ def setup_options(docopt_args):
153148
print("[automate.py] ERROR: Build dir cannot contain spaces")
154149
print(">> " + Options.build_dir)
155150
sys.exit(1)
151+
if not os.path.exists(Options.build_dir):
152+
os.makedirs(Options.build_dir)
156153

157154
# --cef-build-dir
158155
if Options.cef_build_dir:
@@ -163,6 +160,8 @@ def setup_options(docopt_args):
163160
print("[automate.py] ERROR: CEF build dir cannot contain spaces")
164161
print(">> " + Options.cef_build_dir)
165162
sys.exit(1)
163+
if not os.path.exists(Options.cef_build_dir):
164+
os.makedirs(Options.cef_build_dir)
166165

167166
# --depot-tools-dir
168167
Options.depot_tools_dir = os.path.join(Options.cef_build_dir,
@@ -279,11 +278,7 @@ def build_cef_projects():
279278
cef_binary = symbols.replace("_debug_symbols", "")
280279
assert "symbols" not in os.path.basename(cef_binary)
281280
build_cefclient = os.path.join(cef_binary, "build_cefclient")
282-
build_wrapper_mt = os.path.join(cef_binary, "build_wrapper_mt")
283-
build_wrapper_md = os.path.join(cef_binary, "build_wrapper_md")
284281
os.makedirs(build_cefclient)
285-
os.makedirs(build_wrapper_mt)
286-
os.makedirs(build_wrapper_md)
287282

288283
# Build cefclient and cefsimple
289284
print("[automate.py] Building cefclient and cefsimple...")
@@ -301,6 +296,9 @@ def build_cef_projects():
301296
if platform.system() == "Windows":
302297
assert(os.path.exists(os.path.join(build_cefclient, "cefclient",
303298
"cefclient.exe")))
299+
else:
300+
assert (os.path.exists(os.path.join(build_cefclient, "cefclient",
301+
"cefclient")))
304302

305303
# Command to build libcef_dll_wrapper
306304
wrapper_command = ""
@@ -310,16 +308,29 @@ def build_cef_projects():
310308
% Options.build_type
311309
wrapper_command += "ninja libcef_dll_wrapper"
312310

311+
# Build libcef_dll_wrapper libs
312+
if platform.system() == "Windows":
313+
build_wrapper_windows(cef_binary, wrapper_command)
314+
elif platform.system() == "Linux":
315+
build_wrapper_linux(cef_binary, wrapper_command)
316+
317+
318+
def build_wrapper_windows(cef_binary, wrapper_command):
319+
# Directories
320+
build_wrapper_mt = os.path.join(cef_binary, "build_wrapper_mt")
321+
build_wrapper_md = os.path.join(cef_binary, "build_wrapper_md")
322+
os.makedirs(build_wrapper_mt)
323+
os.makedirs(build_wrapper_md)
324+
313325
# Build libcef_dll_wrapper_mt.lib
314326
print("[automate.py] Building libcef_dll_wrapper /MT")
315327
old_gyp_msvs_version = Options.gyp_msvs_version
316328
Options.gyp_msvs_version = get_msvs_for_python()
317329
run_command(wrapper_command, build_wrapper_mt)
318330
Options.gyp_msvs_version = old_gyp_msvs_version
319331
print("[automate.py] OK")
320-
if platform.system() == "Windows":
321-
assert(os.path.exists(os.path.join(build_wrapper_mt, "libcef_dll",
322-
"libcef_dll_wrapper.lib")))
332+
assert(os.path.exists(os.path.join(build_wrapper_mt, "libcef_dll",
333+
"libcef_dll_wrapper.lib")))
323334

324335
# Build libcef_dll_wrapper_md.lib
325336
print("[automate.py] Building libcef_dll_wrapper /MD")
@@ -340,9 +351,21 @@ def build_cef_projects():
340351
run_command(wrapper_command, build_wrapper_md)
341352
Options.gyp_msvs_version = old_gyp_msvs_version
342353
print("[automate.py] OK")
343-
if platform.system() == "Windows":
344-
assert(os.path.exists(os.path.join(build_wrapper_md, "libcef_dll",
345-
"libcef_dll_wrapper.lib")))
354+
assert(os.path.exists(os.path.join(build_wrapper_md, "libcef_dll",
355+
"libcef_dll_wrapper.lib")))
356+
357+
358+
def build_wrapper_linux(cef_binary, wrapper_command):
359+
# Directory
360+
build_wrapper = os.path.join(cef_binary, "build_wrapper")
361+
os.makedirs(build_wrapper)
362+
363+
# Build libcef_dll_wrapper.a and .o files
364+
print("[automate.py] Building libcef_dll_wrapper")
365+
run_command(wrapper_command, build_wrapper)
366+
print("[automate.py] OK")
367+
assert(os.path.exists(os.path.join(build_wrapper, "libcef_dll",
368+
"libcef_dll_wrapper.a")))
346369

347370

348371
def get_msvs_for_python():
@@ -415,7 +438,8 @@ def run_automate_git():
415438
ninja -v -j2 -Cout\Release cefclient
416439
"""
417440
args = []
418-
if ARCH64:
441+
if ARCH64 and platform.system() != "Linux":
442+
# The x64 build flag is only supported on Windows and Mac OS X.
419443
args.append("--x64-build")
420444
args.append("--download-dir=" + Options.cef_build_dir)
421445
args.append("--branch=" + Options.cef_branch)

0 commit comments

Comments
 (0)