這里只簡介官網源碼編譯步驟,所以需要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:\src\depot_tools, open:
Control Panel → System and Security → System → Advanced system settings
If you have Administrator access, Modify the PATH system variable and put C:\src\depot_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:\src\depot_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 Studio\2019\Professional
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 out\Default 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 out\Default
$ devenv out\Default\all.sln