You set the variable “no_check_targets“ here and it was unused before it went out of scope.

很久没有编译CEF新版本了,最近看到Chrome提到在91版本上,提到有23%的性能提升,原文链接:https://blog.chromium.org/2021/05/chrome-is-faster-in-m91.html,是不是真有这么大改进?所以想试试看。然后理所当然地使用以前自己的编译脚本进行编译,结果又遇到个“奇葩”问题,这里简单记录一下。

在使用automate-git.py编译CEF 4472(Chromium 91)的时候,在脚本执行完CEF patch apply以后,突然报错:

Generating CEF project files...
Creating D:\google\cef_new\chromium\src\out\Debug_GN_x86 directory.
ERROR at //.gn:65:20: Assignment had no effect.
no_check_targets = [
                   ^
You set the variable "no_check_targets" here and it was unused before it went
out of scope.
Traceback (most recent call last):
  File "D:\google\cef_new\chromium\src\cef\tools\gclient_hook.py", line 146, in <module>
    RunAction(src_dir, cmd)
  File "D:\google\cef_new\chromium\src\cef\tools\gclient_util.py", line 35, in RunAction
    gclient_utils.CheckCallAndFilter(
  File "D:\google\cef_new\depot_tools\gclient_utils.py", line 673, in CheckCallAndFilter
    raise subprocess2.CalledProcessError(
subprocess2.CalledProcessError: Command 'gn gen out\\Debug_GN_x86 --ide=vs2019 --sln=cef --filters=//cef/*' returned non-zero exit status 1 in D:\google\cef_new\chromium\src
Traceback (most recent call last):
  File "D:\google\cef_new\automate-git.py", line 1462, in <module>
    run('%s %s' % (python_exe, tool), cef_src_dir, depot_tools_dir)
  File "D:\google\cef_new\automate-git.py", line 69, in run
    return subprocess.check_call(
  File "C:\Python39\lib\subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['D:\\google\\cef_new\\depot_tools\\python3.bat', 'D:\\google\\cef_new\\chromium\\src\\cef\\tools\\gclient_hook.py']' returned non-zero exit status 1.

意思很明显,是说chromium\src\.gn中定义了 no_check_targets 但是没有使用。一开始以为是自己的depot_tools版本不对(我机器上有好多个depot_tools),然后切换各种分支、commit还是不行。所以,还是在python脚本里补点日志看看咋回事吧。

通过上面错误提示,是在执行gn gen的时候报错的,然后通过阅读 cef\tools\gclient_hook.py、gclient_util.py,来到depot_tools\gn.py这个文件,其main函数会这两个位置寻找gn执行文件:

  • gclient_paths.GetPrimarySolutionPath()
  • gclient_paths.GetBuildtoolsPlatformBinaryPath()

我在gn.py里补打了一下这两个路径,第一个得到的结果是:

D:\google\cef_new\chromium\src\third_party\gn\gn.exe

看了一下,third_party下面是没有gn和gn.exe的,所以会使用第二个方法获取的路径。第二个的结果是:

D:\Electron\electron\src\buildtools\win\gn.exe

哎哎哎?怎么会跑到Electron下面去了?看来问题就是出在这里了。

接下来的排查就比较简单了,查看GetBuildtoolsPlatformBinaryPath的实现(位于depot_tools文件夹内的gclient_paths.py),原来这个路径受一个环境变量CHROMIUM_BUILDTOOLS_PATH(参见函数GetBuildtoolsPath)的影响,再去Windows系统环境变量查看,果然不知道什么时候有这么个环境变量,实在想不起来了,莫非是几个月前我编译Electron源码的时候手动加的?
CHROMIUM_BUILDTOOLS_PATH
到现在,终于水落石出了,删掉CHROMIUM_BUILDTOOLS_PATH,重新编译即可。正常情况下,使用的gn应该位于\chromium\src\buildtools\win\下面。好了,收工~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值