Windows 版本的 Webrtc 的编译 (  基于声网镜像 )

前期准备:

1.  操作系统

Windows 10 Preview Build 17063或之后的版本,需要命令 curl 和 tar , 以及 PowerShell 的功能

怎么验证是否支持 curl 与 tar, 打开 PowerShell

Windows 版本的 Webrtc 的编译 ( 基于声网镜像 )-LMLPHP

这个是必须要支持的,因为在 webrtc 的下载过程中,需要这些指令支持!

2.  git 的安装

git - https://git-scm.com/download/win

3.  vs2017 的安装

visualstudio2017community - https://download.visualstudio.microsoft.com/download/pr/aaebc214-bc67-4137-9bea-04fcb0c90720/2e18f27594472d0c7515d9cbe237bd56/vs_community.exe

3.1 Modify "Windows Software Development Kit" > +Debugging Tools for Windows 这个是必须的

Windows 版本的 Webrtc 的编译 ( 基于声网镜像 )-LMLPHP

 这个 Windows Phone Kits 应该有多个版本,都全部勾选上 Debugging Tools For Windows

3.2 SDK 版本的选择

这些必须选择好,否则编译过程中依赖的 LIB, INCLUDE 的就不完整,导致编译失败,比如:

AssertionError  File "C:/Users/Administrator/webrtc/src/build/toolchain/win/setup_toolchain.py", line 278, in main

assert vc_lib_atlmfc_path

4. python 的安装

python2 - https://www.python.org/downloads/release/python-2716/

4.1 pip 的安装

https://www.cnblogs.com/baiyuer/p/9606773.html

环境变量的配置

Windows 版本的 Webrtc 的编译 ( 基于声网镜像 )-LMLPHP

4.2  pywin32 模块的安装 pip install pywin32

这个模块不安装,编译过程中,会出现 “ No module named win32file ” 的错误

环境配置

1.  git 的基本配置,把下述内容保存为文件 git_env.bat 文件,等待备用

git config --global user.email "[email protected]"
git config --global user.name "freeabc"

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 https://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

2.  编译前的环境准备,把下述内容保存为文件 pre_build.bat,以备用

set GYP_DEFINES = target_arch=x64
set GYP_MSVS_VERSION=2017

set LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;F:\Windows Kits\10\Lib\10.0.17763.0\um\x64;
set INCLUDE=C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;F:\Windows Kits\10\Include\10.0.17763.0\ucrt;F:\Windows Kits\10\Include\10.0.17763.0\um;F:\Windows Kits\10\Include\10.0.17763.0\winrt;

set DEPOT_TOOLS_UPDATE=0
set GYP_MSVS_VERSION=2017
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
set GYP_DEFINES=target_arch=x64
set GYP_GENERATORS=msvs-ninja,ninja 

千万注意 LIB, INCLUDE, GYP_MSVS_OVERRIDE_PATH,GYP_MSVS_VERSION 要修改为你本地安装的实际路径,上述例子是我机器上的绝对路径!!!!!!

编译过程

1. 首先执行上述的脚本 git_env.bat

2. 下载 depot_tools

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git -b gitlab

3. 配置 depot_tools 的环境变量,见上述 4.1 中的截图

4.创建目录 webrtc

5. 打开 cmd.exe 并进入到 webrtc  目录

6. gclient config --name src https://chromium.googlesource.com/external/webrtc.git@gitlab

7. 配置环境变量

7.1 set CDS_CLANG_BUCKET_OVERRIDE=http://120.92.49.206:3232/chromiumsrc/commondatastorage/raw/master/public/chromium-browser-clang

7.2 set DEPOT_TOOLS_WIN_TOOLCHAIN=0
Windows 版本的 Webrtc 的编译 ( 基于声网镜像 )-LMLPHP Windows 版本的 Webrtc 的编译 ( 基于声网镜像 )-LMLPHP

8. 同步 path

gclient sync --patch-ref=https://chromium.googlesource.com/chromium/src/build.git@gitlab

9. 执行上述脚本 pre_build.bat

10. gn gen out/Default --ide=vs2017

11. ninja -C out/Default

如果顺利,基本可以编译通过!

Good luck!

05-10 10:20