How to build the CEF binaries

Post Reply
User avatar
salvadordf
Posts: 2986
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

How to build the CEF binaries

Post by salvadordf »

WARNING : READ ALL THE INFORMATION IN THIS POST BEFORE RUNNING THE SCRIPTS.

In order to fix a bug in CEF I needed to be able to build the binaries.

The system requirements to build CEF are very high so I had to use part of the money donated to this project to buy more RAM and a new SSD drive for my PC.

Thank you so much to all the patreons and users that decided to make a donation! :D

The building process is described in the official CEF Wiki but if you need a shorter guide to build the 32 bit CEF binaries without proprietary codecs then follow these steps :
  • The Windows SDK that comes with Visual Studio doesn't include the "Debugging tools for Windows" so you will need to download and install the Windows 10 SDK from https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/ The Windows SDK version must be the same as the version mentioned in the "BranchesAndBuilding" wiki at https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md At the time of this writing the Windows 10 SDK version needed for the 4430 branch is 10.0.19041. To avoid issues it's very important to install the Windows SDK in the default directory.
  • When you run the Windows SDK installer select the "Debugging tools for Windows" option only.
  • Create a c:\symbols folder in your hard drive to store the symbols used by WinDbg
  • Run WinDbg and open the "File->Symbol File Path" option and type this :

    Code: Select all

    SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
  • Create a Windows environment variable called _NT_SYMBOL_PATH and the this value :

    Code: Select all

    SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
  • Reboot Windows.
  • Install Visual Studio 2019 Community in the default directory and select the "Desktop development with C++" workload. Make sure the "installation details" also include the same Windows SDK version installed in the first step. You can download the installer for free here : https://visualstudio.microsoft.com/downloads/
  • Run Visual Studio and update it if necessary.
  • The Wiki mentions that you need to create some directories to store the sources and other files and the new SSD drive is identified as "E" by Windows so I created those directories in e:\code\automate and e:\code\chromium_git
  • Download automate-git.py into e:\code\automate from https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py
  • Download depot_tools.zip and decompress into e:\code\depot_tools from https://storage.googleapis.com/chrome-infra/depot_tools.zip
  • Add e:\code\depot_tools to the PATH environment variable in Windows and reboot.
  • Run e:\code\depot_tools\update_depot_tools.bat
  • Create a new BAT file called e:\code\buildcef32.bat with the following contents.

    Code: Select all

    set GN_DEFINES=is_official_build=true use_thin_lto=false
    set GYP_MSVS_VERSION=2019
    set CEF_ARCHIVE_FORMAT=tar.bz2
    python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=4430 --minimal-distrib --client-distrib --force-clean
  • Run e:\code\buildcef32.bat
Notice that buildcef32.bat uses the e:\code\chromium_git path and it also selects the 4430 branch. If you need to build different branches you will need to edit this value in the buildcef32.bat file.

This will build the 32 bits CEF binaries. If you need to build the 64 bit version you would have to create and run a new file called e:\code\buildcef64.bat with the following contents :

Code: Select all

set GN_DEFINES=is_official_build=true use_thin_lto=false
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=4430 --minimal-distrib --client-distrib --force-clean --x64-build
As you can see, buildcef32.bat and buildcef64.bat run automate-git.py which downloads the new CEF and Chromium sources and build them in one really long process.

When buildcef32.bat or buildcef64.bat finish building and creating the packages you will find the tar.bz2 packages in this directory :
e:\code\chromium_git\chromium\src\cef\binary_distrib

The buildcef32.bat or buildcef64.bat scripts mentioned above will create the CEF binaries with the open source codecs only.

If you need to build the binaries with proprietary codecs you need to use the following scripts :
buildcef32.bat

Code: Select all

set GN_DEFINES=is_official_build=true use_thin_lto=false proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=4430 --minimal-distrib --client-distrib --force-clean
buildcef64.bat

Code: Select all

