WebRTC编译

文章目录

  • 环境配置
  • 编译
    • Linux
    • Android
    • iOS/macOS
    • Windows
  • 附录-依赖及镜像列表
  • UWP 工程编译
  • 编译前提

环境配置

一定要把该内容看完,不然会出错

运行以下脚本,替换 git 源

git config --global user.email ""
git config --global user.name ""

git config --global url.http://120.92.49.206:3232/chromiumsrc/webrtc.git.insteadOf https://chromium.googlesource.com/external/webrtc.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/base.git.insteadOf https://chromium.googlesource.com/chromium/src/base
git config --global url.http://120.92.49.206:3232/chromiumsrc/build.git.insteadOf https://chromium.googlesource.com/chromium/src/build
git config --global url.http://120.92.49.206:3232/chromiumsrc/buildtools.git.insteadOf https://chromium.googlesource.com/chromium/src/buildtools
git config --global url.http://120.92.49.206:3232/chromiumsrc/gradle.git.insteadOf https://chromium.googlesource.com/external/github.com/gradle/gradle.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/ios.git.insteadOf sudo apt-get install gcc-multilib g++-multilibhttps://chromium.googlesource.com/chromium/src/ios.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/testing.git.insteadOf https://chromium.googlesource.com/chromium/src/testing
git config --global url.http://120.92.49.206:3232/chromiumsrc/third_party.git.insteadOf https://chromium.googlesource.com/chromium/src/third_party
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
git config --global url.http://120.92.49.206:3232/chromiumsrc/libcxx.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/libcxx.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/libcxxabi.git.insteadOf https://chromium.googlesource.com/chromium/llvm-project/libcxxabi.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/libunwind.git.insteadOf https://chromium.googlesource.com/external/llvm.org/libunwind.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/android_ndk.git.insteadOf https://chromium.googlesource.com/android_ndk.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/android_tools.git.insteadOf https://chromium.googlesource.com/android_tools.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/auto.git.insteadOf https://chromium.googlesource.com/external/github.com/google/auto.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/catapult.git.insteadOf https://chromium.googlesource.com/catapult.git
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
git config --global url.http://120.92.49.206:3232/chromiumsrc/colorama.git.insteadOf https://chromium.googlesource.com/external/colorama.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/depot_tools.git.insteadOf https://chromium.googlesource.com/chromium/tools/depot_tools.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/errorprone.git.insteadOf https://chromium.googlesource.com/chromium/third_party/errorprone.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/ffmpeg.git.insteadOf https://chromium.googlesource.com/chromium/third_party/ffmpeg.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/findbugs.git.insteadOf https://chromium.googlesource.com/chromium/deps/findbugs.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/freetype2.git.insteadOf https://chromium.googlesource.com/chromium/src/third_party/freetype2.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/harfbuzz.git.insteadOf https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git
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
git config --global url.http://120.92.49.206:3232/chromiumsrc/googletest.git.insteadOf https://chromium.googlesource.com/external/github.com/google/googletest.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/icu.git.insteadOf https://chromium.googlesource.com/chromium/deps/icu.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/jsr-305.git.insteadOf https://chromium.googlesource.com/external/jsr-305.git
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
git config --global url.http://120.92.49.206:3232/chromiumsrc/junit.git.insteadOf https://chromium.googlesource.com/external/junit.git
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
git config --global url.http://120.92.49.206:3232/chromiumsrc/libjpeg_turbo.git.insteadOf https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/libsrtp.git.insteadOf https://chromium.googlesource.com/chromium/deps/libsrtp.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/libvpx.git.insteadOf https://chromium.googlesource.com/webm/libvpx.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/libyuv.git.insteadOf https://chromium.googlesource.com/libyuv/libyuv.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/linux-syscall-support.git.insteadOf https://chromium.googlesource.com/linux-syscall-support.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/mockito.git.insteadOf https://chromium.googlesource.com/external/mockito/mockito.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/nasm.git.insteadOf https://chromium.googlesource.com/chromium/deps/nasm.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/openh264.git.insteadOf https://chromium.googlesource.com/external/github.com/cisco/openh264
git config --global url.http://120.92.49.206:3232/chromiumsrc/requests.git.insteadOf https://chromium.googlesource.com/external/github.com/kennethreitz/requests.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/robolectric.git.insteadOf https://chromium.googlesource.com/external/robolectric.git
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
git config --global url.http://120.92.49.206:3232/chromiumsrc/usrsctp.git.insteadOf https://chromium.googlesource.com/external/github.com/sctplab/usrsctp
git config --global url.http://120.92.49.206:3232/chromiumsrc/binaries.git.insteadOf https://chromium.googlesource.com/chromium/deps/yasm/binaries.git
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
git config --global url.http://120.92.49.206:3232/chromiumsrc/tools.git.insteadOf https://chromium.googlesource.com/chromium/src/tools
git config --global url.http://120.92.49.206:3232/chromiumsrc/client-py.git.insteadOf https://chromium.googlesource.com/infra/luci/client-py.git
git config --global url.http://120.92.49.206:3232/chromiumsrc/boringssl.git.insteadOf https://boringssl.googlesource.com/boringssl.git

