全宇宙最好的IDE,Visual Studio系列,沒有之一。
操作系統(tǒng)
- Windows10專業(yè)版1909,64位版本
- 內(nèi)存12G,建議越大越好
- 預(yù)留了50G磁盤空間,注意有大于4G文件,所以文件系統(tǒng)格式需要是NTFS
VS2019
- 使用的是enterprise版,community版本也沒有問題。
- 在C盤安裝,安裝路徑使用默認(rèn),據(jù)說修改會引起某些問題。
- Desktop development with C++組件選擇安裝10.0.18362或以上的Win10 SDK,最新版的VS2019已經(jīng)默認(rèn)了。
- 后面還需要修改Win10 SDK的安裝,添加安裝調(diào)試工具Debugging Tools for Windows。
- Desktop development with C++組件選擇安裝MFC以及ATL這兩項。
以下可能需要自備梯子
depot_tools安裝
- 獲取depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
depot_tools目錄在D盤根目錄上。
將D:\depot_tools目錄的路徑加到System variables系統(tǒng)環(huán)境變量Path里,然后把該路徑移到最前面(這個工具會下載自己的python和git,避免已安裝沖突)。
在User variables for Administration新建一個系統(tǒng)環(huán)境變量: DEPOT_TOOLS_WIN_TOOLCHAIN ,值設(shè)置為0,提示depot_tools使用本機(jī)的VS進(jìn)行編譯。
WebRTC源碼
打開命令行窗口,在D盤新建個目錄準(zhǔn)備下載源代碼,如下:
D:
mkdir webrtc-checkout
cd webrtc-checkout
在同一個命令行窗口里設(shè)置環(huán)境變量,你如果上面默認(rèn)路徑安裝VS2019企業(yè)版,應(yīng)該是一樣的內(nèi)容,其他版本相應(yīng)修改下就好了。
set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
set GYP_GENERATORS=msvs-ninja,ninja
執(zhí)行下面的命令開始下載代碼,這是個漫長的過程,下載的文件總大小大概10G,包括源碼以及一些測試的音視頻文件資源等等。
fetch --nohooks webrtc
gclient sync
如果中途出錯,那就繼續(xù)運(yùn)行 gclient sync 。
我這個挺順利的,花了一夜時間,順利完成。
編譯
執(zhí)行下面的命令,生成VS2019工程文件
cd src
gn gen --ide=vs out/Default
這一次報錯了,提示如下:
Traceback (most recent call last):
File "D:/webrtc-checkout/src/build/compute_build_timestamp.py", line 127, in <module>
? sys.exit(main())
File "D:/webrtc-checkout/src/build/compute_build_timestamp.py", line 113, in main
? last_commit_timestamp = int(open(lastchange_file).read())
IOError: [Errno 2] No such file or directory: 'D:\webrtc-checkout\src\build\util\LASTCHANGE.committime'
ERROR at //build/timestamp.gni:31:19: Script returned non-zero exit code.
build_timestamp = exec_script(compute_build_timestamp,
?????? ^----------
Current dir: D:/webrtc-checkout/src/out/Default/
Command: D:/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe D:/webrtc-checkout/src/build/compute_build_timestamp.py default
Returned 1.
See //build/config/win/BUILD.gn:10:1: whence it was imported.
import("http://build/timestamp.gni")
^-----------------------------
See //build/config/BUILDCONFIG.gn:446:5: which caused the file to be included.
"http://build/config/win:default_crt",
^-------------------------------
執(zhí)行下面的命令,就可以修復(fù),注意檢查src目錄下的build\util\LASTCHANGE是否存在,沒有就繼續(xù)運(yùn)行源代碼下載。
D:\webrtc-checkout\src>python build\util\lastchange.py build\util\LASTCHANGE
再次運(yùn)行
D:\webrtc-checkout\src>gn gen --ide=vs out/Default
Generating Visual Studio projects took 2261ms
Done. Made 1083 targets from 229 files in 20181ms
生成的項目文件是 D:\webrtc-checkout\src\out\Default 目錄下的 all.sln ,可以用VS2019打開。放個圖。

后面編譯還沒寫。。。