set GN_DEFINES=is_official_build=true use_thin_lto=false proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=4430 --minimal-distrib --client-distrib --force-clean --x64-build
READ THIS BEFORE YOU RUN THE BUILD SCRIPTS :
You need a really fast and powerful computer to build the binaries in a reasonable amount of time.
The Wiki pages state that you need at least 8GB of RAM and 40GB of free disk space but I would recommend higher values.

I would also recommend to use a fast SSD 240GB drive only used to build CEF. The sources need 40GB but the compiler creates a lot of files and the final space needed only for the 32 bit binaries, sources, obj files and packages is 110GB !

The CPU speed and the amount of cores is very important to build CEF. I have an old Ryzen 5 CPU and it takes about 8 hours :o to build the 32 bits binaries using all the cores at 100% during that time. Needles to say that you have to be extremely careful with the system cooling.

To avoid making all this process even longer it's also recommended that you :
  • Disable windows defender real-time protection.
  • Turning off Indexing in the hard drives.
  • Add the project folders and all the EXEs used to build the binaries to the "Exclusions" list of Windows Defender. I used the list from this repository and a few more https://gist.github.com/Ryan-Efendy/b7150b18d46d8a8bd18a178f982ef6ca
    • C:\Windows\Microsoft.NET
    • C:\Windows\assembly
    • C:\Users\<UserName>\AppData\Local\Microsoft\VisualStudio
    • C:\ProgramData\Microsoft\VisualStudio
    • C:\Program Files (x86)\MSBuild
    • C:\Program Files (x86)\Microsoft Visual Studio
    • C:\Program Files (x86)\Microsoft SDKs
    • E:\code
    • devenv.exe
    • dotnet.exe
    • msbuild.exe
    • node.exe
    • node.js
    • perfwatson2.exe
    • ServiceHub.Host.Node.x86.exe
    • vbcscompiler.exe
    • testhost.exe
    • datacollector.exe
    • IntelliTrace.exe
    • git.exe
    • git-remote-https.exe
    • clang-cl.exe
    • nasm.exe
    • ninja.exe
    • python.exe
    • python3.exe
    • vpython3.exe
    • lld-link.exe
All the previous BAT scripts use the latest CEF and Chromium sources of the selected branch but if you need to build an older CEF commit you can use the "--checkout=<commit_hash>" parameter in the last line.

The "commit hash" can be obtained from the CEF binaries line. For example, if you use the CEF binaries available in this link :
https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_windows32.tar.bz2

The "commit hash" value would be cd9342c. Notice that the commit value is located between the CEF version and the word "chromium". You also have to remove the plus signs encoded as %2B and the letter "g".
https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_windows32.tar.bz2

In this case, you would have this script to build the binaries with proprietary codecs from that old CEF commit :
buildcef32.bat

Code: Select all

set GN_DEFINES=is_official_build=true use_thin_lto=false proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --checkout=cd9342c --branch=4430 --minimal-distrib --client-distrib --force-clean
buildcef64.bat

Code: Select all

set GN_DEFINES=is_official_build=true use_thin_lto=false proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --checkout=cd9342c --branch=4430 --minimal-distrib --client-distrib --force-clean --x64-build
The "use_thin_lto=false" parameter was added to the building scripts in March 18th, 2021. If you try to build older CEF versions you might need to delete it.
User avatar
salvadordf
Posts: 2986
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to build the CEF binaries

Post by salvadordf »

Chromium and CEF are migrating all Python scripts used to build the binaries from Python 2 to Python 3 :
https://bitbucket.org/chromiumembedded/ ... -migration

I'll see if we need to make some adjustments to these instructions due to that change.
User avatar
salvadordf
Posts: 2986
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to build the CEF binaries

Post by salvadordf »

I updated this tutorial with the latest build information and more speed up tips.
I also removed some outdated information about the scripts.
User avatar
salvadordf
Posts: 2986
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to build the CEF binaries

Post by salvadordf »

I updated again this tutorial with the latest CEF branch info.
User avatar
salvadordf
Posts: 2986
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to build the CEF binaries

Post by salvadordf »

I just edited this guide with the new parameter for Windows builds in the BAT file, the instructions to build the CEF binaries with older sources and used "python3" instead of "python" to execute the automate-git.py script.
Post Reply