一、环境及代码获取
1、本机系统环境
系统:Windows Server 2016,Windows10(代码及编译消耗巨大,采用云端服务器编译)
VS版本:VS2017 15.9.38(建议保持这个版本及以上版本)
代码版本: 分支4103 commit 3ed9687558f4fd0271adf5836d4a029df858dc43 6/28/2020
PYTHON: 2.7.17
语言区域:美国英语(系统及IDE都设为英文)
2、代码获取
(1)安装depot_tools工具包
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
(2)设置一下环境变量
DEPOT_TOOLS_WIN_TOOLCHAIN=0
GYP_GENERATORS=msvs-ninja,ninja
GYP_MSVS_VERSION=2017
PATH添加G:\depot_tools在最前面
(3)获取代码
fetch --nohooks webrtc
如果中途断网:
gclient sync
(4)切换分支
git checkout -b (随便命名) refs/remotes/branch-heads/(指定版本号)
gclient sync -D
二、编译
1、将运行时库由MT改为MD(可选,编SDK建议做这一步)
Windows默认不支持is_component_build设置
手动将src/build/config/win/build.gn改为以下内容
config("default_crt") {
if (is_component_build) {
# Component mode: dynamic CRT. Since the library is shared, it requires
# exceptions or will give errors about things not matching, so keep
# exceptions on.
configs = [ ":dynamic_crt" ]
} else {
if (current_os == "winuwp") {
# https://blogs.msdn.microsoft.com/vcblog/2014/06/10/the-great-c-runtime-crt-refactoring/
# contains a details explanation of what is happening with the Windows
# CRT in Visual Studio releases related to Windows store applications.
configs = [ ":dynamic_crt" ]
} else {
# Desktop Windows: static CRT.
configs = [ ":`dynamic_crt`" ]
}
}
}
或者
config("static_crt") {
if (is_debug) {
# This pulls in the static debug CRT and defines _DEBUG
cflags = [ `"/MDd" `]
} else {
cflags = [ `"/MD"` ]
}
}
参考https://blog.csdn.net/haowei0926/article/details/78530560
2、在构建目录out\debug 新建args.gn,填入以下内容
is_debug = true // release is_debug=false
rtc_enable_protobuf = false
target_cpu = “x86” // 64bit target_cpu = “x64”
target_os = “win”
is_clang = false
libyuv_include_tests = false
rtc_include_tests = false
rtc_use_h264 = true
is_component_ffmpeg=true
enable_iterator_debugging=true
3、生成工程
32bit
gn args out1/Debug --ide=vs2017 --winsdk=10.0.19041.0
gn args out1/Release --ide=vs2017 --winsdk=10.0.19041.0
64bit
gn arg