chromium 00 浏览器编译 vs2017 win10

01 阅读官方文档

https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md

一个中文翻译文档:https://blog.csdn.net/Vincent95/article/details/78469807

02 安装python2.7.*

depot_tools需要使用python2.7。
https://www.python.org/ftp/python/2.7.15/python-2.7.15.amd64.msi

03 配置 depot_tools

下载depot_tools,加压到d:\git\chromium\depot_tools,并把d:\git\chromium\depot_tools加入环境变量。
https://storage.googleapis.com/chrome-infra/depot_tools.zip
把depot_tools的路径加到 PATH 环境变量的最前面,至少要加到python环境变量的前面

04 配置必要的信息

设置git全局配置信息

# user.name 和 user.email 需要使用自己的。
git config --global user.name "5455945"
git config --global user.email "5455945@gmail.com"
git config --global core.autocrlf false
git config --global core.filemode false
git config --global branch.autosetuprebase always

# 这个可以在系统环境变量里面设置,也可以在命令行窗口设置
set GYP_MSVS_VERSION=2017
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_MSVS_OVERRIDE_PATH="D:\install\Microsoft Visual Studio\2017\Community"

05 下载代码

参考:
https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#Using-the-Visual-Studio-IDE

https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/contributing.md

http://www.chromium.org/developers/how-tos/get-the-code/working-with-release-branches

https://chromium.googlesource.com/chromiumos/docs/+/HEAD/work_on_branch.md

# 不下载历史版本信息,速度较快,后续切换分支时略慢
fetch --no-history chromium
# 注意,不是 fetch chromium --no-history

# 如果下载失败,已经有.gclient文件,可以用下面命令
gclient sync --nohooks --with_branch_heads --with_tags --output-json="log.json"
gclient runhooks # 或者 gclient runhooks --force

# fetch --no-history chromium 是下载最新的main分支,如果要下载指定的tag或者branch,用如下方法

# 拉取指定tag(92.0.4515.109),(不带历史记录 --depth 1)
git fetch https://chromium.googlesource.com/chromium/src.git +refs/tags/92.0.4515.109 --depth 1

# 拉取指定分支(branch-heads/4515),(不带历史记录 --depth 1)
git fetch https://chromium.googlesource.com/chromium/src.git +refs/branch-heads/4515 --depth 1

# 上面拉取的分支没有日志信息,git log -3 只有一条记录内容
第一次 git pull 时,要检查远程仓库对象个数,是比较慢的

# 显示计算远程对象个数,比较慢
D:\git\chromium\src>git pull
remote: Counting objects: 7371722

# 再是查找远程对象,也比较慢
D:\git\chromium\src>git pull
remote: Finding sources: 100% (16086128/16086128)

# 最后是接收远程对象,这一步看似完全下载,实际上只有一少部分需要的内容才被下载。
D:\git\chromium\src>git pull
remote: Finding sources: 100% (16086128/16086128)
Receiving objects:  45% (7323535/16086128), 2.52 GiB | 1.78 MiB/s

## 上面成功后,如果要下载整个仓库可以
#cd src
## 切记不要轻易 git fetch
#git fetch --all
#git fetch --tags
## 或者 直接下载整个仓库
# fetch chromium

git pull
# 到此为止,是master的最新代码

06 切换到相对稳定分支

参考:
https://omahaproxy.appspot.com/
http://www.chromium.org/developers/how-tos/get-the-code/working-with-release-branches

cd src # 在src目录
# 创建新的分支b3440
git checkout -b b3440 branch-heads/3440
# 也可以考虑直接使用tag。比如:git checkout -b b3440 68.0.3440.54
cd .. # zai src的上一级目录(chromium目录)
gclient sync --with_branch_heads --with_tags

07 build时的设置参数

target_cpu=“x86”:指明生成的针对X86架构的CPU。
is_debug=false:指明生成的是Release版本可执行程序。
is_official_build=true:指明使用Chrome官方的编译优化建议。
proprietary_codecs:指明支持H264编码,编译时,自动H264相关组件,打包PE文件中。
enable_nacl=false:指明关闭支持NACL,这是一种Chrome插件,因为安全性,稳定性存在问题,已经很少使用了。
remove_webcore_debug_symbols=true:指明删除内核层支持调试的符号文件,这样,有助于减少文件体积,提高运行速度。

查看gn args 所有可用参数
gn 说明 https://www.chromium.org/developers/gn-build-configuration

:: 很重要的参考资料
gn args --list out\Debug
::去掉显示头文件的包含树
::修改src\build\toolchain\win\BUILD.gn,将/showIncludes删除掉

