How to build the CEF binaries

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

How to build the CEF binaries

Post by salvadordf » Mon Jan 13, 2020 5:43 pm

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 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 4240 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
    set GYP_MSVS_VERSION=2019
    set CEF_ARCHIVE_FORMAT=tar.bz2
    python automate\automate-git.py --download-dir=e:\code\chromium_git --branch=4240 --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 4240 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=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
python automate\automate-git.py --download-dir=e:\code\chromium_git --branch=4240 --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 read this forum thread in the official CEF forum :
https://magpcss.org/ceforum/viewtopic.php?f=6&t=13515

I still haven't tried it and I just did a quick read but it seems that you only need to add a couple of parameters to the GN_DEFINES line in the buildcef**.bat scripts.

The scripts to build the binaries with proprietary codecs would be :
buildcef32.bat

Code: Select all

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

Code: Select all

set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
python automate\automate-git.py --download-dir=e:\code\chromium_git --branch=4240 --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
    • vpython3.exe
    • lld-link.exe

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

Re: How to build the CEF binaries

Post by salvadordf » Tue Jan 14, 2020 9:56 am

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

I'll see if we need to make some adjustments to these instructions due to that change.

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

Re: How to build the CEF binaries

Post by salvadordf » Tue Nov 03, 2020 6:26 pm

I updated this tutorial with the latest build information and more speed up tips.
I also removed some outdated information about the scripts.

Post Reply