项目作者: webrtc-mirror

项目描述 :
WebRTC编译国内加速镜像
高级语言:
项目地址: git://github.com/webrtc-mirror/mirror.git
创建时间: 2019-08-28T09:16:49Z
项目社区:https://github.com/webrtc-mirror/mirror

开源协议:

下载


webrtc-mirror

WebRTC国内加速镜像 https://github.com/webrtc-mirror/mirror

项目背景

在进行WebRTC开发的时候经常需要编译WebRTC,但由于WebRTC依赖较多(十几个G), 而且大多数内容需要翻墙。 我们尝试了多种加速编译的方法,最终找到一个对WebRTC代码没有任何侵入的镜像方案。
相信行业内的很多人都体验过WebRTC编译的痛苦,尤其是新接触WebRTC的人,我们决定提供这个WebRTC镜像的方案。快乐自己造福大家。

原理

WebRTC的依赖主要分为三类:

1,放在git中的代码,这部分大概有三十多个仓库, gcient sync 会把这些git仓库的历史记录都拉下来,所以有的厂库会非常大,这些代码大都在google code上, 在镜像的时候我们把这些git代码同步到了gitlab, 之所以放到gitlab上是因为github上对仓库大小会做限制,导致有些代码同步不成功。这些依赖会10分钟同步一次,保持跟google code上代码仓库保持一致。

2,cipd的模块代码, 这部分代码放在appspot.com上面,这部分代码不好做镜像,可以通过采用http代理的方式来进行下载。

3,google storage上的依赖, google storage上的内容非常庞大, 不好做镜像, 可以通过采用http代理的方式进行下载。

在同步WebRTC的依赖过程中,git中的代码会从gitlab相对应的仓库中拉取, 不好镜像的部分我们提供了http代理进行下载。

镜像说明

  • 对WebRTC源码不做任何修改
  • 每十分钟和官方代码同步一次

感谢

编译步骤