指定同步目录

#指定当前目录为同步目录,也可以指定其他路径
export WORKSPACE=`pwd`

安装depot_tools

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=$PATH:$WORKSPACE/depot_tools

同步WebRTC

rm -rf $WORKSPACE/webrtc && mkdir $WORKSPACE/webrtc
cd $WORKSPACE/webrtc && 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 ~/depot_tools; git fetch; git reset --hard origin/gitlab; chmod +x ~/depot_tools/cipd

cd $WORKSPACE/webrtc && gclient sync --patch-ref=https://chromium.googlesource.com/chromium/src/build.git@gitlab

编译

Linux

apt-get update
apt-get install -y g++

export PATH=$PATH:$WORKSPACE/depot_tools

cd $WORKSPACE/webrtc/src

./build/install-build-deps.sh --no-chromeos-fonts

gn gen out/Release "--args=is_debug=false"

ninja -C out/Release

Android

# 安装依赖
apt-get install -y software-properties-common
add-apt-repository -y ppa:openjdk-r/ppa

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


# 添加安卓平台
cd $WORKSPACE/webrtc
echo "target_os = [ 'android' ]" >>.gclient


# 同步
export PATH=$PATH:$WORKSPACE/depot_tools
export CDS_CLANG_BUCKET_OVERRIDE=http://120.92.49.206:3232/chromiumsrc/commondatastorage/raw/master/public/chromium-browser-clang

cd $WORKSPACE/webrtc && gclient sync --patch-ref=https://chromium.googlesource.com/chromium/src/build.git@gitlab


# 编译
cd $WORKSPACE/webrtc/src

gn gen android/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"arm64\""

ninja -C android/Release

iOS/macOS

export PATH=$PATH:$WORKSPACE/depot_tools

export CDS_CLANG_BUCKET_OVERRIDE=https://chromiumsrc.gitlab.io/commondatastorage/chromium-browser-clang
git.sh

# 安装depot_tools
cd $WORKSPACE
rm -rf depot_tools && git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_tools

cd $WORKSPACE/depot_tools && git checkout gitlab
chmod +x $WORKSPACE/depot_tools/cipd


cd $WORKSPACE
rm -rf $WORKSPACE/webrtc && mkdir $WORKSPACE/webrtc

cd $WORKSPACE/webrtc && \
gclient config --name src https://chromium.googlesource.com/external/webrtc.git@gitlab

cd $WORKSPACE/webrtc && \
gclient sync\
 --patch-ref=https://chromium.googlesource.com/chromium/src/build.git@gitlab


sudo xcode-select -s /Applications/Xcode.app/Contents/Developer


cd $WORKSPACE/webrtc/src && \
gn gen out/Release "--args=is_debug=false"

cd $WORKSPACE/webrtc/src && \
ninja -C out/Release

Windows

#安装依赖
1. git - https://git-scm.com/download/win

2. visualstudio2017community - https://download.visualstudio.microsoft.com/download/pr/aaebc214-bc67-4137-9bea-04fcb0c90720/2e18f27594472d0c7515d9cbe237bd56/vs_community.exe
> 2.1 Modify "Windows Software Development Kit" > +Debugging Tools for Windows

3. python2 - https://www.python.org/downloads/release/python-2716/
> 3.1 pip install pywin32

#设置
1. 执行git.sh

#安装depot_tools
cd %USERPROFILE%
rd /s /q depot_tools webrtc & git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git -b gitlab

