主要過程參考官方文檔:https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md
chromium編譯步驟: 1.下載depot_tools 下載地址:https://storage.googleapis.com/chrome-infra/depot_tools.zip 2.將depot_tools.zip解壓后,將depot_tools目錄路徑添加到系統的PATH環境變量,添加環境變量DEPOT_TOOLS_WIN_TOOLCHAIN = 0; 注: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. 3.創建源碼目錄 mkdir chromium //創建目錄 cd chromium 4.配置代理 *******(重要步驟)********* (1)為CMD設置HTTP/HTTPS代理 打開一個具有管理員權限的CMD C:>netsh netsh>winhttp netsh winhttp>set proxy 127.0.0.1:1080 netsh winhttp>bye C:>set http_proxy=http://127.0.0.1:1080 C:>set https_proxy=http://127.0.0.1:1080 注:此步驟若關閉當前cmd,重新打開新的cmd需要重新配置代理 (2)為git設置http/https代理 C:>git config –-global http.proxy %http_proxy% C:>git config –-global https.proxy %https_proxy% (3)設置NO_AUTH_BOTO_CONFIG <1>隨便找個地方創建一個文本文件,比如 C:\boto.cfg 文本內容: [Boto] proxy=127.0.0.1 proxy_port=1080 <2>設置環境變量 C:>set NO_AUTH_BOTO_CONFIG=C:\boto.cfg 備注: 代碼同步成功后,記得回復系統設置 (1)恢復netsh winhttp設置為直連 C:>netsh netsh>winhttp netsh winhttp>reset proxy (2)清除git代理 git config --global --unset http.proxy git config --global --unset https.proxy 5.更新depot_tools C:>gclient 6.如果之前從未使用過git,那么需要進行一下全球的git配置 C:>git config –global user.name "yourname" #yourname改為你希望的用戶名 C:>git config –global user.email "youremailaddress@gmail.com" #輸入你自己的郵箱 7.下載chromium代碼 fetch chromium //下載代碼 fetch --no-history chromium //只下載最新版本 8.下載完成后,再同步更新一次代碼 git pull gclient sync 9.如果編譯指定版本,需要如下操作 (1)檢查分支 git fetch --tags (2)根據指定分支創建分支,並切換到該分支 git checkout -b Browser_61.0.3163.100 tags/61.0.3163.100 //Browser_61.0.3163.100為分支名;61.0.3163.100為對應版本 (3)同步代碼 gclient sync 10.最后一步,編譯chromium源碼 (1)進入源碼目錄 cd src (2)生成編譯配置文件 gn gen out/Default --ide=vs --args="target_cpu=\"x86\"" //out/Default 中 Default並非固定,可以隨意取名 (3)編譯代碼 ninja -C out/Default chrome
這邊提下遇到的問題:
首先你需要保證的是!
1.下載chromium源碼的磁盤....100G保證下
2.內存的話,最好最好是16G
下載:
下載depot_tools,VS都按照文檔來,包括VS下載也按照文檔來用命令行的方式,這邊要注意的是
去控制面板更改SDK 要選中 Debugging Tools for windows這個~
1. 打開cmd,在你想放置源碼的位置,創建chromium文件夾並進入,mkdir chromium && cd chromium;
2. fetch chromium;
下載不下來的話,找同事要把......
這邊遇到問題,
[0:36:42] Still working on:
[0:36:42] src/third_party/angle
沒事,要是斷了,你就一直執行gclient sync --force
最后!!!!
編譯:
看文檔,這邊提到遇到的問題
1. 首先使用默認的編譯方式吧,使用gn gen out/Default,會在src目錄下創建out/Default目錄,並配置些編譯需要的文件;
這個遇到了問題
1). No supported Visual Studio can be found. Supported versions are: 16.0 (2019), 15.0 (2017)
我是直接運行
E:\chromium>gclient sync --force fatal: unable to access 'https://chromium.googlesource.com/chromium/tools/depot_tools.git/': Failed to connect to chromium.googlesource.com port 443: Timed out Syncing projects: 100% (117/117), done. Hook 'vpython.bat src/testing/generate_location_tags.py --out src/testing/location_tags.json' took 34.50 secs Running hooks: 100% (109/109), done. E:\chromium>python src/build/vs_toolchain.py get_toolchain_dir vs_path = "E:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community" sdk_path = "E:\\Windows Kits\\10" vs_version = "2019" wdk_dir = "" runtime_dirs = "C:\\Windows\\System32;C:\\Windows\\SysWOW64;Arm64Unused"
2).找不到SDK
記得添加到環境變量path中
3).就是SDK需要下載安裝Debugging Tools for windows
2. 使用ninja -C outDefault chrome命令行編譯chrome,此時需要等待漫長的時間;
這邊遇到了問題,一個就是磁盤不夠,一個就是內存分配不足,也就是為什么要建議磁盤100G,內存16G的原因
運行:
在 E:\chromium\src下
gn gen --ide=vs out\Default devenv out\Default\all.sln
這邊繼續遇到問題:
path配置環境:
E:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat E:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE
按照每個人的來........
然后重啟cmd再次執行下....
再次遇到問題
對COM組件的調用返回了錯誤HRESULT E_FAIL
找到並且運行Developer Command Prompt for VS 2019 管理員身份運行
命令行打開cmd
執行這個gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll
這里記住命令要到指定目錄下才能執行
一般最后的執行命令路徑在 …\Common7\IDE\PublicAssemblies
如果遇到gacutil不是內部或外部命令
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools
看看有沒有gacutil.exe文件,有的話,把上面路徑配置在path下,設置一下系統的環境。
沒有的話就要去安裝
隨便選一個就好
在把路徑裝進去
關掉vs,再來一次
devenv out\Default\all.sln
再次嘗試了下,這是個悲傷的故事:用gclient的時候,出現了此時不應該出現)
原因是因為depot_tools這邊!!!的路徑有了()
比如C:\Program Files (x86) 這個就不行
然后改了之后再來!!!
顯示glient不是內部或外部命令,也不是可運行的程序或批處理文件。說明 depot_tools 的環境變量未生效,請查看配置是否正確;重啟下就ok
然后!
輸入gclient --version 沒有就下載了,有就出現版本了
顯示“gclient.py 0.7”,說明 depot_tools 的環境變量已經生效;
環境變量的配置有,我是系統變量用戶變量都配置了。
然后皆大歡喜: