Windows10下使用VS2019编译WebRTC

2020-04-27  本文已影响0人  继续奔跑的攻城狮

全宇宙最好的IDE,Visual Studio系列,没有之一。

操作系统

VS2019

以下可能需要自备梯子

depot_tools安装

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

depot_tools目录在D盘根目录上。

WebRTC源码

打开命令行窗口,在D盘新建个目录准备下载源代码,如下:

D:
mkdir webrtc-checkout
cd webrtc-checkout

在同一个命令行窗口里设置环境变量,你如果上面默认路径安装VS2019企业版,应该是一样的内容,其他版本相应修改下就好了。

set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
set GYP_GENERATORS=msvs-ninja,ninja

执行下面的命令开始下载代码,这是个漫长的过程,下载的文件总大小大概10G,包括源码以及一些测试的音视频文件资源等等。

fetch --nohooks webrtc
gclient sync

如果中途出错,那就继续运行 gclient sync 。
我这个挺顺利的,花了一夜时间,顺利完成。

编译

执行下面的命令,生成VS2019工程文件

cd src
gn gen --ide=vs out/Default

这一次报错了,提示如下:

Traceback (most recent call last):
File "D:/webrtc-checkout/src/build/compute_build_timestamp.py", line 127, in <module>
  sys.exit(main())
File "D:/webrtc-checkout/src/build/compute_build_timestamp.py", line 113, in main
  last_commit_timestamp = int(open(lastchange_file).read())
IOError: [Errno 2] No such file or directory: 'D:\webrtc-checkout\src\build\util\LASTCHANGE.committime'
ERROR at //build/timestamp.gni:31:19: Script returned non-zero exit code.
build_timestamp = exec_script(compute_build_timestamp,
       ^----------
Current dir: D:/webrtc-checkout/src/out/Default/
Command: D:/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe D:/webrtc-checkout/src/build/compute_build_timestamp.py default
Returned 1.
See //build/config/win/BUILD.gn:10:1: whence it was imported.
import("//build/timestamp.gni")
^-----------------------------
See //build/config/BUILDCONFIG.gn:446:5: which caused the file to be included.
"//build/config/win:default_crt",
^-------------------------------

执行下面的命令,就可以修复,注意检查src目录下的build\util\LASTCHANGE是否存在,没有就继续运行源代码下载。

D:\webrtc-checkout\src>python build\util\lastchange.py build\util\LASTCHANGE

再次运行

D:\webrtc-checkout\src>gn gen --ide=vs out/Default
Generating Visual Studio projects took 2261ms
Done. Made 1083 targets from 229 files in 20181ms

生成的项目文件是 D:\webrtc-checkout\src\out\Default 目录下的 all.sln ,可以用VS2019打开。放个图。


vs打开webrtc项目

后面编译还没写。。。

上一篇 下一篇

猜你喜欢

热点阅读