官方指南 提供了完整的说明,只要环境设置对然后一步一步跟着做就能编译成功

准备工作

截至2021-3-29需要设置的推荐环境

  • Windows 10
  • 拥有至少 16GB 内存的64位计算机
  • 最少 100GB 的磁盘空余空间(NTFS格式)
  • VS2019 (>=16.0.0)
    • Desktop development with C++
    • MFC/ATL support
    • Windows 10 SDK (>= 10.0.19041 )
    • Debugging Tools For Windows
  • depot_tools
  • 系统变量
    • 添加depot_tools路径到Path开始处
    • DEPOT_TOOLS_WIN_TOOLCHAIN = 0
    • 设置vs2019_install为 Visual Studio 2019 路径

编译

my cmd history (从非cmd的shell中运行 gclient可能不能正常工作)

gclient
git config --global user.name "My Name"
git config --global user.email "my-name@chromium.org"
git config --global core.autocrlf false
git config --global core.filemode false
git config --global branch.autosetuprebase always
E:
mkdir chromium && cd chromium
mkdir chromium && cd chromium
fetch chromium
gn gen out/Default
autoninja -C out\Default chrome -j4

中间clang-cli会出现爆栈崩溃,不用方,重新执行autoninja就好

编译完的可执行路径在 out/Default/chrome.exe

第一次编译天长地久,我花了11个小时,但之后如果只是修改一些组件的代码的话,大部分obj不会重新编译,会快很多

编译时带上多媒体组件

编译支持mp4的chrome需要加编译参数

可以使用gn命令看可用设置

gn args --list out\Default
gn gen out/Cmole --args="ffmpeg_branding=\"Chrome\" proprietary_codecs=true"
autoninja -C out\Default chrome -j4

切换分支

切换版本 Working with Release Branches - The Chromium Projects

gclient sync --with_branch_heads --with_tags
git fetch --tags
git checkout -b my_branch tags/80.0.3987.106
gclient sync --with_branch_heads --with_tags