Skip to content

Building Cef from source

Alex Maitland edited this page Nov 28, 2019 · 18 revisions

This Article has not been updated in 4+ years, the information contained within is no longer useful and is only here for references purposes

CEF provides detailed instructions for downloading an building from source. This article attempts to provide an abridged version relevant to building CEF on Windows which can later be repackaged for use with CefSharp. I suggest reading this tutorial in it's entirety before going too far (I'd kick off the depot_tools download and then keep reading).

Requirements:

  • Depot Tools
  • Visual Studio 2013 Community or Professional Update 4
  • Windows 8.1 SDK
  • Lots of Drive Space and Memory!
  • and last but not least a lot of time on your hands

Build

The downloading/building of CEF is very much an automated process. (Generating the VS2013 project files is done manually)

  1. Create a directory on a drive of your computer (for this tutorial we'll use c:\cefsource)

  2. Install Depot Tools (Download zip, extract to folder, add to path, run gclient). For the purpose of this tutorial we'll assume you extracted the zip into c:\cefsource\depot_tools.

  3. Download the automate.git.py Python script to c:\cefsource

  4. Open a dos command prompt ( run as administrator )

  5. Change directory to c:\cefsource

  6. Set the GYP environment variables.

    cd c:\cefsource
    # SET some GYP environment variables by typing
    set GYP_GENERATORS=ninja,msvs-ninja
    set GYP_MSVS_VERSION=2013
    

    You are now ready to run the CEF automated git workflow

  7. At your command prompt, execute the following (Note If you installed Depot Tools then it automatically installs Python):

    python automate-git.py --download-dir=c:\cefsource\source --depot-tools-dir=c:\cefsource\depot_tools
    

    this will run the automate-git.py script and start downloading the sources needed to build CEF into c:\cefsource\source folder. The version of CEF that will be downloaded is the Dev Channel (master). Be warned the build will take many hours to complete and download 3-4gb.

  8. Test your new CEF build using the cefclient test application (c:\cefsource\source\chromium\src\out\Release\cefclient.exe)

  9. Copy the binary_distrib folder to a safe place (C:\cefsource\source\chromium\src\cef\binary_distrib). It will be needed to repackage using the cef-binary project.

  10. Rinse and repeat building the x64 variation by appending the --x64-build --force-build command line arguments.

  11. Copy the x64 binary_distrib folder.

  12. Use the cef-binary build instructions with your newly created x86 and x64 packages to repackage CEF for use with CefSharp.

Building a specific CEF Branch

If you need to build a different branch of CEF, use:

python automate-git.py --download-dir=c:\cefsource\source --depot-tools-dir=c:\cefsource\depot_tools --branch=branch_number_here

#####Example of building the 2272 branch

python automate-git.py --download-dir=c:\cefsource\source --depot-tools-dir=c:\cefsource\depot_tools --branch=2272

To generate Visual Studio 2013 project files

# at your dos command prompt type
cd C:\cefsource\source\chromium\src\cef
cef_create_projects.bat

when that batch file has finished running, you will find the VS2013 Solution cef.sln under C:\cefsource\source\chromium\src\cef and all of the CEF Visual Studio Project files.

NOTE If you run this step sometime later you'll need to make sure the GYP environment variables from above are set otherwise it won't generate the VS2013 files.

Notes

  • automate-git.py will automatically download depot_tools by default. If you already have Python 2.7 installed on your machine you can skip download depot_tools and just execute the script.
  • You can patch CEF if you would like, by dropping patches in the C:\cefsource\source\chromium\src\cef\patch\patches and editing C:\cefsource\source\chromium\src\cef\patch\patch.cfg (Specific details of patching are outside the scope of this tutorial).
  • The automated build script will also download the corresponding version of Chromium which is needed to build CEF from source, including temporary files your look at > 40gb in free space required for the latest CEF master build at time of writing.

TODO

  • Investigate other build options like --no-debug-build and --minimal-distrib
  • Add --no-update to look at speeding up build process.
  • Create powershell script to download relevant pieces, setup depot_tools, set environment variables and execute auto build script
  • Review https://groups.google.com/forum/#!searchin/cefsharp/GYP_DEFINES|sort:relevance/cefsharp/BJLMXl9c204/HMJlp8mZzF0J and add note about building with mp3 support (also need to include a statement about how the user needs to deal with the licensing implications).
  • Add section about building cefclient and verbose builds with logging (--build-tests --client-distrib --verbose-build --build-log-file)
  • Add manual compile example e.g. D:\projects\cef\2272\chromium\src> ninja -v -Cout\Debug_x64 cefclient cef_unittests