give me step by step instructions how to make a minimalistic chromium build for mac and linux
Automated Method
CEF provides tools for automatically downloading, building and packaging Chromium and CEF source code. These tools are the recommended way of building CEF locally and can also be integrated with automated build systems as described on the AutomatedBuildSetup Wiki page. See the MasterBuildQuickStart Wiki page for an example of the recommended workflow for local development builds.
These steps apply to the Git workflow only. The Git workflow is recommended for all users and supports CEF3 master and newer CEF3 release branches (1750+).
Download the automate-git.py script. Use the most recent master version of this script even when building release branches.
On Linux: Chromium requires that certain packages be installed. You can install them by running the install-build-deps.sh script or by explicitly running the necessary installation commands.
Run the automate-git.py script at whatever interval is appropriate (for each CEF commit, once per day, once per week, etc).
To build master:
python /path/to/automate/automate-git.py --download-dir=/path/to/download
To build a release branch:
python /path/to/automate/automate-git.py --download-dir=/path/to/download --branch=2785
By default the script will download depot_tools, Chromium and CEF source code, run Debug and Release builds of CEF, and create a binary distribution package containing the build artifacts in the “/path/to/download/chromium/src/cef/binary_distrib” directory. Future runs of the script will perform the minimum work necessary (unless otherwise configured using command-line flags). For example, if there are no pending CEF or Chromium updates the script will do nothing.
If you run the script and CEF or Chromium updates are pending the “/path/to/download/chromium/src/cef” directory will be removed and replaced with a clean copy from “/path/to/download/cef_(branch)” (specify the --no-update command-line flag to disable updates). Make sure to back up any changes that you made in the “/path/to/download/chromium/src/cef” directory before re-running the script.
The same download directory can be used for building multiple CEF branches (just specify a different --branch command-line value). The existing “/path/to/download/chromium/src/out” directory will be moved to “/path/to/download/out_(previousbranch)” so that the build output from the previous branch is not lost. When you switch back to a previous branch the out directory will be restored to its original location.
The script will create a 32-bit build on Windows by default. To create a 64-bit build on Windows, macOS or Linux specify the --x64-build command-line flag. 32-bit builds on macOS are no longer supported starting with 2272 branch so this flag is now required when building 2272+ on that platform.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
If you receive Git errors when moving an existing checkout from one branch to another you can force a clean Chromium Git checkout (specify the --force-clean command-line flag) and optionally a clean download of Chromium dependencies (specify the --force-clean-deps command-line flag). Any build output that currently exists in the “src/out” directory will be deleted. Re-downloading the Chromium dependencies can take approximately 30 minutes with a reasonably fast internet connection.
Add the --help command-line switch to output a complete list of supported command-line options.
Manual Downloading
See the MasterBuildQuickStart Wiki page for an example of the recommended developer workflow.
Manual Building
See the MasterBuildQuickStart Wiki page for an example of the recommended developer workflow.
Manual Packaging
After building both Debug and Release configurations you can use the make_distrib tool (.bat on Windows, .sh on macOS and Linux) to create a binary distribution.
cd /path/to/chromium/src/cef/tools
./make_distrib.sh --ninja-build
If the process succeeds a binary distribution package will be created in the /path/to/chromium/src/cef/binary_distrib directory.
See the make_distrib.py script for additional usage options.
The resulting binary distribution can then be built using CMake and platform toolchains. See the README.txt file included with the binary distribution for more information.
Build Notes
This section summarizes build-related requirements and options.
Building on most platforms will require at least 8GB of system memory.
Ninja must be used when building newer CEF/Chromium branches.
Clang is used by default for compiling/linking Chromium/CEF on macOS in all branches, Linux starting in 2063 branch, and Windows starting in 3282 branch.
GYP is supported by 2785 branch and older. GN is supported by 2785 branch and newer, and required starting with 2840 branch. Set CEF_USE_GN=1 to build 2785 branch with GN instead of GYP.
To perform a 64-bit build on Windows (any branch) or macOS (branch 2171 or older) set GYP_DEFINES=target_arch=x64 (GYP only) or build the out/[Debug|Release]_GN_x64 target (GN only). To perform a 32-bit Linux build on a 64-bit Linux system see instructions on the AutomatedBuildSetup Wiki page.
To perform an “official” build set GYP_DEFINES=buildtype=Official (GYP only) or GN_DEFINES=is_official_build=true (GN only). This will disable debugging code and enable additional link-time optimizations in Release builds. See instructions on the AutomatedBuildSetup Wiki page for additional official build recommendations.
Windows -
If multiple versions of Visual Studio are installed on your system you can set the GYP_MSVS_VERSION environment variable to create project files for that version. For example, set the value to "2015" for VS2015 or "2017" for VS2017. Check the Chromium documentation for the correct value when using other Visual Studio versions.
If you wish to use Visual Studio for debugging and compiling in combination with a Ninja build you can set GYP_GENERATORS=ninja,msvs-ninja (GYP only) or GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* (GN only) to generate both Ninja and VS project files. Visual Studio is supported only for debugging and compiling individual source files -- it will not build whole targets successfully. You must use Ninja when building CEF/Chromium targets.
For best local developer (non-official debug) build-time performance:
When using VS2015 set GN_DEFINES=is_win_fastlink=true for improved compile and link time (branches <= 3202).
When using VS2017 or VS2019 set GN_DEFINES=use_jumbo_build=true for improved compile and link time (branches <= 4044).
Component builds are supported by 3202 branch and newer and significantly reduce link time. Add is_component_build=true to GN_DEFINES in combination with the above VS-version-specific values. Component builds cannot be used to create a CEF binary distribution. See issue #1617 for details.
macOS -
The combination of deployment target and base SDK version will determine the platforms supported by the resulting binaries. For proper functioning you must use the versions specified under build requirements for each branch.
32-bit builds are no longer supported with 2272 branch and newer. See here for the Chromium announcement.
Linux -
CEF is developed and tested on the Ubuntu version specified in the "Release Branches" section. It should be possible to build and run CEF on other compatible Linux distributions but this is untested.
The libgtkglext1-dev package is required in branch 1547 and newer to support the off-screen rendering example in cefclient. This is only a requirement for cefclient and not a requirement for other applications using CEF.
Updated 2024-08-29 Wiki
Clone wiki
cef / MasterBuildQuickStart
View
History
This Wiki page provides a quick-start guide for creating a Debug build of CEF/Chromium using the current master (development) branch.
Note to Editors: Changes made to this Wiki page without prior approval via the CEF Forum or Issue Tracker may be lost or reverted.
Overview
File Structure
Windows Setup
Mac OS X Setup
Linux Setup
Next Steps
Overview
This page provides a quick-start guide for setting up a minimal development environment and building the master branch of Chromium/CEF for development purposes. For a comprehensive discussion of the available tools and configurations visit the BranchesAndBuilding Wiki page.
This guide is NOT intended for:
Those seeking a prebuilt binary distribution for use in third-party apps. Go here instead.
Those seeking to build the binary distribution in a completely automated manner. Go here instead.
Development systems can be configured using dedicated hardware or a VMware, Parallels or VirtualBox virtual machine.
The below steps can often be used to develop the most recent release branch of CEF/Chromium in addition to the master branch. Chromium build requirements change over time so review the build requirements listed on the BranchesAndBuilding Wiki page before attempting to build a release branch. Then just add --branch=XXXX to the automate-git.py command-line where "XXXX" is the branch number you wish to build.
File Structure
The same file structure will be used on all platforms. "~" can be any path that does not include spaces or special characters. We'll be building this directory structure for each platform in the following sections.
~/code/
automate/
automate-git.py <-- CEF build script
chromium_git/
cef/ <-- CEF source checkout
chromium/
src/ <-- Chromium source checkout
update.[bat|sh] <-- Bootstrap script for automate-git.py
depot_tools/ <-- Chromium build tools
With this file structure you can develop multiple CEF/Chromium branches side-by-side. For example, repeat the below instructions using "chromium_git1" as the directory name instead of "chromium_git".
Windows Setup
What's Required
Windows Build Requirements as listed on the BranchesAndBuilding Wiki page.
Install required Visual Studio sub-components as described here.
Install the exact Windows SDK version specified in the default location to avoid build issues.
At least 16GB of RAM (32GB+ recommended) and 150GB of free disk space (for a Debug build).
Approximately 4 hours with a fast internet connection (100Mbps) and fast build machine (2.4Ghz, 16 logical cores, SSD).
Step-by-step Guide
All of the below commands should be run using the system "cmd.exe" and not a Cygwin shell.
Create the following directories.
c:\code\automate
c:\code\chromium_git
WARNING: If you change the above directory names/locations make sure to (a) use only ASCII characters and (b) choose a short file path (less than 35 characters total). Otherwise, some tooling may fail later in the build process due to invalid or overly long file paths.
Download depot_tools.zip and extract to "c:\code\depot_tools". Do not use drag-n-drop or copy-n-paste extract from Explorer, this will not extract the hidden ".git" folder which is necessary for depot_tools to auto-update itself. You can use "Extract all..." from the context menu though. 7-zip is also a good tool for this.
Run "update_depot_tools.bat" to install Python and Git.
cd c:\code\depot_tools
update_depot_tools.bat
4. Add the "c:\code\depot_tools" folder to your system PATH. For example, on Windows 10:
Run the "SystemPropertiesAdvanced" command.
Click the "Environment Variables..." button.
Double-click on "Path" under "System variables" to edit the value.
5. Download the automate-git.py script to "c:\code\automate\automate-git.py".
Create the "c:\code\chromium_git\update.bat" script with the following contents.
set GN_DEFINES=is_component_build=true
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
python3 ..\automate\automate-git.py --download-dir=c:\code\chromium_git --depot-tools-dir=c:\code\depot_tools --no-distrib --no-build
Run the "update.bat" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "c:\code\chromium_git\cef" and Chromium source code will be downloaded to "c:\code\chromium_git\chromium\src". After download completion the CEF source code will be copied to "c:\code\chromium_git\chromium\src\cef".
cd c:\code\chromium_git
update.bat
7. Create the "c:\code\chromium_git\chromium\src\cef\create.bat" script with the following contents.
set GN_DEFINES=is_component_build=true
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
call cef_create_projects.bat
Run the "create.bat" script to generate Ninja and Visual Studio project files.
cd c:\code\chromium_git\chromium\src\cef
create.bat
This will generate a "c:\code\chromium_git\chromium\src\out\Debug_GN_x86\cef.sln" file that can be loaded in Visual Studio for debugging and compiling individual files. Replace “x86” with “x64” in this path to work with the 64-bit build instead of the 32-bit build. Always use Ninja to build the complete project. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).
Create a Debug build of CEF/Chromium using Ninja. Edit the CEF source code at "c:\code\chromium_git\chromium\src\cef" and repeat this step multiple times to perform incremental builds while developing.
cd c:\code\chromium_git\chromium\src
autoninja -C out\Debug_GN_x86 cef
Replace "Debug" with "Release" to generate a Release build instead of a Debug build. Replace “x86” with “x64” to generate a 64-bit build instead of a 32-bit build.
Run the resulting cefclient sample application.
cd c:\code\chromium_git\chromium\src
out\Debug_GN_x86\cefclient.exe
See the Windows debugging guide for detailed debugging instructions.
Mac OS X Setup
What's Required
macOS Build Requirements as listed on the BranchesAndBuilding Wiki page.
Building on an Intel Mac is supported with all versions. Building on an Apple Silicon (ARM64) Mac is supported starting with M93 (4577 branch).
At least 16GB of RAM (32GB+ recommended) and 150GB of free disk space (for a Debug build).
Approximately 4 hours with a fast internet connection (100Mbps) and fast build machine (2.4Ghz, 16 logical cores, SSD).
Step-by-step Guide
In this example "" is "/Users/marshall". Note that in some cases the absolute path must be used. Environment variables described in this section can be added to your "/.bash_profile" file to persist them across sessions.
export PATH=/Users/marshall/code/depot_tools:$PATH
4. Download the automate-git.py script to "~/code/automate/automate-git.py".
Create the "~/code/chromium_git/update.sh" script with the following contents.
#!/bin/bash
python3 ../automate/automate-git.py --download-dir=/Users/marshall/code/chromium_git --depot-tools-dir=/Users/marshall/code/depot_tools --no-distrib --no-build --x64-build
⚠ Replace --x64-build with --arm64-build if using an Apple Silicon Mac instead of an Intel Mac.
Give it executable permissions.
cd /code/chromium_git
chmod 755 update.sh
Run the "update.sh" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "/code/chromium_git/cef" and Chromium source code will be downloaded to "/code/chromium_git/chromium/src". After download completion the CEF source code will be copied to "/code/chromium_git/chromium/src/cef".
cd /code/chromium_git
./update.sh
6. Run the "/code/chromium_git/chromium/src/cef/cef_create_projects.sh" script to create Ninja project files. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).
cd ~/code/chromium_git/chromium/src/cef
./cef_create_projects.sh
⚠ Add export GN_DEFINES=is_component_build=true before running cef_create_projects.sh if using an Apple Silicon Mac instead of an Intel Mac.
Create a Debug build of CEF/Chromium using Ninja. Edit the CEF source code at "~/code/chromium_git/chromium/src/cef" and repeat this step multiple times to perform incremental builds while developing.
cd ~/code/chromium_git/chromium/src
autoninja -C out/Debug_GN_x64 cef
⚠ Replace "x64" with "arm64" if using an Apple Silicon Mac instead of an Intel Mac. Replace "Debug" with "Release" to generate a Release build instead of a Debug build.
Run the resulting cefclient, cefsimple and/or ceftests sample applications.
cd ~/code/chromium_git/chromium/src
open out/Debug_GN_x64/cefclient.app
Or run directly in the console to see log output:
./out/Debug_GN_x64/cefclient.app/Contents/MacOS/cefclient
See the Mac OS X debugging guide for detailed debugging instructions.
Linux Setup
What's Required
Linux Build Requirements as listed on the BranchesAndBuilding Wiki page.
Building with other versions or distros has not been tested and may experience issues.
At least 16GB of RAM (32GB+ recommended) and 120GB of free disk space (for a Debug build).
Approximately 4 hours with a fast internet connection (100Mbps) and fast build machine (2.4Ghz, 16 logical cores, SSD).
Step-by-step Guide
In this example "" is "/home/marshall". Note that in some cases the absolute path must be used. Environment variables described in this section can be added to your "/.profile" or "~/.bashrc" file to persist them across sessions.
Create the following directories.
mkdir ~/code
mkdir ~/code/automate
mkdir /code/chromium_git
2. Download and run "/code/install-build-deps.py" to install build dependencies. Answer Y (yes) to all of the questions.
#!/bin/bash
python3 ../automate/automate-git.py --download-dir=/home/marshall/code/chromium_git --depot-tools-dir=/home/marshall/code/depot_tools --no-distrib --no-build
Give it executable permissions.
cd /code/chromium_git
chmod 755 update.sh
Run the "update.sh" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "/code/chromium_git/cef" and Chromium source code will be downloaded to "/code/chromium_git/chromium/src". After download completion the CEF source code will be copied to "/code/chromium_git/chromium/src/cef".
cd ~/code/chromium_git
./update.sh
7. Configure GN_DEFINES for your desired build environment.
Chromium provides sysroot images for consistent builds across Linux distros. The necessary files will have downloaded automatically as part of step 6 above. Usage of Chromium's sysroot is recommended if you don't want to deal with potential build breakages due to incompatibilities with the package or kernel versions that you've installed locally. To use the sysroot image configure the following GN_DEFINES:
export GN_DEFINES="use_sysroot=true use_allocator=none symbol_level=1 is_cfi=false use_thin_lto=false"
It is also possible to build using locally installed packages instead of the provided sysroot. Choosing this option may require additional debugging effort on your part to work through any build errors that result. On Ubuntu 18.04 the following GN_DEFINES have been tested to work reliably:
export GN_DEFINES="use_sysroot=false use_allocator=none symbol_level=1 is_cfi=false use_thin_lto=false use_vaapi=false"
Note that the "cefclient" target cannot be built directly when using the sysroot image. You can work around this limitation by creating a binary distribution after completing step 9 below, and then building the cefclient target using that binary distribution.
You can also create an AddressSanitizer build for enhanced debugging capabilities. Just add is_asan=true dcheck_always_on=true to the GN_DEFINES listed above and build the out/Release_GN_x64 directory in step 9 below. Run with the asan_symbolize.py script as described in the AddressSanitizer link to get symbolized output.
The various other listed GN arguments are based on recommendations from the AutomateBuildSetup Wiki page. You can search for them by name in the Chromium source code to find more details.
Run the "~/code/chromium_git/chromium/src/cef/cef_create_projects.sh" script to create Ninja project files. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).
cd /code/chromium_git/chromium/src/cef
./cef_create_projects.sh
9. Create a Debug build of CEF/Chromium using Ninja. Edit the CEF source code at "/code/chromium_git/chromium/src/cef" and repeat this step multiple times to perform incremental builds while developing. Note the additional "chrome_sandbox" target may be required by step 10. The "cefclient" target will only build successfully if you set use_sysroot=false in step 7, so remove that target if necessary.
cd ~/code/chromium_git/chromium/src
autoninja -C out/Debug_GN_x64 cefclient cefsimple ceftests chrome_sandbox
Replace "Debug" with "Release" to generate a Release build instead of a Debug build.
Set up the Linux SUID sandbox if you are using an older kernel (< 3.8). See here for more background on Linux sandboxing technology.
This environment variable should be set at all times.
cd ~/code/chromium_git/chromium/src
sudo BUILDTYPE=Debug_GN_x64 ./build/update-linux-sandbox.sh
11. Run the cefclient, cefsimple and/or ceftests sample applications. Note that the cefclient application will only have built successfully if you set use_sysroot=false in step 7.
cd ~/code/chromium_git/chromium/src
./out/Debug_GN_x64/cefclient
See the Linux debugging guide for detailed debugging instructions.
Again, I want to make a very minimalistic build of Chromium that's intended to save in file size. For example, I do not need Chrome DevTools. There are a lot of features that I don't need. So can you tell me and walk me through step by step how I can make the most minimalistic possible build of the Chromium browser? With the intention of running it on an embedded device. But the main issue here is how to do this build, how to find what to delete, how to remove Chrome DevTools, for example, which might be a large part of it. So I need advice and step by step instructions on that, please. please.
Building a Minimalistic Chromium Build on Mac and Linux
In this guide, I'll walk you through step-by-step instructions on how to create a minimalistic build of the Chromium browser for Mac and Linux. The goal is to reduce the final build size by excluding unnecessary features such as Chrome DevTools and other components that are not required for your use case, especially for running Chromium on embedded devices.
Note: Building Chromium is a complex process that requires significant computing resources and time. Ensure that your system meets the necessary requirements before proceeding.
Overview
To create a minimalistic build of Chromium, we'll:
Set up the build environment on your Mac or Linux machine.
Download the Chromium source code.
Configure the build to exclude unnecessary features using GN build arguments.
Build Chromium with the customized configuration.
Test the minimalistic Chromium build.
Prerequisites
System Requirements
Operating System:
Mac: macOS 10.15 (Catalina) or later.
Linux: A recent 64-bit Linux distribution (e.g., Ubuntu 20.04 LTS).
Hardware:
At least 16 GB of RAM (32 GB or more recommended).
At least 200 GB of free disk space.
A multi-core CPU (the more cores, the faster the build process).
Tools and Dependencies
Git: For fetching the Chromium source code.
Python 3: Required for various build scripts.
Depot Tools: A collection of scripts and tools for managing Chromium development.
Build Dependencies:
Mac: Xcode with command-line tools.
Linux: Development tools and libraries as specified by Chromium's build instructions.
enable_plugins = false: Disables plugin support (e.g., Flash).
enable_nacl = false: Disables Native Client.
Step 5: Run gclient runhooks
Now that we've configured the build arguments, we need to run hooks to set up the build environment.
bash
gclient runhooks
This will process the .gclient and .gclient_entries files, and run the necessary hooks for the build.
Step 6: Build Chromium
Build Using Ninja:
bash
autoninja -C out/minimal chrome
The autoninja command is a wrapper that calls ninja with the optimal number of parallel processes based on your CPU cores.
Note: The initial build can take several hours, depending on your system's performance.
Monitor Build Progress:
The build process will output progress details. If any errors occur, review the error messages to determine if they're due to a misconfigured build argument.
Step 7: Test the Minimalistic Build
Run the Built Chromium Binary:
bash
./out/minimal/chrome
Note: On Mac, you might need to navigate to the app bundle:
bash
open ./out/minimal/Chromium.app
Verify Functionality:
Ensure that the browser launches without crashing.
Navigate to a few web pages to test basic functionality.
Check That Unwanted Features Are Disabled:
Open the developer tools (usually via F12 or Cmd+Opt+I on Mac). It should not be available if enable_devtools was correctly disabled.
Try opening a PDF file; it should not display if enable_pdf was disabled.
Check that plugins are not supported.
Additional Considerations
Identifying and Disabling Other Unnecessary Components
List of GN Arguments:
Chromium has a vast number of build flags. You can explore available GN arguments by running:
Some third-party libraries can be excluded to reduce size:
To disable libjpeg, libpng, etc., set corresponding use_* flags to false.
Be cautious, as these libraries might be required for basic functionality.
Potential Issues and Pitfalls
Build Failures Due to Missing Dependencies:
Disabling certain features can lead to build failures if other parts of Chromium depend on them.
If a build error occurs, check the error message for clues.
You might need to re-enable certain features or adjust other GN arguments.
Testing Thoroughly:
After building, thoroughly test the browser to ensure essential functionality isn't broken.
Updating the Source Code:
If you need to update the Chromium source code (e.g., to a newer version):
bash
cd ~/chromium/src
git fetch
git checkout [branch/tag/commit]
gclient sync
Then, repeat the configuration and build steps.
Example: Removing Additional Features
Suppose you want to further reduce the size by removing more features:
Disable Safe Browsing:
gn
is_safe_browsing_enabled = false
Disable Autofill:
gn
enable_autofill = false
Disable Extensions:
gn
enable_extensions = false
Disable Sync:
gn
enable_sync = false
Disable Speech Synthesis:
gn
enable_speech = false
Disable WebRTC:
gn
rtc_use_h264 = false
enable_webrtc = false
Caution: Disabling some of these features might result in a browser that cannot render certain web pages correctly or lacks critical functionality. Always test after making changes.
Conclusion
Building a minimalistic Chromium browser involves:
Setting up a proper build environment.
Carefully configuring build options to exclude unnecessary features.
Compiling the browser while ensuring that essential functionalities remain intact.
By following the steps outlined above and adjusting the build configuration to suit your needs, you can create a tailored version of Chromium suitable for embedded devices or other specialized use cases.
Note: Be cautious when disabling features. Some dependencies might not be apparent, and disabling certain features might cause build failures or runtime errors.
Save and Exit the Editor:
For nano: Press Ctrl+O to save, then Ctrl+X to exit.