准备工作:
- Mac (requied 10.11+)
- Xcode IDE(required 7.3+)
- Git(required 2.2.1+)
- 科学上网
参考链接:
步骤概括:
- 安装 depot_tools 项目构建工具
- 使用 depot_tools 下载源码
- 编译 Chromium 源码
- 编译稳定版(Stable)分支
- 克隆 depot_tools git仓库
1
| $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
- 添加环境变量
1
| $ export PATH="$PATH:/path/to/depot_tools"
|
Tip: /path/to/depot_tools, 为你 depot_tools 本地的路径
- 创建一个用于存在 chromium 的目录 (您可以任意命令,并存放在任何您喜欢的位置,只要是路径路径并且没有空格即可)
1
| $ mkdir chromium && cd chromium
|
- 使用 depot_tools 的 fetch 命令,来检查代码及其依赖关系。
1
| $ fetch --no-history chromium
|
Tip: –no-history: 代表不需要历史记录, 完整仓库大约40G
源码大小大概 8G 左右,下载时间因网速而议,请耐心等待
三、编译 Chromium 源码
- 进入源码目录
- 生成编译配置文件
out/Release 中 Release 并非固定,可以随意取名
- 设置编译配置选项
执行以上命令之后,此时会进入 Vim 编辑模式
按字母键 o
进入编辑模式,粘贴一下配置项
按 :wq
退出
1 2 3 4 5 6 7 8 9
| target_cpu = "x64" is_debug = false symbol_level = 0 enable_nacl = true remove_webcore_debug_symbols = true ffmpeg_branding = "Chrome" proprietary_codecs = true enable_iterator_debugging = false exclude_unwind_tables = true
|
具体配置信息见:链接
- 编译代码
1
| $ ninja -C out/Release chrome
|
out/Release 中 Release 并非固定,可以随意取名
- 运行
1
| $ out/Release/Chromium.app/Contents/MacOS/Chromium
|
编译文件大约 3W 左右, 需要 4-8 个小时
四、编译稳定版(Stable)分支
- 检查分支(option)
- 根据指定分支创建分支,并切换到该分支
1
| $ git checkout -b LovenseBrowser_61.0.3163.100 tags/61.0.3163.100
|
- 同步代码
1
| $ gclient sync --with_branch_heads --jobs 16
|
- 编译代码
1
| $ ninja -C out/Release chrome
|
- 运行
1
| $ out/Release/Chromium.app/Contents/MacOS/Chromium
|
Tip: 同第三步中的第4、5步
脚本
以上所以步骤均已写入脚本,可以使用脚本代替。
脚本链接: Github