Linux Chromium source compilation

Keywords: Android Linux network VPN

LInux Chromium source compilation

Under LInux, Chromium is compiled in gn+ninja mode. The older version of gyp has been discarded, and by default (the is Pang flag bit is true), the clang compiler is used.
GN generates the build.ninja file through the GN file in the Chromium source code under the compiled directory (such as out/Default). With this file, ninja compiles Chromium. Don't pay attention to gn and Ninja here. If you are interested in children's shoes, please refer to the following website;
- GN reference website
- Ninja reference website

Get Chromium source code

Setting up the compilation environment

  • Set depot? Tools
 git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
 # you depot_tools path
 export PATH=$PATH:/xxx/xxx/xxx//depot_tools
 # Unzip command tar - zxvf xxxx.tar.gz
  • Set up the build
cd ~/chromium/src
# Run this command, some people's terminals may exit (exit command)
# When you encounter this problem, please comment the exit command in install-build-deps.sh
# If you are prompted that you cannot install the font library, follow the prompts to add the parameter of not installing the font library
. build/install-build-deps.sh
# Compile Android version of Chromium
. build/install-build-deps-android.sh 
# This step is very important. Please confirm that the network can get all the content (try VPN \ agent \ various methods)
# Ensure that this step is installed successfully, do not modify the relevant script or program, jump out of the installation step, and wait patiently
gclient runhooks

Compile

  • If the compilation environment is set up correctly, this step will not encounter any problems
  • gen generates. ninja files
# Linux
gn gen out/Default
gn gen out/Default --args='is_debug=false'  (Releas Edition)
gn gen out/Default --args='target_cpu="x64" use_sysroot=false is_clang=false' (No use clang Compile)
# Android
gn gen out/Default --args='target_os="android" target_cpu="x86"'
gn gen out/Default --args='target_os="android" target_cpu="x64"'
gn gen out/Default --args='target_os="android" target_cpu="arm64"'
gn gen out/Default --args='target_os="android" target_cpu="arm"' 
  • ninja compilation
#Linux
ninja -C out/Default    (Chromium Browser)
ninja -C out/Default content/shell:content_shell   (Chromium content_shell)

#Android
ninja -C out/Default chrome_public_apk  (Chromium Browser)
ninja -C out/Default content_shell_apk  (Chromium content_shell)
ninja -C out/Default system_webview_apk  (Android Webview)
ninja -C out/Default webview_instrumentation_test_apk  (Android Webview test apk)
  • Install APK
cd src/out/Default/apks
adb install chrome_public_apk
  • Extra: Chromium compilation has certain requirements for configuration, especially in the link phase, machines with low configuration (such as memory 4G and below) are easy to get stuck.

Posted by mac25 on Sat, 04 Apr 2020 03:29:53 -0700