替换git仓库地址

  1. git config --global url.https://gitlab.com/webrtc-mirror/webrtc.git.insteadOf https://chromium.googlesource.com/external/webrtc.git
  2. git config --global url.https://gitlab.com/webrtc-mirror/base.git.insteadOf https://chromium.googlesource.com/chromium/src/base
  3. git config --global url.https://gitlab.com/webrtc-mirror/build.git.insteadOf https://chromium.googlesource.com/chromium/src/build
  4. git config --global url.https://gitlab.com/webrtc-mirror/buildtools.git.insteadOf https://chromium.googlesource.com/chromium/src/buildtools
  5. git config --global url.https://gitlab.com/webrtc-mirror/gradle.git.insteadOf https://chromium.googlesource.com/external/github.com/gradle/gradle.git
  6. git config --global url.https://gitlab.com/webrtc-mirror/ios.git.insteadOf https://chromium.googlesource.com/chromium/src/ios.git
  7. git config --global url.https://gitlab.com/webrtc-mirror/testing.git.insteadOf https://chromium.googlesource.com/chromium/src/testing
  8. git config --global url.https://gitlab.com/webrtc-mirror/third_party.git.insteadOf https://chromium.googlesource.com/chromium/src/third_party
  9. git config --global url.https://gitlab.com/webrtc-mirror/clang-format.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format.git
  10. git config --global url.https://gitlab.com/webrtc-mirror/libcxx.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/libcxx.git
  11. git config --global url.https://gitlab.com/webrtc-mirror/libcxxabi.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/libcxxabi.git
  12. git config --global url.https://gitlab.com/webrtc-mirror/libunwind.git.insteadOf https://chromium.googlesource.com/external/llvm.org/libunwind.git
  13. git config --global url.https://gitlab.com/webrtc-mirror/android_ndk.git.insteadOf https://chromium.googlesource.com/android_ndk.git
  14. git config --global url.https://gitlab.com/webrtc-mirror/android_tools.git.insteadOf https://chromium.googlesource.com/android_tools.git
  15. git config --global url.https://gitlab.com/webrtc-mirror/auto.git.insteadOf https://chromium.googlesource.com/external/github.com/google/auto.git
  16. git config --global url.https://gitlab.com/webrtc-mirror/catapult.git.insteadOf https://chromium.googlesource.com/catapult.git
  17. git config --global url.https://gitlab.com/webrtc-mirror/compact_enc_det.git.insteadOf https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git
  18. git config --global url.https://gitlab.com/webrtc-mirror/colorama.git.insteadOf https://chromium.googlesource.com/external/colorama.git
  19. git config --global url.https://gitlab.com/webrtc-mirror/depot_tools.git.insteadOf https://chromium.googlesource.com/chromium/tools/depot_tools.git
  20. git config --global url.https://gitlab.com/webrtc-mirror/errorprone.git.insteadOf https://chromium.googlesource.com/chromium/third_party/errorprone.git
  21. git config --global url.https://gitlab.com/webrtc-mirror/ffmpeg.git.insteadOf https://chromium.googlesource.com/chromium/third_party/ffmpeg.git
  22. git config --global url.https://gitlab.com/webrtc-mirror/findbugs.git.insteadOf https://chromium.googlesource.com/chromium/deps/findbugs.git
  23. git config --global url.https://gitlab.com/webrtc-mirror/freetype2.git.insteadOf https://chromium.googlesource.com/chromium/src/third_party/freetype2.git
  24. git config --global url.https://gitlab.com/webrtc-mirror/harfbuzz.git.insteadOf https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git
  25. git config --global url.https://gitlab.com/webrtc-mirror/gtest-parallel.git.insteadOf https://chromium.googlesource.com/external/github.com/google/gtest-parallel
  26. git config --global url.https://gitlab.com/webrtc-mirror/googletest.git.insteadOf https://chromium.googlesource.com/external/github.com/google/googletest.git
  27. git config --global url.https://gitlab.com/webrtc-mirror/icu.git.insteadOf https://chromium.googlesource.com/chromium/deps/icu.git
  28. git config --global url.https://gitlab.com/webrtc-mirror/jsr-305.git.insteadOf https://chromium.googlesource.com/external/jsr-305.git
  29. git config --global url.https://gitlab.com/webrtc-mirror/jsoncpp.git.insteadOf https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp.git
  30. git config --global url.https://gitlab.com/webrtc-mirror/junit.git.insteadOf https://chromium.googlesource.com/external/junit.git
  31. git config --global url.https://gitlab.com/webrtc-mirror/fuzzer.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git
  32. git config --global url.https://gitlab.com/webrtc-mirror/libjpeg_turbo.git.insteadOf https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git
  33. git config --global url.https://gitlab.com/webrtc-mirror/libsrtp.git.insteadOf https://chromium.googlesource.com/chromium/deps/libsrtp.git
  34. git config --global url.https://gitlab.com/webrtc-mirror/libvpx.git.insteadOf https://chromium.googlesource.com/webm/libvpx.git
  35. git config --global url.https://gitlab.com/webrtc-mirror/libyuv.git.insteadOf https://chromium.googlesource.com/libyuv/libyuv.git
  36. git config --global url.https://gitlab.com/webrtc-mirror/linux-syscall-support.git.insteadOf https://chromium.googlesource.com/linux-syscall-support.git
  37. git config --global url.https://gitlab.com/webrtc-mirror/mockito.git.insteadOf https://chromium.googlesource.com/external/mockito/mockito.git
  38. git config --global url.https://gitlab.com/webrtc-mirror/nasm.git.insteadOf https://chromium.googlesource.com/chromium/deps/nasm.git
  39. git config --global url.https://gitlab.com/webrtc-mirror/openh264.git.insteadOf https://chromium.googlesource.com/external/github.com/cisco/openh264
  40. git config --global url.https://gitlab.com/webrtc-mirror/requests.git.insteadOf https://chromium.googlesource.com/external/github.com/kennethreitz/requests.git
  41. git config --global url.https://gitlab.com/webrtc-mirror/robolectric.git.insteadOf https://chromium.googlesource.com/external/robolectric.git
  42. git config --global url.https://gitlab.com/webrtc-mirror/ub-uiautomator.git.insteadOf https://chromium.googlesource.com/chromium/third_party/ub-uiautomator.git
  43. git config --global url.https://gitlab.com/webrtc-mirror/usrsctp.git.insteadOf https://chromium.googlesource.com/external/github.com/sctplab/usrsctp
  44. git config --global url.https://gitlab.com/webrtc-mirror/binaries.git.insteadOf https://chromium.googlesource.com/chromium/deps/yasm/binaries.git
  45. git config --global url.https://gitlab.com/webrtc-mirror/patched-yasm.git.insteadOf https://chromium.googlesource.com/chromium/deps/yasm/patched-yasm.git
  46. git config --global url.https://gitlab.com/webrtc-mirror/tools.git.insteadOf https://chromium.googlesource.com/chromium/src/tools
  47. git config --global url.https://gitlab.com/webrtc-mirror/client-py.git.insteadOf https://chromium.googlesource.com/infra/luci/client-py.git
  48. git config --global url.https://gitlab.com/webrtc-mirror/boringssl.git.insteadOf https://boringssl.googlesource.com/boringssl.git

