Reference: Local compilation of Chrome browser stepping notes on Mac (2021.02 latest) - Nuggets
For Mac:
1. Download the compilation toolchain: deptool
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PATH:/Users/yumlu/code/depot_tools"
(However, for the convenience of subsequent operations, you can add it to your ~/.zshrc)
After completion, test whether the fetch command is available on the command line:
which fetch
2. Download the Chromium project code
git config --global http.postBuffer 524288000
git config --global core.precomposeUnicode true
Download the source code: Create a new folder and execute after entering:
fetch --no-history chromium
You can also download the source code in this way:
git clone --depth 1 -b 114.0.5735.134 https://chromium.googlesource.com/chromium/src.git src
gclient sync
(gclient runhooks)
cd /Users/yumlu/code/src/build/util/ && ./lastchange.py LASTCHANGE
gclient runhooks
Add the following two lines to the http_download.py file: (Otherwise, the file download of the https link will fail)
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
If an ssl error is found
It is often encountered that requesting an https or wss address will fail to verify the ssl certificate.
The error is similar to:
ssl.SSLCertVerificationError:[SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed: unable to get local issuer certificate(_ssl.c:1056)
The network connection with wss://xxxxxx is disconnected, please check whether the client and the network are normal
There is no problem on windows and linux servers, and only Mac will encounter it.
Found a thorough solution to this type of problem on StackOverflow:
>cd /Applications #Enter the application subdirectory from the root directory
>cd Python\ 3.7/ #My Python version is 3.7, please make it according to the situation
>sudo ./Install\ Certificates.Command #After entering the directory, you can ls it to see what is there, and find the right one
Enter the password to start the automatic installation of the certificate.
After installing it, I went to test it and found that there is no problem.
If you want to get the latest code later, just execute cd src && git rebase -update && gclient sync
3. Compilation _
cd src
Use the gn tool to generate a suitable ninjaFile according to the current system environment. After that, you don’t need to set any parameters when compiling with autoninja, and compile directly based on the ninjaFile configuration file:
gn gen out/Default
Now a series of parameters and configurations required to compile Chrome will be generated in the out directory
Edit the out/Default/args.gn file and add the following:
# Set build arguments here. See `gn help buildargs`.
is_debug = false
enable_nacl = false
target_cpu = "x64"
proprietary_codecs = true
ffmpeg_branding = "Chrome"
#media_use_ffmpeg = false
Then start compiling (the whole process takes about 7-10 hours):
autoninja -C out/Default chrome
After the compilation is complete, you will see that it appears in the out directory
./out/Default/Chromium.app/Contents/MacOS/Chromium Such an executable file can be executed directly from the command line, and your own locally compiled Chromium will be opened
Clean up: gn clean out/Default
Handling of some compilation failures:
Mac_sdk.gni modify the current os version
Add cflags += [ "-Wno-deprecated-declarations" ] to the BUILD.gn file
Start the compiled chromium:
/Users/yumlu/code/src/out/Default/Chromium.app/Contents/MacOS/Chromium --enable-logging=stderr --v=1 >chromium.log 2>&1
/Users/yumlu/code/src/out/Default/Chromium.app/Contents/MacOS/Chromium --force-fieldtrials="WebRTC-SpsPpsIdrIsH264Keyframe/Enabled/" --enable-logging=stderr --v=1 >chromium.log 2>&1
Where to execute this command log is where
Pull the specified version, such as version 111.0.5563.110
git fetch origin tag 111.0.5563.110
git checkout -b branch_111.0.5563.110 tags/111.0.5563.110
gclient sync --with_branch_heads --with_tags
或者gclient sync -D --with_branch_heads --with_tags
Check the xcode path: xcode-select -p
Set the xcode path: sudo xcode-select -s /Users/yumlu/Downloads/Xcode.app
1. Install Visual Studio (refer to the VS version required by the chromium version), and configure the environment variable after the installation is complete:
vs2022_install=C:\Program Files\Microsoft Visual Studio\2022\Community
WINDOWSSDKDIR=C:\Program Files (x86)\Windows Kits\10
2. Download depot_tools
3. Download the specified version of chromium source code
git clone --depth 1 -b 114.0.5735.134 https://chromium.googlesource.com/chromium/src.git src
4、gclient sync
5、gn gen out\Default
6. Edit the out/Default/args.gn file to add the following content:
# Set build arguments here. See `gn help buildargs`.
is_debug = false
is_clang = false
target_cpu = "x64"
enable_nacl = false
proprietary_codecs = true
#media_use_ffmpeg = false
ffmpeg_branding = "Chrome"
7、autoninja -C out\Default chrome
Then start the compiled exe, the log is in C:\Users\luyum\AppData\Local\Chromium\User Data\chrome_debug.log