Android webrtc 源碼編譯

編譯最近的代碼

1 環境準備
ubuntu 16.04(最好是這個版本以上)
安裝depot tools:
 國外:git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
 國內:git clone https://source.codeaurora.org/quic/lc/chromium/tools/depot_tools
 配置環境變量:export PATH=$PATH:/home/test/tools/depot_tools


2 下載代碼
創建工作目錄,然後運行以下命令

fetch --nohooks webrtc_android
gclient sync

這將獲取Android特定部分的常規WebRTC checkout。 請注意,Android SDK和NDK等Android特定部分非常大(約8 GB),因此總大小約爲16 GB。 同樣的checkout可以用於Linux和Android開發,因爲您可以爲每個構建配置在不同的目錄中生成Ninja項目文件。

編譯Android,更新必要的依賴庫。

./build/install-build-deps.sh
./build/install-build-deps-android.sh

3 編譯代碼

  1. 使用GN生成項目
    進入src目錄下,
gn gen out/Debug --args='target_os="android" target_cpu="arm"'

可以指定自己選擇的目錄而不是out/Debug ,以便並行管理多個配置。

  • To build for ARM64: use target_cpu=“arm64”
  • To build for 32-bit x86: use target_cpu=“x86”
  • To build for 64-bit x64: use target_cpu=“x64”
  1. 編譯
    ninja -C out/Debug (全部編譯)
    ninja -C out/Debug sdk/android:libjingle_peerconnection_so (單獨編譯某個模塊)
    ninja -C out/Debug AppRTCMobile
    ninja -C out/Debug libwebrtc

下載release版本的代碼

兩種下載方式:
1 已下載原有的Android版本
可以在原有的.git/config中添加

fetch = +refs/branch-heads/*:refs/remotes/branch-heads/*

然後進行git fetch。
之後就可以切換分支了。

2 從最開始下載
創建一個工作目錄,輸入它,然後運行fetch webrtc

mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
gclient sync

下載成功後,到src目錄下
要查看可用的發佈分支,請運行:

git branch -r

要創建跟蹤遠程發佈分支的本地分支(在此示例中爲43分支):

git checkout -b my_branch refs/remotes/branch-heads/43
gclient sync

注意:checkout時不會跟蹤depot_tools,因此gclient sync可能會在足夠舊的分支上中斷。 在這種情況下,您可以嘗試使用較舊的depot_tools:

which gclient
# cd to depot_tools dir
# edit update_depot_tools; add an exit command at the top of the file
git log  # find a hash close to the date when the branch happened
git checkout <hash>
cd ~/dev/webrtc/src
gclient sync
# When done, go back to depot_tools, git reset --hard, run gclient again and
# verify the current branch becomes REMOTE:origin/master

編譯的方法和以上基本一致,太舊的代碼不建議使用。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章