使用 --filters=//chrome , 会过滤掉一些工程,比如:setup,mini_installer 两个工程,在设置 --filters=//chrome 支持ninja编译,不会生成vs2017的工程。
所以是否使用 --filters=chrome,还需要根据自己的实际需要斟酌。

gn gen out/Debug --ide=vs2017 --filters=//chrome --args="target_os=\"win\" target_cpu=\"x86\" is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" remove_webcore_debug_symbols=true enable_nacl=false enable_hevc_demuxing=true enable_dolby_vision_demuxing=true enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true"
ninja -C out\Debug chrome setup mini_installer
:: 35025文件

gn gen out/Release --ide=vs2017 --filters=//chrome --args="target_os=\"win\" target_cpu=\"x86\" is_component_build=false is_debug=false is_official_build=true google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" remove_webcore_debug_symbols=true enable_nacl=false enable_hevc_demuxing=true enable_dolby_vision_demuxing=true enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true"
ninja -C out\Release chrome
ninja -C out\Release mini_installer

gn gen out/DebugX64 --ide=vs2017 --filters=//chrome --args="target_os=\"win\" target_cpu=\"x64\" is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" remove_webcore_debug_symbols=true enable_nacl=false enable_hevc_demuxing=true enable_dolby_vision_demuxing=true enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true"
ninja -C out\DebugX64 chrome
:: 35025文件

:: is_component_build=false 和 is_official_build=true 不能同时为true
gn gen out/ReleaseX64 --ide=vs2017 --filters=//chrome --args="target_os=\"win\" target_cpu=\"x64\" is_component_build=false is_debug=false is_official_build=true google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" remove_webcore_debug_symbols=true enable_nacl=false enable_hevc_demuxing=true enable_dolby_vision_demuxing=true enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true"
ninja -C out\ReleaseX64 chrome
:: 生成安装包
ninja -C out\ReleaseX64 mini_installer
ninja -C out\ReleaseX64 setup
:: 34416文件

:: 关掉clang选项 is_clang=false,需要停用掉vs的头文件警告,修改src\build\toolchain\win\BUILD.gn,将/showIncludes删除掉
gn gen out/DebugX64 --ide=vs2017 --filters=//chrome --args="target_os=\"win\" target_cpu=\"x64\" is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" remove_webcore_debug_symbols=true enable_nacl=false enable_hevc_demuxing=true enable_dolby_vision_demuxing=true enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true is_clang=false"

:: 指定winsdk版本。如果本机按照多个版本的sdk,可以明确指定使用sdk的版本,目前官网说明使用10.0.17134
:: 注意,winsdk版本号不要加引号
gn gen out/DebugX64 --ide=vs2017 --filters=//chrome --args="target_os=\"win\" target_cpu=\"x64\" --winsdk=10.0.17134.12 is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" remove_webcore_debug_symbols=true enable_nacl=false enable_hevc_demuxing=true enable_dolby_vision_demuxing=true enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true"

:: 使用eclipse调试,指定ide=eclipse,使用 Eclipse IDE for C/C++ Developers x64版本
:: https://www.eclipse.org/downloads/packages/
:: https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2018-09/R/eclipse-cpp-2018-09-win32-x86_64.zip
gn gen out/eclipse --ide=eclipse --winsdk=10.0.17134.12 --filters=//chrome --args="target_os=\"win\" target_cpu=\"x64\" is_component_build=true is_debug=true is_official_build=false google_api_key=\"zdx-client-oauth-id\" google_default_client_id=\"761449048278-g5uovi72654mi09043umi634r03ms6h7.apps.googleusercontent.com\" google_default_client_secret=\"MPf1fXdwyTp9218HABi1fzyx\" proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" remove_webcore_debug_symbols=true enable_nacl=false enable_hevc_demuxing=true enable_dolby_vision_demuxing=true enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true"

chromium能够支持的html5选项,可以参考: http://html5test.com/

*在gclient sync的时候遇到了错误,根据提示手动修改了 .py文件。
后来编译的时候又出现错误。卸载了windows wdk,编译正常通过

Chrome浏览器内置功能指令
https://wiki.deepin.io/mediawiki/index.php?title=Chrome%E6%B5%8F%E8%A7%88%E5%99%A8%E5%86%85%E7%BD%AE%E5%8A%9F%E8%83%BD%E6%8C%87%E4%BB%A4

08 设置远程分支与本地分支对应关系

建立对应远程分支的本地分支,比如:建立对应68的正式发布版本的本地分支,68.0.3440.54,分支为b3440。

git checkout -b b3440 remotes/branch-heads/3440

