[Android]Linux下WebRTC下載與編譯


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

參考:https://webrtc.org/native-code/android/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM