-
-
Notifications
You must be signed in to change notification settings - Fork 473
BuildOnWindows
Instructions on this page are for the old cefpython31 branch. New instructions for newer branches / master are at docs/Build-instructions.md.
The original instructions on building Chromium/CEF can be found on the CEF project Branches and Building wiki page.
Table of contents:
- The steps of downloading and building Chromium from sources may be skipped by downloading CEF ready binaries from cefbuilds.com. The branch and revision must match with the ones provided in the BUILD_COMPATIBILITY.txt file.
- The path to the chromium directory should not contain any spaces
- Compiling cefpython was tested with Python 2.7 / 3.2 (32bit). See Issue 121 for Python 3.4 support.
- To build Chromium you will need Windows 7 64-bit or later.
- The result binaries require at least Windows XP SP3 to run.
- To build 64-bit binaries you will need VS2008 Pro. The Express edition cannot is missing the x64 platform configuration.
- See the "Build environment" section on the Chromium project site, the instructions are available for Visual Studio 2010 and for the Express edition which is free:
(link seems no more relevant, as Chrome now officially uses VS 2013, but CEF Python probably still requires VS 2010 as it uses an older version of Chrome)
http://www.chromium.org/developers/how-tos/build-instructions-windows#TOC-Build-environment
You have to install Visual Studio 2010 with Service Packs and x64 compiler tools, Windows SDK and DirectX SDK. Do not install the Cygwin.
- Install depot_tools:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
If you do not have git installed download and extract depot_tools from here:
https://src.chromium.org/svn/trunk/tools/depot_tools.zip
-
Add depot_tools directory to your system PATH (Advanced System Settings > Environment Variables > System variables > PATH).
-
Run the gclient once command:
gclient once
This will install git, svn and python to the depot_tools directory.
- Python 2.6.2 has been installed to the depot_tools directory that shall be used from now on by gclient and the CEF tools, if you have some other python in your system PATH then this may cause conflicts, remove it or add depot_tools at the beginning of the system PATH. After the PATH is modified make sure you're running the python from depot tools by running the command:
python --version
It should display "Python 2.6.2".
- Go open the BUILD_COMPATIBILITY.txt file.
For CEF 1: ../blob/master/cefpython/cef1/BUILD_COMPATIBILITY.txt
For CEF 3: ../blob/master/src/BUILD_COMPATIBILITY.txt
Later we will need the "Chromium release url" and and the "CEF repository url" so keep it in sight.
- Create the "chromium" directory:
mkdir chromium
- Configure Chromium to use a specific revision (through a release url) by running the "gclient config" command, the release url we will be using is from the BUILD_COMPATIBILITY.txt file:
cd chromium/
gclient config {Chromium release url}
- Edit the "chromium/.gclient" and edit the "custom_deps" to reduce the size of the sources to downoad:
"custom_deps": {
"src/content/test/data/layout_tests/LayoutTests": None,
"src/chrome/tools/test/reference_build/chrome_win": None,
"src/chrome_frame/tools/test/reference_build/chrome_win": None,
"src/chrome/tools/test/reference_build/chrome_linux": None,
"src/chrome/tools/test/reference_build/chrome_mac": None,
"src/third_party/hunspell_dictionaries": None,
},
This excludes some directories that contain lots of data (many many gigabytes) that would extend the time significantly when synchronizing Chromium sources with the revision we've selected.
- Type the "svn ls" command and permanently accept the SSL certificate if it appears:
svn ls https://src.chromium.org/chrome
Download the Chromium sources by running the "gclient sync" command. The Chromium sources will be updated to the revision based on the release url we've configured earlier via "gclient config". Read also the "Possible issues" section below in case you encounter errors.
cd chromium/
gclient sync --jobs 8 --force
This can take a while and sometimes it can break with some errors when a download fails. In such case you should run the "gclient sync" command once again. One of the last messages in the console should be:
Updating projects from gyp files...
- You may encounter an error while checking out the gsutil repo, fix it by removing gsutil entries from the DEPS file.
Download the CEF sources, the repository url can be found in the BUILD_COMPATIBILITY.txt file.
cd chromium/src/
svn checkout {CEF repository url} cef
This will download the CEF sources to the "cef" directory inside the Chromium "src" directory.
Run the "git clone" command for the CEF Python repository. This download can take hundreds of megabytes.
git clone https://github.com/cztomczak/cefpython
This is an optional fix. By default Chromium disables caching when there is certificate error. This patch will fix the HTTPS caching only when ApplicationSettings.ignore_certificate_errors is set to True. Official cefpython binaries have this fix applied, starting with the 31.0 release. See also Issue 125.
Apply the patch in the "~/chromium/src/
" directory. Modifications are made in the HttpCache::Transaction::WriteResponseInfoToEntry
function.
Index: net/http/http_cache_transaction.cc
===================================================================
--- http_cache_transaction.cc (revision 241641)
+++ http_cache_transaction.cc (working copy)
@@ -2240,7 +2240,8 @@
// reverse-map the cert status to a net error and replay the net error.
if ((cache_->mode() != RECORD &&
response_.headers->HasHeaderValue("cache-control", "no-store")) ||
- net::IsCertStatusError(response_.ssl_info.cert_status)) {
+ (!cache_->GetSession()->params().ignore_certificate_errors &&
+ net::IsCertStatusError(response_.ssl_info.cert_status))) {
DoneWritingToEntry(false);
ReportCacheActionFinish();
if (net_log_.IsLoggingAllEvents())
-
Set the "GYP_MSVS_VERSION" environment variable depending on version of Visual Studio you are using. For Visual Studio 2010 set it to "2010", for the Express edition set it to "2010e".
-
Generate the build files based on the GYP configuration by running the "cef_create_projects.bat" script.
cd chromium/src/cef/
cef_create_projects.bat
- Open the "cef.sln" solution file, change the configuration to Release mode and build it.
cd chromium/src/cef/
cef.sln
After it's built you can close the solution.
- Run the "make_distrib.bat" script.
cd chromium/src/cef/tools/
make_distrib.bat --allow-partial
-
Go to the "chromium/src/cef/binary_distrib/cef_binary_xxxx_windows/" directory, for the next few steps we will be calling this directory the "cef_binary" directory.
-
Open the "cef_binary/cefclient2010.sln" solution, change the configuration to Release mode and build it.
-
Copy the "cef_binary/README.txt" file to the "src/windows/binaries_32bit/" directory.
-
Go to the "cef_binary/Release/" directory and copy the "libcef.lib" file to the "src/windows/setup/" directory.
-
Go to the "cef_binary/out/Release/" directory, copy the following files:
- locales/ directory
- all the .exe, .dll and .pak files
Copy them to the "src/windows/binaries_32bit/" directory.
If you already had any binaries in the "binaries_32bit/" directory from the previous build process then delete them first, but do not delete the visual c runtime dlls (msvcm90.dll, msvcp90.dll, msvcr90.dll).
It might be useful to copy also the debug symbols for the CEF library, so that you can debug the stack trace when there is an error in the CEF library. To copy the debug symbols go to the "chromium/src/cef/binary_distrib/cef_binary_3.1650.1646_windows32_release_symbols/" directory and copy the "libcef.dll.pdb" file to the "src/windows/binaries_32bit/" directory.
-
Install Visual Studio 2008 with Service Pack 1 or the Express edition which is free. Building Python is supported only on VS2008, thus the same requirement stands for Cython.
-
Install Windows SDK 7.0 to the default location.
GRMSDK_EN_DVD.iso - for Windows 32bit
GRMSDKX_EN_DVD.iso - for Windows 64bit
3. Download Cython 0.19.2 from PYPI. Later version are not supported by cefpython. Extract it and install:
python setup.py install
- (Optional) Install the pywin32 extension to run the pywin32 example.
- Before building static libraries you have to set the "PYTHON_INCLUDE_PATH" environment variable, it should point to the include/ directory in the python installation directory. If you have python installed to the "C:\Python27" directory (or "C:\Python34", "C:\Python27_x64", "C:\Python27_amd64", "C:\Python27_64", "C:\Python34_x64" etc.), then setting the "PYTHON_INCLUDE_PATH" environment variable is not required.
2. Go to the "chromium/src/cef/binary_distrib/cef_binary/" directory, open the "libcef_dll_wrapper.vcproj" project file in Visual Studio 2008 (not VS2010) and change the configuration to Release mode.
2a. Change the properties of the "libcef_dll_wrapper" project:
- Set the "C/C++ > Output files > Program Database File Name" option an empty string. This will get rid of warnings during cython compilation
Build it. Go to the cef_binary/out/Release/lib/ directory and rename "libcef_dll_wrapper.lib" to "libcef_dll_wrapper_mt.lib". Copy it to the src/windows/setup/lib_32bit/ directory.
2b. Change the properties of the "libcef_dll_wrapper" project:
- Set the "C/C++ > Code Generation > Runtime Library" to "Multi-threaded DLL (/MD)".
- In "C/C++ > Command Line" add a flag: "-D_HAS_EXCEPTIONS=1" (or set "multi_threaded_dll" in your GYP configuration, see CEF Issue 970).
Build it. After it's built, go to the "cef_binary/out/Release/lib/" directory. Rename "libcef_dll_wrapper.lib" to "libcef_dll_wrapper_md.lib" and copy it to the "src/windows/setup/lib_32bit/" directory.
Go to the "src/windows/" directory.
There is one thing to do before building. An up-to-date "cefpython.h" file needs to be generated, signatures of the Cython public functions are there. To generate this file you need to run the compile.bat script and ignore any errors you see. When asked whether to continue press "y" (yes). The compile.bat script expects first argument to be release version number:
compile.bat 31.2
After cefpython.h was generated run the compile.bat script once again.
If everything went fine then the "cefpython_py27.pyd" (or py34.pyd) module should be created in the "src/windows/binaries_32bit/" directory and the "wxpython.py" example should be launched automatically.
The compile.bat script also accepts additional flags that can be passed after the version argument:
- --rebuild - to rebuild vcproj builds
- --py27-32bit, --py27-64bit, --py34-32bit, --py34-64bit - these allow to set PATH for specific Python version. This path contains minimum set of directories to allow detecting possible issues early.
To be able to build the inno setup installer you have to install Inno Setup 5. It should be installed to the deafault location "c:\Program Files (x86)\Inno Setup 5\ISCC.exe", otherwise you will have to edit the "make-installer.py" script and change the path. To disable creation of inno setup installer package pass the "--disable-inno-setup
" flag after the version number argument.
You will also need the pip package manager, please see here on how to install it on Windows. It needs to be a recent version of pip, so that Python Wheels are supported. The build_all.bat script will install some dependencies (setuptools, wheel) if they are missing. If you have some old versions of pip/setuptools/wheel installed, then you need to upgrade them by typing these commands:
pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade wheel
To create multiple packages run the build_all.bat script. The first argument is a version number. There are also optional flags that you can pass after the version argument: --disable-inno-setup, --py27-32bit, --py27-64bit, --py34-32bit, --py34-64bit.
cd src/windows/installer/
build_all.bat win32 31.2
If everything went fine then you should see multiple distributions created in the dist/ directory.