感谢声网提供的webrtc国内源码镜像。
首先要安装好海思编译工具链和git。
先替换一下webrtc代码的仓库网址路径
1 git config --global user.email "100582783@qq.com" 2 git config --global user.name "linxing" 3 git config --global url.http://120.92.49.206:3232/chromiumsrc/webrtc.git.insteadOf https://chromium.googlesource.com/external/webrtc.git 4 git config --global url.http://120.92.49.206:3232/chromiumsrc/base.git.insteadOf https://chromium.googlesource.com/chromium/src/base 5 git config --global url.http://120.92.49.206:3232/chromiumsrc/build.git.insteadOf https://chromium.googlesource.com/chromium/src/build 6 git config --global url.http://120.92.49.206:3232/chromiumsrc/buildtools.git.insteadOf https://chromium.googlesource.com/chromium/src/buildtools 7 git config --global url.http://120.92.49.206:3232/chromiumsrc/gradle.git.insteadOf https://chromium.googlesource.com/external/github.com/gradle/gradle.git 8 git config --global url.http://120.92.49.206:3232/chromiumsrc/ios.git.insteadOf https://chromium.googlesource.com/chromium/src/ios.git 9 git config --global url.http://120.92.49.206:3232/chromiumsrc/testing.git.insteadOf https://chromium.googlesource.com/chromium/src/testing 10 git config --global url.http://120.92.49.206:3232/chromiumsrc/third_party.git.insteadOf https://chromium.googlesource.com/chromium/src/third_party 11 git config --global url.http://120.92.49.206:3232/chromiumsrc/clang-format.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format.git 12 git config --global url.http://120.92.49.206:3232/chromiumsrc/libcxx.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/libcxx.git 13 git config --global url.http://120.92.49.206:3232/chromiumsrc/libcxxabi.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/libcxxabi.git 14 git config --global url.http://120.92.49.206:3232/chromiumsrc/libunwind.git.insteadOf https://chromium.googlesource.com/external/llvm.org/libunwind.git 15 git config --global url.http://120.92.49.206:3232/chromiumsrc/android_ndk.git.insteadOf https://chromium.googlesource.com/android_ndk.git 16 git config --global url.http://120.92.49.206:3232/chromiumsrc/android_tools.git.insteadOf https://chromium.googlesource.com/android_tools.git 17 git config --global url.http://120.92.49.206:3232/chromiumsrc/auto.git.insteadOf https://chromium.googlesource.com/external/github.com/google/auto.git 18 git config --global url.http://120.92.49.206:3232/chromiumsrc/catapult.git.insteadOf https://chromium.googlesource.com/catapult.git 19 git config --global url.http://120.92.49.206:3232/chromiumsrc/compact_enc_det.git.insteadOf https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git 20 git config --global url.http://120.92.49.206:3232/chromiumsrc/colorama.git.insteadOf https://chromium.googlesource.com/external/colorama.git 21 git config --global url.http://120.92.49.206:3232/chromiumsrc/depot_tools.git.insteadOf https://chromium.googlesource.com/chromium/tools/depot_tools.git 22 git config --global url.http://120.92.49.206:3232/chromiumsrc/errorprone.git.insteadOf https://chromium.googlesource.com/chromium/third_party/errorprone.git 23 git config --global url.http://120.92.49.206:3232/chromiumsrc/ffmpeg.git.insteadOf https://chromium.googlesource.com/chromium/third_party/ffmpeg.git 24 git config --global url.http://120.92.49.206:3232/chromiumsrc/findbugs.git.insteadOf https://chromium.googlesource.com/chromium/deps/findbugs.git 25 git config --global url.http://120.92.49.206:3232/chromiumsrc/freetype2.git.insteadOf https://chromium.googlesource.com/chromium/src/third_party/freetype2.git 26 git config --global url.http://120.92.49.206:3232/chromiumsrc/harfbuzz.git.insteadOf https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git 27 git config --global url.http://120.92.49.206:3232/chromiumsrc/gtest-parallel.git.insteadOf https://chromium.googlesource.com/external/github.com/google/gtest-parallel 28 git config --global url.http://120.92.49.206:3232/chromiumsrc/googletest.git.insteadOf https://chromium.googlesource.com/external/github.com/google/googletest.git 29 git config --global url.http://120.92.49.206:3232/chromiumsrc/icu.git.insteadOf https://chromium.googlesource.com/chromium/deps/icu.git 30 git config --global url.http://120.92.49.206:3232/chromiumsrc/jsr-305.git.insteadOf https://chromium.googlesource.com/external/jsr-305.git 31 git config --global url.http://120.92.49.206:3232/chromiumsrc/jsoncpp.git.insteadOf https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp.git 32 git config --global url.http://120.92.49.206:3232/chromiumsrc/junit.git.insteadOf https://chromium.googlesource.com/external/junit.git 33 git config --global url.http://120.92.49.206:3232/chromiumsrc/fuzzer.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git 34 git config --global url.http://120.92.49.206:3232/chromiumsrc/libjpeg_turbo.git.insteadOf https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git 35 git config --global url.http://120.92.49.206:3232/chromiumsrc/libsrtp.git.insteadOf https://chromium.googlesource.com/chromium/deps/libsrtp.git 36 git config --global url.http://120.92.49.206:3232/chromiumsrc/libvpx.git.insteadOf https://chromium.googlesource.com/webm/libvpx.git 37 git config --global url.http://120.92.49.206:3232/chromiumsrc/libyuv.git.insteadOf https://chromium.googlesource.com/libyuv/libyuv.git 38 git config --global url.http://120.92.49.206:3232/chromiumsrc/linux-syscall-support.git.insteadOf https://chromium.googlesource.com/linux-syscall-support.git 39 git config --global url.http://120.92.49.206:3232/chromiumsrc/mockito.git.insteadOf https://chromium.googlesource.com/external/mockito/mockito.git 40 git config --global url.http://120.92.49.206:3232/chromiumsrc/nasm.git.insteadOf https://chromium.googlesource.com/chromium/deps/nasm.git 41 git config --global url.http://120.92.49.206:3232/chromiumsrc/openh264.git.insteadOf https://chromium.googlesource.com/external/github.com/cisco/openh264 42 git config --global url.http://120.92.49.206:3232/chromiumsrc/requests.git.insteadOf https://chromium.googlesource.com/external/github.com/kennethreitz/requests.git 43 git config --global url.http://120.92.49.206:3232/chromiumsrc/robolectric.git.insteadOf https://chromium.googlesource.com/external/robolectric.git 44 git config --global url.http://120.92.49.206:3232/chromiumsrc/ub-uiautomator.git.insteadOf https://chromium.googlesource.com/chromium/third_party/ub-uiautomator.git 45 git config --global url.http://120.92.49.206:3232/chromiumsrc/usrsctp.git.insteadOf https://chromium.googlesource.com/external/github.com/sctplab/usrsctp 46 git config --global url.http://120.92.49.206:3232/chromiumsrc/binaries.git.insteadOf https://chromium.googlesource.com/chromium/deps/yasm/binaries.git 47 git config --global url.http://120.92.49.206:3232/chromiumsrc/patched-yasm.git.insteadOf https://chromium.googlesource.com/chromium/deps/yasm/patched-yasm.git 48 git config --global url.http://120.92.49.206:3232/chromiumsrc/tools.git.insteadOf https://chromium.googlesource.com/chromium/src/tools 49 git config --global url.http://120.92.49.206:3232/chromiumsrc/client-py.git.insteadOf https://chromium.googlesource.com/infra/luci/client-py.git 50 git config --global url.http://120.92.49.206:3232/chromiumsrc/boringssl.git.insteadOf https://boringssl.googlesource.com/boringssl.git
(第一二句改一下哈,写的是我的)
然后选择一个文件夹作为工作目录,我们所有的东西都在这里搞。然后把depot_tools拉下来
代码为:
export WORKSPACE='/mnt/d/webrtc' cd $WORKSPACE rm -rf depot_tools && git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git cd $WORKSPACE/depot_tools && git checkout gitlab chmod +x $WORKSPACE/depot_tools/cipd export PATH=$WORKSPACE/depot_tools:$PATH
然后拉取代码
代码为:
rm -rf $WORKSPACE/code && mkdir $WORKSPACE/code cd $WORKSPACE/code && gclient config --name src https://chromium.googlesource.com/external/webrtc.git@gitlab export CDS_CLANG_BUCKET_OVERRIDE=http://120.92.49.206:3232/chromiumsrc/commondatastorage/raw/master/public/chromium-browser-clang cd $WORKSPACE/code && gclient sync --patch-ref=https://chromium.googlesource.com/chromium/src/build.git@gitlab
(这个过程可能持续2个小时,因为拉取的代码有10个G)
然后生成解决方案(最好先把软件源换到阿里云,一共要通过apt-get下载960多个系统组件,你用ubuntu自带的源搞不定),而且最好切换到root,因为要用sudo,这个过程会持续一整天,如果不su,中途sudo的session过期可能导致你失败
代码为:
cd $WORKSPACE/code/src
./build/install-build-deps.sh --no-chromeos-fonts
图中的gn参数为:
cd $WORKSPACE/code/src
gn gen out/Release --args='target_os="linux" enable_iterator_debugging=false enable_profiling=false is_clang=false is_debug=false is_desktop_linux=false is_nacl_glibc=true libyuv_use_neon=true rtc_build_with_neon=true rtc_include_internal_audio_device=false rtc_include_pulse_audio=false rtc_libvpx_build_vp9=false rtc_use_gtk=false strip_absolute_paths_from_debug_symbols=true treat_warnings_as_errors=false use_aura=false use_custom_libcxx=true use_dbus=false target_sysroot="/opt/hisi-linux/x86-arm/arm-himix200-linux/target" use_gold=true use_goma=false use_lld=false use_ozone=false use_udev=false rtc_build_examples=false rtc_build_tools=false rtc_include_tests=false use_glib=false target_cpu="arm" rtc_use_x11 = false'
解决方案生成之后,需要把toolchain.ninja中的arm编译工具改为hisi的交叉编译链,然后直接编译
代码为:
cd $WORKSPACE/code/src
sudo sed -i "s/arm-linux-guneabihf/arm-himix200-linux/g" out/Release/toolchain.ninja
ninja -C out/Release
编译完成之后,可以在$WORKSPACE/code/src/out/Release/obj中找到libwebrtc.a
其实整篇文章中,精髓在gn gen的参数,这个参数需要你自己调教出来。首先有几个你必须加入
target_os="linux" target_sysroot="/opt/hisi-linux/x86-arm/arm-himix200-linux/target" target_cpu="arm" rtc_use_x11=false
如果不需要测试工程,下面的几个也可以加入
rtc_build_examples=false rtc_build_tools=false rtc_include_tests=false
其他的是我从google的论坛扒下来的(做了一些减法),不过我个人认为可能有些是不需要的,你应该先都不加,然后gn gen,如果报错,就去找到导致报错的模块,把它的编译选项关掉。下文我展示一下rtc_use_x11是怎么发掘的,给大家打个样
首先是不知道要加这个开关时,我们可以gn gen成功,但编译会报错,如下图
怎么排查问题,没别的办法,只有文件夹全局搜索
(注意,具体的调教过程可能没这么简单哈!你得稍微会一点gn)
(当然,linux下递归搜索可能要麻烦一些)
最后修改日期:2020-01-11 02:00:44
gn参数中的use_custom_libcxx要填false,然后需要把硬件浮点数运算关掉,如下图
还有一个jsoncpp它没编进去,这个比较麻烦,暂时是手动抽取编译的
最后修改日期:2020-01-16 18:39:58
如果你的编译链是arm-hisiv600-linux,则需要关闭pffft的多核,如下图
最后修改日期:2020-01-17 16:20:51