1.硬盘空间:
WebRTC官方原话:
The checkout size is large due the use of the Chromium build toolchain and many dependencies. Estimated size:
Linux: 6.4 GB.
Linux (with Android): 16 GB (of which ~8 GB is Android SDK+NDK images).
Mac (with iOS support): 5.6GB
2.破墙:
Ubuntu破墙:http://www.cnblogs.com/hcbin/p/8489041.html
3.将socks5协议转http协议
proxychains使用socks5协议,但cipd不支持,会报出这样的错误:
[...] cipd: connectivity error ...
所以只能将socks5协议转http协议
使用polipo进行转换:
git clone https://github.com/jech/polipo.git
安装
cd polipo sudo make all sudo make install
打开编辑器,新建文件
vim /etc/polipo.conf
添加如下内容,保存关闭(绿字是设置polipo的代理,红字是破墙代理)
daemonise = false pidFile = /tmp/polipo.pid proxyAddress="0.0.0.0" proxyPort=8090 socksParentProxy = "127.0.0.1:1080" socksProxyType = socks5 diskCacheRoot = ""
执行polipo(PS:终端会卡住),打开新终端执行操作,命令可以省略proxychains前缀直接破墙
/usr/local/bin/polipo -c /etc/polipo.conf
参考:https://hk.saowen.com/a/fa13ead9f226de7d089a75fc4f56c77e836c43d7317b4fced023af6d133b448e
4.设置depot_tools代理
不设置的话download_from_google_storage会提示NO_AUTH_BOTO_CONFIG
打开编辑器,新建文件
vim /etc/gclient_boto.cfg
添加如下内容,保存关闭(绿字是polipo代理)
[Boto] proxy = 127.0.0.1 proxy_port = 8090
终端设置变量
export NO_AUTH_BOTO_CONFIG=/etc/gclient_boto.cfg
参考:https://blog.csdn.net/qq_22716879/article/details/53760879
5.设置git
git config --global core.packedgitlimit 10g git config --global core.packedgitwindowsize 10g git config --global core.bigfilethreshold 10g git config --global core.compression 0 git config --global core.autocrlf false git config --global core.filemode false git config --global pack.deltacachesize 10g git config --global pack.packsizelimit 10g git config --global pack.windowmemory 10g git config --global pack.threads 4
可选
git config --global branch.autosetupmerge always git config --global branch.autosetuprebase always
下载代码,下载中断用gclient sync命令继续下载,整个下载过程需要几个小时(视乎网络速度)
PS:建议插网线,一般网线传输速率比WIFI快和稳定,WIFI受路由发送速率与无线网卡接收速率限制
mkdir webrtc-android && cd webrtc-android fetch --nohooks webrtc_android gclient sync
因为异常中断,使用gclient sync继续下载
如中断时发现某个文件无法下载,请手动下载,并复制到提示的文件夹中,然后多尝试用gclient sync继续下载
root@ubuntu:/home/hcbin/webrtc-android# gclient sync Running depot tools as root is sad. Syncing projects: 23% (15/63) src/third_party/accessibility_test_framework:chromium/third_party/accessibility-test-frameSyncing projects: 25% (16/63) src/third_party/android_support_test_runner:chromium/third_party/android_support_test_runnSyncing projects: 26% (17/63) src/third_party/bazel:chromium/third_party/bazel Syncing projects: 30% (19/63) src/third_party/byte_buddy:chromium/third_party/byte_buddy ________ running 'cipd ensure -log-level error -root /home/hcbin/webrtc-android/src -ensure-file /tmp/tmp78dpke.ensure' in '.' Bootstrapping cipd client for linux-amd64 from https://chrome-infra-packages.appspot.com/client?platform=linux-amd64&version=git_revision:ae28364c740acff97ae118adcb2808b6cb5129c5... curl: (7) Failed to connect to chrome-infra-packages.appspot.com port 443: Connection refused Syncing projects: 68% (44/64) src/third_party/junit/src [0:02:33] Still working on: [0:02:33] src/third_party/icu [0:02:43] Still working on: [0:02:43] src/third_party/icu [0:02:53] Still working on: [0:02:53] src/third_party/icu [0:03:03] Still working on: [0:03:03] src/third_party/icu [0:03:14] Still working on: [0:03:14] src/third_party/icu [0:03:18] Still working on: [0:03:18] src/third_party/icu Syncing projects: 70% (45/64) src/third_party/icu src/third_party/apk-patch-size-estimator:chromium/third_party/apk-patch-size-estimator (ERROR) ---------------------------------------- [0:00:47] Started. ---------------------------------------- Error: Command 'cipd ensure -log-level error -root /home/hcbin/webrtc-android/src -ensure-file /tmp/tmp78dpke.ensure' returned non-zero exit status 7 root@ubuntu:/home/hcbin/webrtc-android#
参考:https://blog.csdn.net/qq_22716879/article/details/53760879
6.编译
下载依赖
cd src ./build/install-build-deps.sh
确定当前工作目录是src,使用GN生成项目
gn gen out/Release --args='target_os="android" target_cpu="arm"'
ARM64 使用 target_cpu="arm64"
32-bit x86: 使用 target_cpu="x86"
64-bit x64: 使用 target_cpu="x64"
编译
ninja -C out/Release