昆明網(wǎng)站建設(shè)培訓(xùn)/寧德市政府
最近項(xiàng)目上遇到webrtc wgc 的幾個(gè)test case無(wú)法通過(guò),與webrtc人員溝通后決定要自行修復(fù)一下(因?yàn)樗麄儾幌牍堋?
參考文檔
- https://webrtc.org/support/contributing
- https://chromium.googlesource.com/chromium/src/+/main/docs/#checking-out-and-building
以上兩個(gè)夠了,一個(gè)是webrtc的,一個(gè)是chromium的,他倆親兄弟,一套體系
正常流程
他的常規(guī)要求比如git, vs,硬盤大小什么的不再贅述,自行閱讀,但一般開發(fā)電腦都OK,重中之重,一個(gè)穩(wěn)定可靠的 科學(xué)上網(wǎng)工具,如果沒(méi)有,就不要往下看了,以下的所有步驟,都認(rèn)為你開了科學(xué)上網(wǎng)工具,而且認(rèn)為你已經(jīng)正確的開了全局代理或運(yùn)行在設(shè)置了proxy的命令行中~
-
下載工具包 depot_tools
他的使用手冊(cè)在 depot_tools_tutorial,剛開始沒(méi)必要看,下載安裝即可,當(dāng)然里面也描述了一些問(wèn)題的解決方法,但我這一步都沒(méi)遇到過(guò)
-
配置 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)境變量中,為了避免工具鏈與你的其他工具沖突,請(qǐng)把它上移最頂部或者最前面。
-
運(yùn)行g(shù)client
- 新建一個(gè)文件夾,比如,webrtc
- 打開這個(gè)文件夾,并且將你命令行的工作目錄設(shè)置到這里或者簡(jiǎn)單 cd 過(guò)來(lái)
- 輸入
gclient
- 沒(méi)什么錯(cuò)的話他會(huì)經(jīng)過(guò)一會(huì)兒更新之類的,然后給你打印出來(lái)一些選項(xiàng),這就ok了
-
拉取代碼
- 還是在上一步的文件夾內(nèi),輸入
fetch --nohooks webrtc
- 然后就是漫長(zhǎng)的等待,大概有幾百M(fèi)B的代碼和一些工具要同步
- 上一步?jīng)]有失敗最好不過(guò)了,有了也不怕,任何報(bào)錯(cuò)后再次輸入
gclient sync
,fetch
只是在第一次時(shí)使用,隨后都用gclient sync
, 然后看錯(cuò)誤解決錯(cuò)誤吧,我只遇到過(guò)讓我對(duì)git做一些配置以及一個(gè)proxy的報(bào)錯(cuò),說(shuō)是檢查到你用了代理,但是沒(méi)有檢測(cè)到代理配置文件(他應(yīng)該是有工具可以讀這個(gè)配置文件,這樣他的工具鏈可以走你的代理) - 在上一步的文件夾內(nèi)新建文件
.boto
, 并寫入以下內(nèi)容
[Boto]proxy = 127.0.0.1proxy_port = 7890proxy_type = http
5.重新運(yùn)行
gclient sync
直到?jīng)]有任何報(bào)錯(cuò)而且資源都下載完成即可~ - 還是在上一步的文件夾內(nèi),輸入
-
構(gòu)建代碼
cd src gn gen out/Default --args="is_debug=false" --ide=vs autoninja -C out/Default
其中
is_debug=false
表示要編譯release,--ide=vs
表示要生成vs的項(xiàng)目文件,不出意外的話還是會(huì)有意外,比如我碰到四個(gè)個(gè)問(wèn)題- vs版本低了,更新即可
Chromium requires Visual Studio 2022 (>=17.0.0) to build. Visual Studio can also be used to debug Chromium.
- WINDOWS SDK版本低了,通過(guò)vs installer去更新安裝對(duì)應(yīng)版本即可
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組件沒(méi)有,通常是因?yàn)槟闶峭ㄟ^(guò)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.讓你設(shè)置DEPOT_TOOLS_WIN_TOOLCHAIN用來(lái)生成工程時(shí),用本地的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機(jī)器是arm64架構(gòu)的,這個(gè)安裝程序還是會(huì)缺少x64架構(gòu)的debugger,沒(méi)辦法只能從別的機(jī)器里面copy一個(gè)過(guò)來(lái)~
-
運(yùn)行test case
經(jīng)過(guò)漫長(zhǎng)的等待,5000多個(gè)文件的編譯完成后,可以在out/Default中查看你所編譯好的一切,隨便運(yùn)行點(diǎn)什么吧。
-
VS中編譯調(diào)試
打開生成的VS工程,選中你想要編譯調(diào)試的工程,其他和你普通項(xiàng)目一樣,唯一一點(diǎn)是,他的構(gòu)建工具是ninja而不是msvc,我的機(jī)器是個(gè)比較干凈的機(jī)器沒(méi)有過(guò)其他環(huán)境的安裝,碰到了無(wú)法找到ninja的錯(cuò)誤信息。
用everything搜索ninja.exe,把ninja.exe添加到環(huán)境變量中,重新打開工程,可以調(diào)試了~(上面的autoninja是個(gè)批處理,里面也是找當(dāng)前目錄中的ninja.exe并且去執(zhí)行~)