1 参考链接
https://blog.csdn.net/foruok/article/details/54944427
2 编译步骤
2.1 下载代码
同windows下载方式
2.2 安装depot_tools
export WORKSPACE=$(pwd)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$WORKSPACE/depot_tools:$PATH
2.3 配置http和https代理
本处使用蓝灯的代理地址,具体代理端口请查看蓝灯的配置
export http_proxy=http://127.0.0.1:40869
export https_proxy=http://127.0.0.1:40869
2.4 同步WebRTC
mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
gclient sync
2.5 编译WebRTC
cd webrtc-checkout/src
// 安装依赖
bash build/install-build-deps.sh
// 可以加入其它的编译参数
//暂时不建议使用这个命令:
gn gen out/linux --args='is_debug=false target_cpu="x64" rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false'
生成ninja项目文件
需要进入webrtc-checkout/src目录下来执行相关命令。
2.5.1 生成debug版ninja项目文件
gn gen out/Default
gn gen out/Default --args='rtc_include_tests=false'
2.5.2 生成release版ninja项目文件
gn gen out/Default --args='is_debug=false'
2.5.3 要清空ninja项目文件
gn clean out/Default
2.5.4 编译
ninja -C out/Default
2.5.5 编译结果
默认编译的是静态库和可执行文件。
进入 out/Default 文件夹,执行ls命令,会看到编译出来各种可执行程序,比如stunserver、relayserver。
2.5.6 清空http和https代理
由于对http和https代理做了相应的白名单处理, 使用该http代理后访问其它的网站会被禁止, 在编译完WebRTC需要把http和https代理设置为空
export http_proxy=''
export https_proxy=''
2.5.7 注意
如果在 src 目录下面使用 git 命令切换了分支,比如使用 git checkout -b myrtc-m79 branch-heads/m79
此时需要再次运行 gclient sync 进行同步,根据需要看是否需要再次使用 build/install-build-deps.sh 安装依赖;
如果直接使用 ninja -C out/Default 进行编译,即使代码是最新的,编译的时候就会出现 framework 不配的情况。