#配置
set PATH=%PATH%;%USERPROFILE%\depot_tools

cd %USERPROFILE% && ^
rd /s /q webrtc & mkdir webrtc

cd %USERPROFILE%\webrtc && ^
gclient config --name src https://chromium.googlesource.com/external/webrtc.git@gitlab

#同步
set CDS_CLANG_BUCKET_OVERRIDE=http://120.92.49.206:3232/chromiumsrc/commondatastorage/raw/master/public/chromium-browser-clang
set DEPOT_TOOLS_WIN_TOOLCHAIN=0

cd %USERPROFILE%\webrtc && ^
gclient sync --patch-ref=https://chromium.googlesource.com/chromium/src/build.git@gitlab

#生成
cd %USERPROFILE%\webrtc\src &&& ^
gn gen out/Release "--args=is_debug=false"

#编译
cd %USERPROFILE%\webrtc\src && ^
ninja -C out/Release

附录-依赖及镜像列表

整个开源WebRTC编译时需要下载的依赖列表

https://chromium.googlesource.com/chromium/src/base
https://chromium.googlesource.com/chromium/src/build
https://chromium.googlesource.com/chromium/src/buildtools
https://chromium.googlesource.com/external/github.com/gradle/gradle
https://chromium.googlesource.com/chromium/src/ios
https://chromium.googlesource.com/chromium/src/testing
https://chromium.googlesource.com/chromium/src/third_party
https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format
https://chromium.googlesource.com/chromium/llvm-project/libcxx
https://chromium.googlesource.com/chromium/llvm-project/libcxxabi
https://chromium.googlesource.com/external/llvm.org/libunwind
https://chromium.googlesource.com/android_ndk
https://chromium.googlesource.com/android_tools
https://chromium.googlesource.com/external/github.com/google/auto
https://chromium.googlesource.com/catapult
https://chromium.googlesource.com/external/github.com/google/compact_enc_det
https://chromium.googlesource.com/external/colorama https://chromium.googlesource.com/chromium/tools/depot_tools
https://chromium.googlesource.com/chromium/third_party/errorprone
https://chromium.googlesource.com/chromium/third_party/ffmpeg
https://chromium.googlesource.com/chromium/deps/findbugs
https://chromium.googlesource.com/chromium/src/third_party/freetype2
https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz
https://chromium.googlesource.com/external/github.com/google/gtest-parallel
https://chromium.googlesource.com/external/github.com/google/googletest
https://chromium.googlesource.com/chromium/deps/icu
https://chromium.googlesource.com/external/jsr-305
https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp
https://chromium.googlesource.com/external/junit
https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer
https://chromium.googlesource.com/chromium/deps/libjpeg_turbo
https://chromium.googlesource.com/chromium/deps/libsrtp
https://chromium.googlesource.com/webm/libvpx
https://chromium.googlesource.com/libyuv/libyuv
https://chromium.googlesource.com/linux-syscall-support
https://chromium.googlesource.com/external/mockito/mockito
https://chromium.googlesource.com/chromium/deps/nasm
https://chromium.googlesource.com/external/github.com/cisco/openh264
https://chromium.googlesource.com/external/github.com/kennethreitz/requests
https://chromium.googlesource.com/external/robolectric
https://chromium.googlesource.com/chromium/third_party/ub-uiautomator
https://chromium.googlesource.com/external/github.com/sctplab/usrsctp
https://chromium.googlesource.com/chromium/deps/yasm/binaries
https://chromium.googlesource.com/chromium/deps/yasm/patched-yasm
https://chromium.googlesource.com/chromium/src/tools
https://chromium.googlesource.com/infra/luci/client-py

系统官方国内镜像列表

http://mirrors.aliyun.com/ubuntu/

本地镜像

