Build chromium browser from source code

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="/path/to/depot_tools:$PATH"
# for FISH set -U fish_user_paths /home/kar/p/build/depot_tools $fish_user_paths && source ~/.config/fish/config.fish
#git python3 curl is needed
mkdir chromium && cd chromium
fetch chromium # this will get the chromium & it takes time
cd src
./build/install-build-deps.sh
./build/install-build-deps-arch.py # for arch linux i have created
# Basic installation
./build/install-build-deps-arch.py # With 32-bit libraries and ARM cross-compilation
./build/install-build-deps-arch.py --lib32 --arm # Non-interactive installation
./build/install-build-deps-arch.py --no-prompt # Using paru instead of yay for AUR packages
./build/install-build-deps-arch.py --aur-helper paru
# Quick check without installing
./install-build-deps-arch.py --quick-check
on windows python build\install-build-deps.py
gn gen out/Default #generate build files
autoninja -C out/Default chrome #starts the build
customize Build Configuration Options.
gn gen out/Custom --args='
is_debug=false
symbol_level=1
enable_nacl=false
remove_webcore_debug_symbols=true
proprietary_codecs=true
ffmpeg_branding="Chrome"
'
the build setup script for arch linux: https://git.siliconpin.com/topic/chromium-build/src/branch/main/install-build-deps-arch.py
Building the Chromium browser from source involves several steps, including setting up your environment, obtaining the source code, and compiling the project. This process can be resource-intensive, requiring a powerful machine with ample RAM and disk space.
1. System Requirements:
An x86-64 machine with at least 8GB of RAM (16GB+ recommended).
At least 100GB of free disk space.
Git and Python v3.9+ installed.
2. Install Depot Tools:
Download depot_tools
from the Chromium website. ( git clone https://chromium.googlesource.com/chromium/tools/depot_tools )
Extract the archive to a designated location (e.g., C:\chromium\depot_tools
on Windows or ~/depot_tools
on Linux/macOS).
Add the depot_tools
directory to your system's PATH environment variable, ensuring it takes precedence over any existing Python installations.
On Windows, set the environment variable DEPOT_TOOLS_WIN_TOOLCHAIN
to 0
.
3. Get the Chromium Source Code:
Create a directory for your Chromium checkout (e.g., C:\chromium\src
or ~/chromium/src
).
Navigate to this directory in your terminal or command prompt.
Run the following command to fetch the source code:
Code
gclient config --name src https://chromium.googlesource.com/chromium/src.git
gclient sync
This command can take a significant amount of time, depending on your internet connection.
4. Install Build Dependencies (Linux/macOS):
Navigate to the src
directory of your Chromium checkout.
Run the appropriate script to install build dependencies for your operating system:
Code
build/install-build-deps.sh # For Linux
# Follow instructions in docs/mac_build_instructions.md for macOS
5. Generate Build Files:
Navigate to the src
directory.
Generate the build files using gn gen
. You can create a build directory with a custom name and arguments:
Code
gn gen out/Default
Replace Default
with a name of your choice. You can add build arguments for release settings, specific features, etc., by running gn args out/Default
and editing the configuration.
6. Compile Chromium:
Navigate to the src directory and Compile Chromium using autoninja.
Code
autoninja -C out/Default chrome
Replace Default
with your chosen build directory name. This step will take a considerable amount of time and resources.
7. Run Your Custom Browser:
Once the compilation is complete, the Chromium executable will be located within your build directory (e.g., out/Default/chrome.exe
on Windows or out/Default/Chromium.app
on macOS).
You can then run this executable to launch your custom-built Chromium browser.
autoninja -C out/Default chrome offline mode ninja: Entering directory `out/Default' 1.45s load siso config pre:0 local:4474 remote:0 13.8/s
explain pre:0 local:4474 remote:0 13.8/s
Ans:
This output is from Siso (Simple Isolated Builds), which is Google's distributed build system used in Chromium. Let me break down what each part means:
Build Status Breakdown:
pre:0
Preprocessor jobs: Number of preprocessing tasks (like header dependency analysis)
0
means no preprocessing jobs are currently running
local:4474
Local compilation jobs: Number of compilation tasks being executed on your local machine
4474
means 4,474 compilation units have been processed locally so far
remote:0
Remote compilation jobs: Number of tasks sent to remote build servers (like Goma or RBE - Remote Build Execution)
0
means no remote compilation is happening
13.8/s
Throughput rate: Number of compilation units being processed per second
Your build is processing about 13.8 files per second
What This Tells You:
You're building entirely locally - no distributed compilation is being used
Good progress - 4,474 files have been compiled already
Reasonable speed - 13.8 files/second is decent for local compilation
Offline mode - As indicated at the top, you're not using any remote build acceleration
Context:
Chromium has thousands of source files, so seeing 4,474+ compilation units is normal. A full Chrome build can involve compiling 10,000+ files, so you're making good progress through the build process.
The build system is efficiently parallelizing the work across your CPU cores, which is why you're seeing a steady throughput rate.
after successful build, out/Default is ~40gb and chrome file is 1.5gb
Linux: ./out/Default/chrome
MacOS: ./out/Default/Chromium.app/Contents/MacOS/Chromium
Windows: ./out/Default/chrome.exe
./out/Default/chrome --user-data-dir=/tmp/chrome-test --disable-web-security
autoninja -C out/Default content_shell # Minimal browser for testing
autoninja -C out/Default chrome_sandbox # Security sandbox
#Clean rebuild
gn clean out/Default
autoninja -C out/Default chrome
#Debug Build
gn gen out/Debug --args='is_debug=true'
autoninja -C out/Debug chrome
#Release Build
gn gen out/Release --args='is_debug=false is_official_build=true'
autoninja -C out/Release chrome