chrouim编译(1)-代码拉取

笔者编译浏览器环境是在Mac电脑上,安装好了git和xcode

克隆仓库

下载dep_tools 并且导出到环境变量

1
2
git clone https://chromium.googlesource.com/chromium/tools/depot_tools /opt/depot_tools
export $PATH=$PATH:/opt/depot_tools

拉取代码配置信息

1
2
gclient config https://chromium.googlesource.com/chromium/src.git
gclient config --cache-dir git_cache https://chromium.googlesource.com/chromium/src.git

cat .gclient查看信息 配置已经写入到文件中

1
2
3
4
5
6
7
8
9
10
11
12
❯ cat .gclient
solutions = [
{ "name" : 'src',
"url" : 'https://chromium.googlesource.com/chromium/src.git',
"deps_file" : 'DEPS',
"managed" : True,
"custom_deps" : {
},
"custom_vars": {},
},
]
cache_dir = 'git_cache'

拉取代码

  1. fetch --no-hooks chromium

  2. gclient sync 拉取最新的代码

  3. gclient sync --revision src@120.0.6099.312 --with_tags --with_branch_heads -D 拉取指定的代码

编译浏览器

1
2
3
4
5
6
7
gn gen out/Default --args='is_debug=false'  #(Releas版)
gn gen out/Default --args='target_cpu="x64" # 指定CPU
gn gen out/Default --args='target_os="android" target_cpu="x86"' # 给android 平台编译并且指定cpu 指令集,下同
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"
gn gen out/Default --args='target_os="linux" target_cpu="x64" # 给linux 平台编译并且指定cpu 架构

chrome 是可以做到交叉编译的,但是还是推荐在同类型的机器上做编译。

开始编译

1
autoninja -C out/Default chrome chromedriver

编译的速度和电脑配置相关。修改代码之后代理是增量编译,因此建议拉取代码之后编译一下,后续修改速度就比较快。


chrouim编译(1)-代码拉取
https://kingjem.github.io/2025/06/23/chrouim编译-1-代码拉取/
作者
Ruhai
发布于
2025年6月23日
许可协议