WebRTC在Windows下编译过程

0、设置代理

根据自己的代理服务器来具体设置。
git config --global http.proxy "127.0.0.1:60609"
git config --global https.proxy "127.0.0.1:60609"

set http_proxy=http://127.0.0.1:60609
set https_proxy=http://127.0.0.1:60609

1、安装Depot Tools

Depot Tools下载路径:https://storage.googleapis.com/chrome-infra/depot_tools.zip
下载完把压缩包解压,然后把解压目录加入PATH环境变量(PS:需要放到python环境比那里之前)

2、源码下载(编译依赖下载)

mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
gclient sync

PS:gclient sync失败描述如下。
Running hooks: 40% ( 9/22) win_toolchain
________ running 'vpython.bat src/build/vs_toolchain.py update --force' in 'D:\webrtc-checkout'
No downloadable toolchain found. In order to use your locally installed version of Visual Studio to build Chrome please set DEPOT_TOOLS_WIN_TOOLCHAIN=0.
For details search for DEPOT_TOOLS_WIN_TOOLCHAIN in the instructions at https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md
解决方案:安装VS2017,set DEPOT_TOOLS_WIN_TOOLCHAIN=0 ,然后重新gclient sync 即可。

PS:Exception: No supported Visual Studio can be found.
File "D:\webrtc-checkout\src\build\vs_toolchain.py", line 168, in GetVisualStudioVersion ' Supported versions are: %s.' % supported_versions_str)
Exception: No supported Visual Studio can be found. Supported versions are: 16.0 (2019), 15.0 (2017).
解决方案:在环境变量中添加vs2017_install,值为安装路径,例如 D:\Program Files (x86)\Microsoft Visual Studio\2017\Community  

3、编译

切换到realease分支再编译
git checkout -b m79 remotes/branch-heads/m79
gclient sync -D

# gn clean out/Default  ( 清理动作)
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_MSVS_VERSION=2017
set GYP_GENERATORS=ninja

cd webrtc-checkout
cd src
# gn clean out/Default  (清理动作)
# gn gen --ide=vs --args="is_clang=false" out/Default   
gn gen out/Default --ide=vs2017 --args="is_debug=true rtc_include_tests=false is_clang=false use_lld=false enable_iterator_debugging=true target_cpu=\"x64\""

ninja -C out/Default  

PS: ninja: error: loading 'build.ninja': 系统找不到指定的文件。
解决方案: build.ninja 找不到的原因实际上是上一步 gn gen out/Default 出错导致的,需要VS安装 "Debugging Tools for Windows"。

You must install the "Debugging Tools for Windows" feature from the Windows 10 SDK.ERROR at //build/toolchain/win/BUILD.gn:49:3: Script returned non-zero exit code.
解决方案:win 10 SDK还需要安装Debugging Tools,安装步骤为 控制面板 → 程序 → 程序和功能 → 选中“Windows Software Development Kit” → 变更 → Change → Check “Debugging Tools For Windows” → Change.  

PS:ImportError: No module named win32file
解决方法:python -m pip install pywin32

参考资料:
https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/development/prerequisite-sw/index.md
https://blog.jianchihu.net/webrtc-build-vs2017.html
https://blog.csdn.net/aaronjny/article/details/79828939

你可能感兴趣的:(WebRTC在Windows下编译过程)