FGYP_GENERATORSGoogle官方文档参考:Development | WebRTC
-
安装VS
VS 必须安装在C盘,否则需要修改很多文件
1、Desktop development with C++ 2、MFC and ATL support
3、Windows10SDK 选择版本:10.0.19041.0 Windows Software Development Kit,下载后安装上
4、通过卸载面板,选择windowsSDK change->勾选所有
-
安装depot_tools
1、下载 curl https://storage.googleapis.com/chrome-infra/depot_tools.zip --output depot_tools.zip 2、解压缩 mkdir c:\depot_tools tar -xf depot_tools.zip -C c:\depot_tools del depot_tools.zip 3、 设置环境变量 set PATH=c:\depot_tools;%PATH%
-
下载源码
方法一:
1、设置webrtc本地环境
set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set GYP_MSVS_VERSION=2019
2、下载webrtc官方源码执行
fetch --nohooks webrtc
3、切换到自己仓库依赖的主分支,例如:依赖M97切换到4692,然后执行
gclient sync -d 4692
4、添加远端仓库
git add remote XXX git@XXX.git
方法二:
1、下载自己仓库的源码,并改名为src
2、拷贝官网webrtc的.gclient、.gclient_entries和src同目录
存放的是需要依赖的目录
同步编译依赖
gclient sync -f
-
编译
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community set GYP_MSVS_VERSION=2019 set GYP_GENERATORS=msvs-ninja,ninja set DEPOT_TOOLS_WIN_TOOLCHAIN=0
执行工程构建命令
gn gen out/release_h264_clang_vs2019 --args="target_cpu=\"x86\" is_debug=false enable_iterator_debugging=true use_custom_libcxx = false use_rtti=true is_component_build=false is_clang=true proprietary_codecs=true rtc_use_h264=true ffmpeg_branding=\"Chrome\" rtc_build_ssl=true " --ide=vs2019
-
error问题解决
1、vs没有安装在c盘
ERROR at //build/config/win/visual_studio_version.gni:27:7: Script returned non-zero exit code.
代表vs不是装在C盘,在webrtc/src/build/vs_toolchain.py 163行添加vs绝对路径
path = os.path.expandvars('D:/Microsoft Visual Studio/%s' % version)
2、ERROR at //build/toolchain/toolchain.gni:10:1: Can't load input file.
See //build/config/profiling/profiling.gni:6:1: whence it was imported.
代表编译库已经被污染了,替换
build目录 build_overrides目录