https://120.92.49.206:3232/chromiumsrc/base.git
https://120.92.49.206:3232/chromiumsrc/build.git
https://120.92.49.206:3232/chromiumsrc/buildtools.git
https://120.92.49.206:3232/chromiumsrc/gradle.git
https://120.92.49.206:3232/chromiumsrc/ios.git
https://120.92.49.206:3232/chromiumsrc/testing.git
https://120.92.49.206:3232/chromiumsrc/third_party.git
https://120.92.49.206:3232/chromiumsrc/clang-format.git
https://120.92.49.206:3232/chromiumsrc/libcxx.git
https://120.92.49.206:3232/chromiumsrc/libcxxabi.git
https://120.92.49.206:3232/chromiumsrc/libunwind.git
https://120.92.49.206:3232/chromiumsrc/android_ndk.git
https://120.92.49.206:3232/chromiumsrc/android_tools.git
https://120.92.49.206:3232/chromiumsrc/auto.git
https://120.92.49.206:3232/chromiumsrc/catapult.git
https://120.92.49.206:3232/chromiumsrc/compact_enc_det.git
https://120.92.49.206:3232/chromiumsrc/colorama.git
https://120.92.49.206:3232/chromiumsrc/depot_tools.git
https://120.92.49.206:3232/chromiumsrc/errorprone.git
https://120.92.49.206:3232/chromiumsrc/ffmpeg.git
https://120.92.49.206:3232/chromiumsrc/findbugs.git
https://120.92.49.206:3232/chromiumsrc/freetype2.git
https://120.92.49.206:3232/chromiumsrc/harfbuzz.git
https://120.92.49.206:3232/chromiumsrc/gtest-parallel.git
https://120.92.49.206:3232/chromiumsrc/googletest.git
https://120.92.49.206:3232/chromiumsrc/icu.git
https://120.92.49.206:3232/chromiumsrc/jsr-305.git
https://120.92.49.206:3232/chromiumsrc/jsoncpp.git
https://120.92.49.206:3232/chromiumsrc/junit.git
https://120.92.49.206:3232/chromiumsrc/fuzzer.git
https://120.92.49.206:3232/chromiumsrc/libjpeg_turbo.git
https://120.92.49.206:3232/chromiumsrc/libsrtp.git
https://120.92.49.206:3232/chromiumsrc/libvpx.git
https://120.92.49.206:3232/chromiumsrc/libyuv.git
https://120.92.49.206:3232/chromiumsrc/linux-syscall-support.git
https://120.92.49.206:3232/chromiumsrc/mockito.git
https://120.92.49.206:3232/chromiumsrc/nasm.git
https://120.92.49.206:3232/chromiumsrc/openh264.git
https://120.92.49.206:3232/chromiumsrc/requests.git
https://120.92.49.206:3232/chromiumsrc/robolectric.git
https://120.92.49.206:3232/chromiumsrc/ub-uiautomator.git
https://120.92.49.206:3232/chromiumsrc/usrsctp.git
https://120.92.49.206:3232/chromiumsrc/binaries.git
https://120.92.49.206:3232/chromiumsrc/patched-yasm.git
https://120.92.49.206:3232/chromiumsrc/tools.git
https://120.92.49.206:3232/chromiumsrc/client-py.git

如果遇到不能下载,请检查是否设置了不可用代理,或者限制了端口。

UWP 工程编译

下载:https://github.com/webrtc-uwp
下载过程可以,单个模块下载,然后再整合成完成的工程
https://github.com/webrtc-uwp/webrtc-uwp-sdk/tree/James/m71-releasenotes 此分支个人已经编译成功

准备以下.exe  clang-format.exe  gn.exe  nuget.exe
clang-format.exe       gn.exe 两个文件放到  webrtc-uwp-sdk\webrtc\xplatform\buildtools\win
nuget.exe                     文件放到      webrtc-uwp-sdk\webrtc\windows\nuget

exe下载路径: https://github.com/ShifengJin/exe-for-webrtc_for_uwp

编译前提

git 安装    vs2017或vs2019 python2.7
编译选项 
gn gen out/x64/Debug "--args=is_debug=true target_os=\"linux\" target_cpu=\"x64\" use_custom_libcxx=false is_clang=false rtc_enable_protobuf=false treat_warnings_as_errors=false rtc_include_tests=false is_component_build=false"

ninja -C out/x64/Debug

编译x86时,出现以下问题
bits/c++config.h找不到
sudo apt-get install gcc-multilib g++-multilib

打开以下文件:
webrtc/src/modules/audio_processing/echo_detector/mean_variance_estimator.cc
webrtc/src/modules/audio_processing/echo_detector/normalized_covariance_estimator.cc
在以上的两个文件中 找到 isfinite 修改为  std::isfinite

你可能感兴趣的:(工程类,工程)