目录
1.下载源码
2.下载稳定版本
3.生成工程
4.编译
5.vscode配置
首先,下载depot_tools
mkdir webrtc
cd webrtc
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
然后,配置环境变量,后面需要用到的工具都在depot_tools文件夹里面
export PATH="$PATH:/home/xxxx/webrtc/depot_tools"
获取webrtc源码,时间会比较长
fetch --nohooks webrtc
gclient sync
如果不想编译,只是看代码,可以直接下载源码,不需要depot_tools
https://webrtc.googlesource.com/src.git
源码下载完成以后,在src目录
开始安装依赖库
cd src
./build/install-build-deps.sh --no-chromeos-fonts
如果想下载稳定的webrtc版本,可以切换到相应的branch
git checkout -b remotes/branch-heads/5615
切换完成以后,需要同步以下
gclient sync
不同稳定版本对应关系可以参照
https://chromiumdash.appspot.com/branches
cd src
gn gen out/Default
如果想用vscode单步调试,可以用以下命令
gn gen out/Default --args='is_debug=true rtc_include_tests=false treat_warnings_as_errors=false use_rtti=true is_component_build=false enable_iterator_debugging=false is_clang=false use_sysroot=false use_custom_libcxx=false use_custom_libcxx_for_host=false target_os="linux" target_cpu="x64"'
cd src
ninja -C out/Default
安装vscode,调试用的文件launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "peerconnection_client",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/Default/peerconnection_client",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}