建立本地分支与远程分支的对应关系,远程分支变化,切换到本地分支时,能够直接观察的到,或者使用 git fetch --all时,能够拉到对应分支的变更内容

# git branch --set-upstream-to=远程分支名词  本地分支名称
git branch --set-upstream-to=remotes/branch-heads/3440 b3440

09 查看分支对应关系

git branch -vv

10 取消远程分支对应关系

# git branch --set-unupstream-to=远程分支名词
git branch --set-unupstream-to=remotes/branch-heads/3440

11 编译生成安装包

ninja -C out/Release chrome setup mini_installer
out\Release\setup.exe --chrome --multi-install

12 几个有用的命令

# 查找当前目录下所有.gn文件 是否包含 executable("chrome")
findstr /S "executable(\"chrome\")" *.gn

删除d:\path1目录及子目录下所有*.lock文件
forfiles /P "d:\path1" /S  /M "*.lock" -C "cmd /c del @path"

# 清楚不用的文件
git clean -df  # 注意,这个命令同时会清除git仓库下面的submodule内容,慎用!!
git reset --hard

git reset --hard 
git clean -xdf

git pull
:: 解决冲突
git rebase --continue
git pull

如果vs2017安装路径不是默认的,runhooks的时候提示的错误中含有 vs2017_install,需要自己在系统环境变量中添加一下vs2017_install环境变量。比如:我的vs2017安装在D:\install\Microsoft Visual Studio\2017\Community。需要这样设置:

set vs2017_install="D:\install\Microsoft Visual Studio\2017\Community"

13 关于google api key

如果需要使用google api key,可以在gn中指定 google api key 相关的参数。
获取密钥(ID)教程:
https://www.chromium.org/developers/how-tos/api-keys
获取密钥(ID)地址:
https://cloud.google.com/console
https://console.cloud.google.com/start

google_api_key
google_default_client_id
google_default_client_secret

也可以把这几个参数直接写在文件src\google_apis\BUILD.gn 中的
google_api_key
google_default_client_id
google_default_client_secret

对于同一个分支的 gclient sync,我们自己修改代码前和修改代码后不会影响gclient sync的。
git checkout -b bb3578_1 branch-heads/3578
git merge b3578
gclient sync
git checkout -b bb3578_2 branch-heads/3578
gclient sync

14 关于branch-heads/3578问题

在编译branch-heads/3578后,debug x86版本。vs2017调试会出现崩溃现象,单独运行debug release版本都正常。只有调试的时候,出现崩溃。而且很频繁。使用vs2017的15.9.1版本不行,回退到15.8版本,也不行。一次删除扩展插件也没缓解。该问题为解决。

切换到 branch-heads/3538 稳定分支。70.0.3538.110,不修改任何代码,vs2017调试,依然崩溃。
vs2017 社区版本,15.8 14.15 toolset。

最初使用vs2017 老版本,68.0.3440.105调试时,偶尔有崩溃问题 ,频率不高。

后来,代码升级到branch-heads/3578,调试登陆问题,崩溃频率很高。于是升级vs2017到最新版本 15.9.1。崩溃频率更高。
于是各种更新vs2017版本。包括:更好sdk版本15.8 14.15 toolset;14.14 toolset;卸载扩展插件。
重新完整安装15.9.2版本。问题依然存在。

vs2017崩溃无提示。看vs2017报告显示内存不足,观察任务管理器或者ProcessHacker查看,调试是内存最高占用4BG左右。

调试的chromium是x86版本。

目前没找到解决办法。

15 chrome://net-internals

chrome://net-internals/#proxy
chrome://net-internals/#dns

16 插件商店下载相关的源码

显示安装窗口的部分

void DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::
    OnWebstoreParseSuccess

kDashboardInvalidManifestError

ExtensionInstallPrompt::GetLocalizedExtensionForDisplay

安装vs的环境要求

https://blog.csdn.net/LostSpeed/article/details/81405462
记得上次弄68版本的时候,一开始好像也遇到过上面博客说的情况。

如果发现vs编译或者调试chromium不行,那就完全卸载vs和sdk,然后用官网的安装工具安装。

17 vs2019 编译92.0.4515.82

gn gen out/Debug --ide=vs2019 --args="target_os=\"win\" target_cpu=\"x86\" is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_platform_hevc=true chrome_pgo_phase=0"
ninja -C out\Debug chrome

gn gen out/Release --ide=vs2019 --args="target_os=\"win\" target_cpu=\"x86\" is_component_build=false is_debug=false is_official_build=true google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_platform_hevc=true chrome_pgo_phase=0"
ninja -C out\Release chrome

