Page 1 of 4

How to build the CEF binaries

Posted: Mon Jan 13, 2020 5:43 pm
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/sdk-archive/ 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 6261 branch is 10.0.22621. To avoid issues it's very important to install the Windows SDK in the default directory. Also check if your computer has all the requirements to build Chromium. Read the official information here : https://chromium.googlesource.com/chromium/src/+/HEAD/docs/windows_build_instructions.md
  • When you run the Windows SDK installer select all the installation options.
  • 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 2022 Community in the default directory and select the "Desktop development with C++" workload. The Visual Studio version must be the same version mentioned in the "BranchesAndBuilding" wiki at https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md 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. Make sure this path entry is added before other paths with different versions of Python. If you get a message about installing Python from the Microsoft Store then add "e:\" and the depot_tools path in the first position.
  • 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
    set GYP_MSVS_VERSION=2022
    set CEF_ARCHIVE_FORMAT=tar.bz2
    python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=6261 --minimal-distrib --client-distrib --force-clean --with-pgo-profiles
  • Run e:\code\buildcef32.bat
Notice that buildcef32.bat uses the e:\code\chromium_git path and it also selects the 6261 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
set GYP_MSVS_VERSION=2022
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=6261 --minimal-distrib --client-distrib --force-clean --x64-build --with-pgo-profiles
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 proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_MSVS_VERSION=2022
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=6261 --minimal-distrib --client-distrib --force-clean --with-pgo-profiles
buildcef64.bat

Code: Select all

set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_MSVS_VERSION=2022
set CEF_ARCHIVE_FORMAT=tar.bz2
python3 automate\automate-git.py --download-dir=e:\code\chromium_git --branch=6261 --minimal-distrib --client-distrib --force-clean --x64-build --with-pgo-profiles
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 much higher values. According some developers inthe official CEF forum the latest versions require at least 24 GB of RAM to build the binaries.

I would also recommend to use a fast SSD 512GB drive only used to build CEF. Some users report that a 240GB drive is not big enough to build all the latest binaries. :shock:

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 with the right branch value in the "--branch=" parameter.

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". The branch value is the third number after the word "chromium".
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=2022
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=2022
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.

Read the following document for more details about building Chromium :
https://chromium.googlesource.com/chromium/src/+/HEAD/docs/windows_build_instructions.md

Re: How to build the CEF binaries

Posted: Tue Jan 14, 2020 9:56 am
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.

Re: How to build the CEF binaries

Posted: Tue Nov 03, 2020 6:26 pm
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.

Re: How to build the CEF binaries

Posted: Mon Feb 15, 2021 11:01 am
by salvadordf
I updated again this tutorial with the latest CEF branch info.

Re: How to build the CEF binaries

Posted: Sat May 01, 2021 9:38 am
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.

Re: How to build the CEF binaries

Posted: Thu Aug 19, 2021 6:47 am
by salvadordf
I edited this guide with the latest branch value and some more details to build old CEF binaries.

Re: How to build the CEF binaries

Posted: Thu May 26, 2022 1:35 pm
by salvadordf
I just updated the guide for the 5005 branch (CEF 102).

Now you need to use the Windows SDK 10.0.20348

Re: How to build the CEF binaries

Posted: Thu Jun 16, 2022 7:25 am
by salvadordf
Updated the guide with the information provided by thefunkyjoint.

Re: How to build the CEF binaries

Posted: Tue Nov 08, 2022 3:32 pm
by salvadordf
Updated the guide with the script changes for the 5304 branch (CEF 107).

Update your BAT files!

Re: How to build the CEF binaries

Posted: Sat Apr 08, 2023 7:08 pm
by salvadordf
Updated the guide with the new build requirements for CEF 112.

Now you need to use Windows 10 or 11, Visual Studio 2022 v17.5+ and Win 10.0.22621 SDK

The scripts have a few modifications too.