昆明網站建設培訓/寧德市政府
最近項目上遇到webrtc wgc 的幾個test case無法通過,與webrtc人員溝通后決定要自行修復一下(因為他們不想管…)
參考文檔
- https://webrtc.org/support/contributing
- https://chromium.googlesource.com/chromium/src/+/main/docs/#checking-out-and-building
以上兩個夠了,一個是webrtc的,一個是chromium的,他倆親兄弟,一套體系
正常流程
他的常規(guī)要求比如git, vs,硬盤大小什么的不再贅述,自行閱讀,但一般開發(fā)電腦都OK,重中之重,一個穩(wěn)定可靠的 科學上網工具,如果沒有,就不要往下看了,以下的所有步驟,都認為你開了科學上網工具,而且認為你已經正確的開了全局代理或運行在設置了proxy的命令行中~
-
下載工具包 depot_tools
他的使用手冊在 depot_tools_tutorial,剛開始沒必要看,下載安裝即可,當然里面也描述了一些問題的解決方法,但我這一步都沒遇到過
-
配置 depot_tools
Add depot_tools to the front of your PATH (must be ahead of any installs of Python). Assuming you unzipped the bundle to C:\workspace\depot_tools:
解壓到指定目錄里,隨意,然后添加到環(huán)境變量中,為了避免工具鏈與你的其他工具沖突,請把它上移最頂部或者最前面。
-
運行gclient
- 新建一個文件夾,比如,webrtc
- 打開這個文件夾,并且將你命令行的工作目錄設置到這里或者簡單 cd 過來
- 輸入
gclient
- 沒什么錯的話他會經過一會兒更新之類的,然后給你打印出來一些選項,這就ok了
-
拉取代碼
- 還是在上一步的文件夾內,輸入
fetch --nohooks webrtc
- 然后就是漫長的等待,大概有幾百MB的代碼和一些工具要同步
- 上一步沒有失敗最好不過了,有了也不怕,任何報錯后再次輸入
gclient sync
,fetch
只是在第一次時使用,隨后都用gclient sync
, 然后看錯誤解決錯誤吧,我只遇到過讓我對git做一些配置以及一個proxy的報錯,說是檢查到你用了代理,但是沒有檢測到代理配置文件(他應該是有工具可以讀這個配置文件,這樣他的工具鏈可以走你的代理) - 在上一步的文件夾內新建文件
.boto
, 并寫入以下內容
[Boto]proxy = 127.0.0.1proxy_port = 7890proxy_type = http
5.重新運行
gclient sync
直到沒有任何報錯而且資源都下載完成即可~ - 還是在上一步的文件夾內,輸入
-
構建代碼
cd src gn gen out/Default --args="is_debug=false" --ide=vs autoninja -C out/Default
其中
is_debug=false
表示要編譯release,--ide=vs
表示要生成vs的項目文件,不出意外的話還是會有意外,比如我碰到四個個問題- vs版本低了,更新即可
Chromium requires Visual Studio 2022 (>=17.0.0) to build. Visual Studio can also be used to debug Chromium.
- WINDOWS SDK版本低了,通過vs installer去更新安裝對應版本即可
Windows 11 SDK version 10.0.22621.2428. This can be installed separately or by checking the appropriate box in the Visual Studio Installer.
- WINDOWS SDK版本夠了,但是debugger組件沒有,通常是因為你是通過vs installer安裝的
(Windows 11) SDK Debugging Tools 10.0.22621.755 or higher. This version of the Debugging tools is needed in order to support reading the large-page PDBs that Chrome uses to allow greater-than 4 GiB PDBs. This can be installed after the matching Windows SDK version is installed, from: Control Panel -> Programs and Features -> Windows Software Development Kit [version] -> Change -> Debugging Tools for Windows. If building on ARM64 Windows then you will need to manually copy the Debuggers\x64 directory from another machine because it does not get installed on ARM64 and is needed, whether you are building Chromium for x64 or ARM64 on ARM64.
4.讓你設置DEPOT_TOOLS_WIN_TOOLCHAIN用來生成工程時,用本地的vs 而不是從Google下載,他也不給外人下載
Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN environment variable in the same way, and set it to 0. This tells depot_tools to use your locally installed version of Visual Studio (by default, depot_tools will try to use a google-internal version).
需要注意的是如果你的host機器是arm64架構的,這個安裝程序還是會缺少x64架構的debugger,沒辦法只能從別的機器里面copy一個過來~
-
運行test case
經過漫長的等待,5000多個文件的編譯完成后,可以在out/Default中查看你所編譯好的一切,隨便運行點什么吧。
-
VS中編譯調試
打開生成的VS工程,選中你想要編譯調試的工程,其他和你普通項目一樣,唯一一點是,他的構建工具是ninja而不是msvc,我的機器是個比較干凈的機器沒有過其他環(huán)境的安裝,碰到了無法找到ninja的錯誤信息。
用everything搜索ninja.exe,把ninja.exe添加到環(huán)境變量中,重新打開工程,可以調試了~(上面的autoninja是個批處理,里面也是找當前目錄中的ninja.exe并且去執(zhí)行~)