gn gen out/DebugX64 --ide=vs2019 --args="target_os=\"win\" target_cpu=\"x64\" is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_platform_hevc=true chrome_pgo_phase=0"
ninja -C out\DebugX64 chrome

gn gen out/ReleaseX64 --ide=vs2019 --args="target_os=\"win\" target_cpu=\"x64\" is_component_build=false is_debug=false is_official_build=true google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_platform_hevc=true chrome_pgo_phase=0"
ninja -C out\ReleaseX64 chrome

#单元测试编译
ninja -C out\DebugX64 chrome\test:unit_tests
out\DebugX64\unit_tests.exe --gtest_filter="PushClientTest.*" 

# 基础单元测试
ninja -C out\DebugX64 base_unittests
out\DebugX64\base_unittests
out\DebugX64\base_unittests --no-sandbox --gtest_filter=FileUtilTest.GetShmemTempDirTest

out\DebugX64\base_unittests --no-sandbox --single-process-tests


# 网络相关单元测试
ninja -C out\DebugX64 net_unittests
out\DebugX64\net_unittests.exe --gtest_filter=*DiskCacheBackendTest.SparseEvict*

# 编译 content_shell
ninja -C out\DebugX64 content_shell

18 查看可修改的参数

gn args out\DebugX64 --list > a.log

19 92.0.4515.82 版本编译错误处理

如果出现如下错误,(在编译ReleaseX64时出现)

Traceback (most recent call last):
  File "../../chrome/browser/resources/tools/optimize_webui.py", line 273, in <module>
    main(sys.argv[1:])
  File "../../chrome/browser/resources/tools/optimize_webui.py", line 253, in main
    manifest_out_path = _optimize(args.input, args)
  File "../../chrome/browser/resources/tools/optimize_webui.py", line 207, in _optimize
    bundled_paths = _bundle_v3(tmp_out_dir, in_path, out_path,
  File "../../chrome/browser/resources/tools/optimize_webui.py", line 183, in _bundle_v3
    output = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 220648: illegal multibyte sequence
[48/26818] ACTION //chrome/browser/resources/settings:build(//build/toolchain/win:win_clang_x64)
ninja: build stopped: subcommand failed.

可以修改 src\chrome\browser\resources\tools\optimize_webui.py 文件的182行。

with open(bundled_file, 'r') as f:

改为

with open(bundled_file, 'r', encoding='UTF-8') as f:

20 推送完整的代码仓库到gitlab

如果需要把自己下载的chromium代码推送到自己架设的gitlab仓库中。需要注意一些问题。

  1. 截至20210715日,chromium的代码仓库已经有30GB+大小。要准备足够的gitlab磁盘空间。
  2. 第一次上传时,最好采用覆盖方式,把默认的空仓库替换掉
# origin 一般是默认的,第一个main是本地分支名称,第二个main是远程分支名称
# 切记只有第一次才带 -f 参数,强制上传覆盖远程仓库
git push -f origin main:main
  1. 最好是设置一个gitlab的rsa密钥
    就是在本地使用 ssh-keygen -t rsa -C "mailname@xxx.com"生成 私钥文件id_rsa 和 公钥文件 id_rsa.pub%USERNAME%\.ssh 目录。然后把公钥文件的内容拷贝到 gitlab的 设置SSH Keys 页面的 添加 SSH Keys的文本框中,保存即可。
  2. 要调整下本地的 http.postBuffer 参数,这个比较重要。
    这个http.postBuffer 太小(默认值),push的时候,会有问题,提示信息如下:
D:\git\chromium\src>git push -f origin b4515:b4515
Enumerating objects: 15201734, done.
Counting objects: 100% (15201734/15201734), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3225504/3225504), done.
error: unable to rewind rpc post data - try increasing http.postBuffer
error: RPC failed; curl 56 OpenSSL SSL_read: Connection was reset, errno 10054
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (15201734/15201734), 21.72 GiB | 5.91 MiB/s, done.
Total 15201734 (delta 11396261), reused 14955421 (delta 11168555), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date

我在64GB内存的机器上面设置为4GB,push的时候会有问题,提示如下错误:
这个http.postBuffer值不能太大,否则会出现如下错误
git错误“无法推送一些引用到xxx"的解决方法

fatal: protocol error: bad line length 162
send-pack: unexpected disconnect while reading sideband packet
error: failed to push some refs to 'https://url/gitname.git'

# # 有帖子针对该错误修改服务的配置信息的。我没有针对该内容测试。
# # git错误“无法推送一些引用到xxx"的解决方法
# https://www.cnblogs.com/fixbug/p/6962701.html
# 打开 .git/config
# [receive]
# denyCurrentBranch = ignore