安装depot_tools

  1. export WORKSPACE=$(pwd)
  2. git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
  3. export PATH=$WORKSPACE/depot_tools:$PATH

配置http和https代理

  1. // http和https代理服务,因为是代理外网服务,有可能出现间歇性的不稳定,如果不工作可以提issuse
  2. // 请不要滥用该http和https代理服务,后面会加上黑名单服务
  3. export http_proxy=http://39.105.13.136:8080
  4. export https_proxy=http://39.105.13.136:8080

同步WebRTC

  1. gclient config --name src https://chromium.googlesource.com/external/webrtc.git
  2. gclient sync

编译WebRTC

mac平台

  1. cd src
  2. // 可以加入其它的编译参数
  3. gn gen out/mac --args='is_debug=false target_cpu="x64" rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false'
  4. // mac_framework_objc 为framework, 可以为其它的target
  5. ninja -C out/mac mac_framework_objc

iOS平台

  1. cd src
  2. python tools_webrtc/ios/build_ios_libs.py --output-dir out/ios --arch arm64 --extra-gn-args rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false

Linux平台

  1. cd src
  2. // 安装依赖
  3. bash build/install-build-deps.sh
  4. // 可以加入其它的编译参数
  5. gn gen out/linux --args='is_debug=false target_cpu="x64" rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false'
  6. ninja -C out/linux

Android 平台(须在linux平台上编译)

  1. # 添加安卓平台
  2. echo "target_os = [ 'android' ]" >> .gclient
  3. gclient sync
  4. cd src
  5. // 安装android依赖
  6. ./build/install-build-deps-android.sh
  7. python tools_webrtc/android/build_aar.py --build-dir out/android --arch armeabi-v7a --extra-gn-args rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false

Windows 平台

  1. gn gen out/Win --args='proprietary_codecs=true is_debug=false target_cpu="x86" ffmpeg_branding="Chrome" rtc_include_tests=false'
  2. ninja -C out/Win

清空http和https代理

由于对http和https代理做了相应的白名单处理, 使用该http代理后访问其它的网站会被禁止, 在编译完WebRTC需要把http和https代理设置为空

  1. export http_proxy=''
  2. export https_proxy=''

注意

  • 为了加快下载和编译我们目前禁止掉了测试文件的下载, 所以在编译的时候请加上 rtc_include_tests=false
  • 为了节省代理流量,我们对通过代理的域名进行了过滤,只允许WebRTC相关域名通过