这里只简介官网源码编译步骤,所以需要FQ,否则第三方离线源码包下载之后编译遇到乱七八糟的错误,浪费时间。
环境win10,预装了vs2019社区版。
先装上git,卸载掉python
Add depot_tools to the start of your PATH (must be ahead of any installs of Python). Assuming you unzipped the bundle to C:srcdepot_tools, open:
Control Panel → System and Security → System → Advanced system settings
If you have Administrator access, Modify the PATH system variable and put C:srcdepot_tools
at the front (or at least in front of any directory that might already have a copy of Python or Git).
If you don't have Administrator access, you can add a user-level PATH environment variable and put C:srcdepot_tools
at the front,** but if your system PATH has a Python in it, you will be out of luck.**
git用于下载源码,depot_tools to the start of your PATH ,depot_tools路径放在python之前不知道行不行,因为官网这么说的,不行就先卸载python,之后会自己装上的。
下载depot_tools
https://storage.googleapis.com/chrome-infra/depot_tools.zip
右键解压另存,不要拖拽,否则里可能丢掉隐藏文件。
Warning: DO NOT use drag-n-drop or copy-n-paste extract from Explorer, this will not extract the hidden “.git” folder which is necessary for depot_tools to autoupdate itself. You can use “Extract all…” from the context menu though.
把depot_tools
解压后的路径放到系统环境变量path中
安装免费的vs2019 Community版本,带win10kits和debug tools。
以下都用命令行操作。
set vs2019_install=C:Program Files (x86)Microsoft Visual Studio2019Professional
for Visual Studio 2019.
如果后面报win32 dll找不到或者win10 kits找不到,手动下载
使用本地visual studio编译要用2017或2019版本,且要添加环境变量DEPOT_TOOLS_WIN_TOOLCHAIN值为0
win10 SDK进行安装,记录勾选debug tools装完最好重启下,甚至前面更新完环境变量可能也要重新启动下。
fetch chromium
$ mkdir chromium && cd chromium
$ fetch chromium --no-history
$ cd src
$ gn gen out/Default
$ autoninja -C outDefault chrome
gn gen out/Default --args="is_component_build = true is_debug = true"
--args可加target_cpu = "x64"
编译64位,默认是x86,如果自己指定target_cpu为x86解析会出错
gn gen out/Default --args="is_component_build = true is_debug = true target_cpu = "x64""
生成vs工程
$ gn gen --ide=vs outDefault
$ devenv outDefaultall.sln