Page 1 of 1

How to build the CEF binaries

Posted: Mon Jan 13, 2020 5:43 pm
by salvadordf
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 :
  • Install Visual Studio 2019 Community in the default location and select the "Desktop development with C++" workload. Make sure the "installation details" also include the Windows SDK version mentioned in the "Master Build Quick Start" wiki. At the moment of this writing it's 10.0.18362. 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=3945 --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 3945 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=3945 --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.

automate-git.py assumes you have Visual Studio 2017 installed and it works fine with Visual Studio 2019 except for one thing. One of the final steps searches for the directory where Visual Studio is installed and it can't find Visual Studio 2019. This will create the CEF DLLs but will fail when it tries to create the tar.bz2 packages.

To fix this issue just let automate-git.py download all the sources and then edit this file when you see that it's building the obj files :
e:\code\chromium_git\cef\tools\msvs_env.bat

Edit msvs_env.bat and replace the line 33 :

Code: Select all

set vcvars="%%~x\Microsoft Visual Studio\2017\%%y\VC\Auxiliary\Build\vcvars%bits%.bat"
with this :

Code: Select all

set vcvars="%%~x\Microsoft Visual Studio\2019\%%y\VC\Auxiliary\Build\vcvars%bits%.bat"
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=3945 --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=3945 --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.

Building the OBJ files will not need much memory but during linking you will notice in the Windows Task Manager shows that the memory usage increases over time.

Linking only takes a few minutes but in the final seconds I could see a 96-97% memory usage in my computer. I have 24GB of RAM now so I would recommend that you install at least that amount of memory if you don't want to increase the time it takes to link the binaries.

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.

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/cef/issues/2856/python-3-migration

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