重点
当gitlab中不存在远程分支,或者远程分支为master/main时,可能会出现如下错误。

D:\git\oray\chromium\src>git push -u -f origin b4515:b4515
Enumerating objects: 366010, done.
Counting objects: 100% (366010/366010), done.
Delta compression using up to 16 threads
Compressing objects: 100% (277367/277367), done.
Writing objects: 100% (366010/366010), 1.16 GiB | 7.93 MiB/s, done.
Total 366010 (delta 71380), reused 366010 (delta 71380), pack-reused 0
To https://gitlab.xxxx.com/group01/project01.git
 ! [remote rejected]       b4515 -> b4515 (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.xxxx.com/group01/project01.git'

可以采用如下方式,即可把chromium本地分支代码成功推到自己已经建立的远程分支上,采用完全覆盖方式,不应期已有的其他分支。

1 gitlab服务端,建立一个空仓库,创建一个master,为空仓库切换一个分支b4515,
2 在本地切换一个稳定分支b4515, git push -u -f origin b4515:b4515

22 ppapi 默认已经不被支持了

刚才用92版本测试了一下代码中 ppapi的用力,发现已经不被支持了。

"C:\Users\zhang\AppData\Local\Chromium\Application\chrome.exe" --register-pepper-plugins="D:\git\chromium\src\ppapi\examples\video_encode\ppapi_example_video_encode.dll#ppexample##1.0.0;application/x-ppapi-kkvideo-preview" file:///D:\git\chromium\src\ppapi\examples\video_encode\video_encode.html

在这里插入图片描述

23 增加或者修改一个 args.gn 中控制的参数

build/config/ 下面的 xxx.gni 中 声明一个参数,根据自己的需要,在声明时,设置初始值

declare_args() {
    params_x = false
}

gn gen--args = 'params_x = true' 或者 --args = 'params_x = false'

24 指定sdk版本

本地安装多个版本时,如果 gn gen --winsdk=10.0.14393.0 指定sdk版本无效,
可以直接修改 uild/toolchain/win/setup_toolchain.py ,把从环境变量里面获得的sdk版本修改掉。是否修改成功,可以看 out/Default/environment.* 文件。

        env[var.upper()] = setting
        #print(var, setting.replace('10.0.22000.0', '10.0.14393.0'))
        env[var.upper()] = setting.replace('10.0.22000.0', '10.0.14393.0')
git diff build/toolchain/win/setup_toolchain.py
diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py
index fbc201e..f16c92e 100644
--- a/build/toolchain/win/setup_toolchain.py
+++ b/build/toolchain/win/setup_toolchain.py
@@ -50,7 +50,8 @@ def _ExtractImportantEnvironment(output_of_set):
           # path. Add the path to this python here so that if it's not in the
           # path when ninja is run later, python will still be found.
           setting = os.path.dirname(sys.executable) + os.pathsep + setting
-        env[var.upper()] = setting
+        #print(var, setting.replace('10.0.22000.0', '10.0.14393.0'))
+        env[var.upper()] = setting.replace('10.0.22000.0', '10.0.14393.0')
         break
   if sys.platform in ('win32', 'cygwin'):
     for required in ('SYSTEMROOT', 'TEMP', 'TMP'):

25 去除老版本的c++编译警告

出现如下错误,需要警用警告,优先在 公共部分加,其次在发生问题的工程中加。

如下错误,是因为把警告当成错误引起的。只要警用相应的警告就可以了。在对应 BUILD.gn 文件的 cflags 中加入对应警告号即可。

e:\banma\chromium572\src\media\formats\mp2t\es_parser_h264.cc(93) : error C2220: 警告被视为错误 - 没有生成“object”文件
e:\banma\chromium572\src\media\formats\mp2t\es_parser_h264.cc(93) : warning C4706: 条件表达式内的赋值
[20/12700] CXX obj/third_party/WebKit/public/offs..._mojo_bindings/offscreen_canvas_surface.mojom.obj
ninja: build stopped: subcommand failed.

公共部分一般到 src\build\config\BUILD.gn 或者 src\build\config\win\BUILD.gn 下面设置。
工程的话,一般可以到项目目录的根目录查找,比如: src\media\BUILD.gn

在 cflags = [] 中加入 “/wd4706”,或者在设当的位置加入 cflags += [] 中加入 “/wd4706”。

这里直接在 src\media\BUILD.gncflags = [] 中加入即可。cflags = ["/wd4706"]

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 18
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值