配置如下:
- GYP_MSVS_VERSION设置VisualStudio的版本为2017
- DEPOT_TOOLS_WIN_TOOLCHAIN设置不依赖Depot内置内置的工具链(Tool Chain)
- 较新版本的WebRTC使用Python3.8,老版本的使用Python2.7,需要在此之前配置好
export GYP_MSVS_VERSION=2017
export DEPOT_TOOLS_WIN_TOOLCHAIN=0
gn gen out/win --args='
target_os = "win"
target_cpu = "x86"
is_debug = false
rtc_enable_protobuf = false
rtc_libvpx_build_vp9 = false
rtc_use_h264 = true
rtc_use_openmax_dl = false
rtc_enable_sctp = false
rtc_include_tests = false
use_cxx11 = false
' --ide=vs2017
fetch错误
使用fetch下载Windows平台WebRTC代码的时候遇到了如下错误
The system cannot find the file C:\Users\stoneliu\Desktop\depot_tools\python3_bin_reldir.txt.
[E2021-12-30T11:28:59.735399+08:00 11572 0 annotate.go:273] goroutine 1:
#0 go.chromium.org/luci/vpython/venv/config.go:309 - venv.(*Config).resolvePythonInterpreter()
reason: none of [C:\Users\stoneliu\Desktop\depot_tools\\\python3.exe] matched specification 3.8.0
#1 go.chromium.org/luci/vpython/venv/config.go:153 - venv.(*Config).resolveRuntime()
reason: failed to resolve system Python interpreter
#2 go.chromium.org/luci/vpython/venv/venv.go:143 - venv.With()
reason: failed to resolve python runtime
#3 go.chromium.org/luci/vpython/run.go:60 - vpython.Run()
#4 go.chromium.org/luci/vpython/application/application.go:327 - application.(*application).mainImpl()
#5 go.chromium.org/luci/vpython/application/application.go:416 - application.(*Config).Main.func1()
#6 go.chromium.org/luci/vpython/application/support.go:46 - application.run()
#7 go.chromium.org/luci/vpython/application/application.go:415 - application.(*Config).Main()
#8 vpython/main.go:112 - main.mainImpl()
#9 vpython/main.go:118 - main.main()
#10 runtime/proc.go:225 - runtime.main()
#11 runtime/asm_amd64.s:1371 - runtime.goexit()
方案一(不推荐)
这个是因为我使用的是Win10系统,而且Python是从AppStore下载的,depot_tools没能识别到Python的路径导致的。方案一就是手动指定,不推荐这样的做法。
#!/usr/bin/env bash
function bootstrap_python3 {
base_dir=$(dirname "${BASH_SOURCE[0]}")
cd "${base_dir}"
# if [ -e ".bleeding_edge" ]; then
# CIPD_MANIFEST="bootstrap/manifest_bleeding_edge.txt"
# else
# CIPD_MANIFEST="bootstrap/manifest.txt"
# fi
# while IFS= read -r line; do
# if [[ $line =~ ^[^#].*cpython3/.*version:(.*)$ ]]; then
# PYTHON3_VERSION=${BASH_REMATCH[1]}
# PYTHON3_VERSION=${PYTHON3_VERSION//[[:space:]]/}
# fi
# done < $CIPD_MANIFEST
# if [ "X$PYTHON3_VERSION" == "X" ]; then
# echo Could not extract Python 3 version from manifest.
# return 1
# fi
# BOOTSTRAP_PATH="bootstrap-${PYTHON3_VERSION}_bin"
# # Install CIPD packages. The CIPD client self-bootstraps.
# "cipd" ensure -log-level warning -ensure-file "${CIPD_MANIFEST}" \
# -root "$BOOTSTRAP_PATH"
# BOOTSTRAP_PYTHON_BIN="${BOOTSTRAP_PATH}/python3/bin/python3"
BOOTSTRAP_PYTHON_BIN="C:\Users\stoneliu\AppData\Local\Microsoft\WindowsApps\python"
"$BOOTSTRAP_PYTHON_BIN" "bootstrap/bootstrap.py" --bootstrap-name "$BOOTSTRAP_PATH"
cd - > /dev/null
}
方案二
让depot_tools自动下载它需要的Python库。打开depot_tools/bootstrap文件夹,点击执行win_tools.bat
脚本,它就会下载所需的Python到depot_tools适合的目录了
获取VS信息错误
使用gn gen
去生成.ninja
文件的时候遇到如下错误
ERROR at dynamically parsed input that //build/config/win/visual_studio_version.gni:27:7 loaded :7:3: This is not a valid number.
[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
-^
See //build/config/win/BUILD.gn:11:1: whence it was imported.
import("//build/config/win/visual_studio_version.gni")
^----------------------------------------------------
See //build/config/BUILDCONFIG.gn:357:5: which caused the file to be included.
"//build/config/win:unicode",
^---------------------------
[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
于是查看对应的代码,发现是在获取vs信息(exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
)的时候遇到了错误
if (visual_studio_path == "") {
toolchain_data =
exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
visual_studio_path = toolchain_data.vs_path
windows_sdk_path = toolchain_data.sdk_path
visual_studio_version = toolchain_data.vs_version
wdk_path = toolchain_data.wdk_dir
visual_studio_runtime_dirs = toolchain_data.runtime_dirs
} else {
assert(visual_studio_version != "",
"You must set the visual_studio_version if you set the path")
assert(wdk_path != "",
"You must set the wdk_path if you set the visual studio path")
visual_studio_runtime_dirs = []
}
于是在终端单独执行这个脚本python build/vs_toolchain.py get_toolchain_dir
输出信息如下,说明是能正确的获取到当前vs信息的,但是多了一行信息[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
,是解析这个语句出错导致的。
vs_path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community"
sdk_path = "C:\\Program Files (x86)\\Windows Kits\\10"
vs_version = "2022"
wdk_dir = ""
runtime_dirs = "C:\\Windows\\System32;C:\\Windows\\SysWOW64;Arm64Unused"
[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
解决方案
升级Win10以后在终端下执行一些命名会多一条这样的[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
信息在输出内容之后,exec_script
在解析输出内容的时候报错了,解决方案就是不让它输出多余的信息。解决方案就是修改注册表。
- 路径:
\HKEY_LOCAL_MACHINE\SOFTWARE\TEC\Ocular.3\agent\config
- 字段:
hookapi_filterproc_external
- 内容:如果该字段已经存在,在该字段的最后追加Python相关的可执行即可(
;python.exe;python3.8.exe
)
Windows 10 SDK
因为是新的电脑,所以不存在Windows 10 SDK,于是报了如下错误
Traceback (most recent call last):
File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 585, in <module>
sys.exit(main())
File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 581, in main
return commands[sys.argv[1]](*sys.argv[2:])
File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 412, in CopyDlls
_CopyDebugger(target_dir, target_cpu)
File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 445, in _CopyDebugger
raise Exception('%s not found in "%s"\r\nYou must install'
Exception: dbghelp.dll not found in "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\dbghelp.dll"
You must installWindows 10 SDK version 10.0.19041.0 including the "Debugging Tools for Windows" feature.
ERROR at //build/toolchain/win/BUILD.gn:55:3: Script returned non-zero exit code.
exec_script("../../vs_toolchain.py",
^----------
Current dir: C:/Users/stoneliu/Desktop/chromium/src/out/win/
Command: C:/Users/stoneliu/AppData/Local/Microsoft/WindowsApps/python3.exe C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py copy_dlls C:/Users/stoneliu/Desktop/chromium/src/out/win Release x86
Returned 1 and printed out:
Copying C:\Windows\SysWOW64\msvcp140.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\msvcp140.dll...
Copying C:\Windows\SysWOW64\vccorlib140.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\vccorlib140.dll...
Copying C:\Windows\SysWOW64\vcruntime140.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\vcruntime140.dll...
Copying C:\Windows\SysWOW64\ucrtbase.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\ucrtbase.dll...
解决方案
下载安装Windows 10 SDK即可,下载链接。