0.系统配置要求
最重要是能连接到国际网
- A 64-bit Intel machine running Linux with at least 8GB of RAM. More than 16GB is highly recommended.
- At least 100GB of free disk space.
- You must have Git and Python installed already.
Most development is done on Ubuntu. Other distros may or may not work; see theLinux instructions for some suggestions.
Building the Android client on Windows or Mac is not supported and doesn't work.
1. 下载depot_tools
(红色为shell命令)
Clone the depot_tools
repository:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
Add depot_tools
to the end of your PATH (you will probably want to put this in your~/.bashrc
or~/.zshrc
). Assuming you cloneddepot_tools
to/path/to/depot_tools
:
export PATH="$PATH:/path/to/depot_tools"
2. 获取代码
Create a chromium
directory for the checkout and change to it (you can call this whatever you like and put it wherever you like, as long as the full path has no spaces):
mkdir ~/chromium && cd ~/chromium
fetch --nohooks android
If you don't want the full repo history, you can save a lot of time by adding the--no-history
flag tofetch
.
Expect the command to take 30 minutes on even a fast connection, and many hours on slower ones.
If you've already installed the build dependencies on the machine (from another checkout, for example), you can omit the--nohooks
flag andfetch
will automatically executegclient runhooks
at the end.
- 如果遇到 gnutls_handshake失败
-
error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing ... fatal: HTTP request failed
可以参考
Got reason of the problem, it was gnutls
package. It's working weird behind a proxy. Butopenssl
is working fine even in weak network. So workaround is that we should compilegit
with openssl
. To do this, run the following commands:
sudo apt-get install build-essential fakeroot dpkg-dev
mkdir ~/git-openssl
cd ~/git-openssl
sudo apt-get source git
sudo apt-get build-dep git
sudo apt-get install libcurl4-openssl-dev
sudo dpkg-source -x git_1.7.9.5-1.dsc //具体版本看下载的
cd git_1.7.9.5 8.
Then, edit debian/control
file (run the command: gksu gedit debian/control
) and replace all instances oflibcurl4-gnutls-dev
with libcurl4-openssl-dev
sudo dpkg-buildpackage -rfakeroot -b
(if it's failing on test, you can remove the line TEST=test
from the filedebian/rules
)
sudo dpkg -i ../git_1.7.9.5-1_i386.deb
When fetch
completes, it will have created a hidden .gclient
file and a directory called src
in the working directory. The remaining instructions assume you have switched to thesrc
directory:
cd src
Converting an existing Linux checkout
If you have an existing Linux checkout, you can add Android support by appendingtarget_os = ['android']
to your.gclient
file (in the directory abovesrc
):
echo "target_os = [ 'android' ]" >> ../.gclient
Then run gclient sync
to pull the new Android dependencies:
gclient sync
(This is the only difference between fetch android
andfetch chromium
.)
安装依赖相关
Once you have checked out the code, run
build/install-build-deps-android.sh
to get all of the dependencies you need to build on Linux, plus all of the Android-specific dependencies (you need some of the regular Linux dependencies because an Android build includes a bunch of the Linux tools and utilities).
运行hooks
Once you've run install-build-deps
at least once, you can now run the Chromium-specific hooks, which will download additional binaries and other things you might need:
注意这里会提示要下载一份LICENSE文件,需要用户选择接受还是拒绝。当选择接受后,会继续启动下载,如果没有选择,那么再运行一遍:gclient runhooks
gclient runhooks
Optional: You can also install API keys if you want your build to talk to some Google services, but this is not necessary for most development and testing purposes.
2.1. 切换分支(如果不需要请略过)
To check from which revision a certain build is released, 输入: 版本如(60.0.3112.107)
chromium source refs : 各个tag的chromium链接
chromium old versions:截止到2017-08-18最新版本为 60.0.3112.107
git fetch —tags
切到自定义分支并同步远程分支:
git checkout 60.0.3112.107
git checkout -b your_release_branch 60.0.3112.107
同步分支代码:
gclient sync --with_branch_heads --jobs 16
gclient runhooks
3.编译代码
设置编译参数
Chromium uses Ninja as its main build tool along with a tool called GN to generate .ninja
files. You can create any number ofbuild directories with different configurations. To create a build directory which builds Chrome for Android, run:
gn gen --args='target_os="android"' out/Default
或者使用
gn args out/Default
文件中配置:
target_os = "android"
#32位,不配置为64位,主动配置64为"arm64"
target_cpu = "arm"
is_official_build = true
is_debug = false
symbol_level = 1
enable_nacl = false
exclude_unwind_tables = true
proprietary_codecs = true
ffmpeg_branding = "Chrome"
remove_webcore_debug_symbols = true
is_component_build = false
is_clang = false
enable_incremental_javac = false
enable_webrtc = true
- You only have to run this once for each new build directory, Ninja will update the build files as needed.
- You can replace
Default
with another name, but it should be a subdirectory ofout
. - For other build arguments, including release settings, see GN build configuration. The default will be a debug component build matching the current host operating system and CPU.
- For more info on GN, run
gn help
on the command line or read thequick start guide.
Also be aware that some scripts (e.g. tombstones.py
,adb_gdb.py
) require you to setCHROMIUM_OUTPUT_DIR=out/Default
.
编译
Build Chromium with Ninja using the command:
60以上的chromium保证java是1.8版本
ninja -C out/Default chrome_public_apk
You can get a list of all of the other build targets from GN by running gn ls out/Default
from the command line. To compile one, pass the GN label to Ninja with no preceding “//” (so, for//chrome/test:unit_tests
useninja -C out/Default chrome/test:unit_tests
).