当前位置:   article > 正文

Windows 编译CEF源码详细记录

windows 编译cef源码

背景

默认的CEF不支持音视频功能,需要下载源码将ffmpeg开关打开,再进行编译。

Linux编译参考:
Linux CEF源码下载编译详细记录

创建目录结构

code/
  automate/
    automate-git.py   <-- CEF build script
  chromium_git/
    cef/              <-- CEF source checkout
    chromium/
      src/            <-- Chromium source checkout
    update.[bat|sh]   <-- Bootstrap script for automate-git.py
  depot_tools/        <-- Chromium build tools
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

powershell中使用命令一键创建所需文件夹

mkdir -p CEF\automate,CEF\chromium_git
  • 1

设置网络环境

可从clash猫 常规-端口那里打开已经设置好的代理的终端,或者手动设置终端代理

$env:HTTP_PROXY="http://127.0.0.1:7890"
$env:HTTPS_PROXY="http://127.0.0.1:7890"
  • 1
  • 2

查看代理

ls env:*|findstr proxy(PROXY)

PS E:\CEF\depot_tools> ls env:*|findstr proxy
https_proxy                    http://127.0.0.1:7890
http_proxy                     http://127.0.0.1:7890
  • 1
  • 2
  • 3
  • 4
  • 5

设置git代理(可选),自测不需要。

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890
  • 1
  • 2

下载脚本

下载depot_tools

在CEF目录下,下载depot_tools

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

depot_tools目录下执行update_depot_tools脚本,等待下载完成,这个阶段时间会有点长,会下载大约1GB的文件。

PS E:\CEF\depot_tools> .\update_depot_tools.bat
  • 1

下载完成后,将其设置为环境变量

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-T836StWD-1691654584186)(../AppData/Roaming/Typora/typora-user-images/image-20230802164755820.png)]

注意:这里环境变量位置似乎要在python、git之上。

不过我推荐临时设置环境变量的方式:

查看powershell环境变量

$env:path -split“;”
  • 1

在powershell设置环境变量,这里是放在了所有Path环境变量的最前面

$env:Path="E:\CEF\depot_tools;$env:Path;"
  • 1

cmd设置环境变量

set path=E:\CEF\depot_tools;%path%
  • 1

查看环境变量:

set path
  • 1

文档好多都是set命令,推荐使用cmd命令行。

下载automate-git.py

下载 automate-git.py 脚本到 CEF\automate\automate-git.py,可使用powershell命令下载,或者手动下载。

Start-BitsTransfer -Source "https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py" -Destination "automate-git.py"
  • 1

在chromium_git目录下创建update.bat脚本:

set GN_DEFINES=is_component_build=true
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
python ..\automate\automate-git.py --download-dir=c:\code\chromium_git --depot-tools-dir=c:\code\depot_tools --no-distrib --no-build
  • 1
  • 2
  • 3
  • –branch 表示要下载哪个版本的代码,CEF 每个版本都有固定的分支,在 CEF 项目页查看分支名称指定即可。

  • –no-build 表示只下载代码而不编译,这里只为下载代码,我们还要修改支持多媒体的参数,所以不进行编译。

  • –no-distrib 不执行打包项目,这里只为下载代码,我们还要修改支持多媒体的参数,所以不进行打包。

  • –force-clean 如果你曾经执行过这个脚本,可能会出错,则加上这个参数,它执行清理残留文件(你也可以手动在 chromium 源码目录执行 git clean -xdf 来清理目录中的多余内容)。如果没有一次性下载成功而再次执行下载命令时,需要带上这个参数来清理一些信息,否则检出会失败

  • –force-clean-deps 编译老版本的时候会碰到下载第三方依赖库失败,碰到了可以加下这个

  • –no-depot-tools-update 如果工具包之前下载过了可以加上,就不升级工具包了,第一次下载不加

  • –no-update 编译时用,不更新直接编译

  • –no-debug-build 编译时用,不编译debug只要release

  • –x64-build 构建64位的版本

设置Boto代理(可选)

这一步可能有用

[Boto]
proxy = 127.0.0.1
proxy_port = 7890
  • 1
  • 2
  • 3

创建boto.cfg文件,在命令行设置环境变量,set NO_AUTH_BOTO_CONFIG=E:\CEF\boto.cfg

执行脚本

运行update.bat:

PS E:\CEF\chromium_git> ./update.bat

E:\CEF\chromium_git>set GN_DEFINES=is_component_build=true

E:\CEF\chromium_git>set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*

E:\CEF\chromium_git>python ..\automate\automate-git.py --download-dir=E:\CEF\chromium_git --depot-tools-dir=E:\CEF\depot_tools --no-distrib --no-build
--> Download Directory: E:\CEF\chromium_git
--> Depot Tools Directory: E:\CEF\depot_tools
--> Updating depot_tools
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

等待。。。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7bJniKOQ-1691654584187)(../AppData/Roaming/Typora/typora-user-images/image-20230807210431222.png)]

但这里我老是卡在这个地方:

SyntaxError: unexpected EOF while parsing
Traceback (most recent call last):
  File "..\automate\automate-git.py", line 1232, in <module>
    run("gclient revert --nohooks", chromium_dir, depot_tools_dir)
  File "..\automate\automate-git.py", line 67, in run
    args, cwd=working_dir, env=env, shell=(sys.platform == 'win32'))
  File "E:\code\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python\bin\lib\subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gclient', 'revert', '--nohooks']' returned non-zero exit status 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

我尝试了好几种:

  1. 将目录CEF改为code,与Wiki文档保持一致,失败
  2. 尝试修改update.bat,失败
  3. 尝试PowerShell换为cmd执行update.bat,失败

然后我换用VS的命令行工具x64 Native Tools Command Prompt for VS 2022执行,没想到成功了,能开始下载第三方库了

set http_proxy=http://127.0.0.1:7890 & set https_proxy=http://127.0.0.1:7890
update.bat
  • 1
  • 2

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-IDoIp3zc-1691654584188)(../AppData/Roaming/Typora/typora-user-images/image-20230808095743525.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-T7witlQu-1691654584188)(../AppData/Roaming/Typora/typora-user-images/image-20230808124425879.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bUsjAPo9-1691654584189)(../AppData/Roaming/Typora/typora-user-images/image-20230808124845010.png)]

下载成功!

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CgXnaSuv-1691654584189)(../AppData/Roaming/Typora/typora-user-images/image-20230808134538909.png)]

问题处理

  • RPC failed; curl 92 HTTP/2 stream 3 was not closed cleanly before end of the underlying stream
1>________ running 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src.git E:\CEF\chromium_git\chromium\_gclient_src_uhqf8ic3' in 'E:\CEF\chromium_git\chromium' attempt 2 / 2
1>Cloning into 'E:\CEF\chromium_git\chromium\_gclient_src_uhqf8ic3'...
1>remote: Finding sources: 100% (1558/1558)           objects: 1
1>error: RPC failed; curl 92 HTTP/2 stream 3 was not closed cleanly before end of the underlying stream
1>error: 59273 bytes of body are still expected
1>fetch-pack: unexpected disconnect while reading sideband packet
1>fatal: early EOF
1>fatal: fetch-pack: invalid index-pack output
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

一般是下载超时

  • ‘gclient’, ‘revert’, ‘–nohooks’
src (ERROR)
----------------------------------------
[0:00:00] Started.
----------------------------------------
Traceback (most recent call last):
  File "E:\CEF\depot_tools\metrics.py", line 301, in print_notice_and_exit
    yield
  File "E:\CEF\depot_tools\gclient.py", line 3669, in <module>
    sys.exit(main(sys.argv[1:]))
  File "E:\CEF\depot_tools\gclient.py", line 3655, in main
    return dispatcher.execute(OptionParser(), argv)
  File "E:\CEF\depot_tools\subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "E:\CEF\depot_tools\gclient.py", line 3256, in CMDrevert
    return client.RunOnDeps('revert', args)
  File "E:\CEF\depot_tools\gclient.py", line 2129, in RunOnDeps
    work_queue.flush(revision_overrides,
  File "E:\CEF\depot_tools\gclient_utils.py", line 1016, in flush
    reraise(e[0], e[1], e[2])
  File "E:\CEF\depot_tools\gclient_utils.py", line 70, in reraise
    raise value
  File "E:\CEF\depot_tools\gclient_utils.py", line 1093, in run
    self.item.run(*self.args, **self.kwargs)
  File "E:\CEF\depot_tools\gclient.py", line 1161, in run
    self.ParseDepsFile()
  File "E:\CEF\depot_tools\gclient.py", line 888, in ParseDepsFile
    deps_to_add = self._deps_to_objects(
  File "E:\CEF\depot_tools\gclient.py", line 723, in _deps_to_objects
    cached_conditions[condition] = gclient_eval.EvaluateCondition(
  File "E:\CEF\depot_tools\gclient_eval.py", line 662, in EvaluateCondition
    return _convert(main_node)
  File "E:\CEF\depot_tools\gclient_eval.py", line 592, in _convert
    return EvaluateCondition(
  File "E:\CEF\depot_tools\gclient_eval.py", line 662, in EvaluateCondition
    return _convert(main_node)
  File "E:\CEF\depot_tools\gclient_eval.py", line 628, in _convert
    value = _convert(node.operand)
  File "E:\CEF\depot_tools\gclient_eval.py", line 620, in _convert
    bool_values.append(_convert(value))
  File "E:\CEF\depot_tools\gclient_eval.py", line 644, in _convert
    left = _convert(node.left)
  File "E:\CEF\depot_tools\gclient_eval.py", line 592, in _convert
    return EvaluateCondition(
  File "E:\CEF\depot_tools\gclient_eval.py", line 564, in EvaluateCondition
    main_node = ast.parse(condition, mode='eval')
  File "C:\Users\Listening\.vpython-root\store\cpython-e6tenrlsesftvg6k08ajgkk7b4\contents\bin\Lib\ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 0

    ^
SyntaxError: unexpected EOF while parsing
Traceback (most recent call last):
  File "E:\CEF\automate\automate-git.py", line 1232, in <module>
    run("gclient revert --nohooks", chromium_dir, depot_tools_dir)
  File "E:\CEF\automate\automate-git.py", line 66, in run
    return subprocess.check_call(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Listening\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gclient', 'revert', '--nohooks']' returned non-zero exit status 1.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

此问题难以处理,只能多尝试几次,或者修改update.bat参数、换终端尝试。

修改ffmpeg配置文件

chromium_git\chromium\src\third_party\ffmpeg\chromium\config\Chromium\win-msvc\x64\config.h

chromium_git\chromium\src\third_party\ffmpeg\chromium\config\Chromium\win\x64\config_components.h
  • 1
  • 2
  • 3

以防万一,这两个地方都将CONFIG_SIPR_PARSER 宏开关启用,改为1

执行cef脚本

chromium_git\chromium\src\cef\下创建脚本create.bat

set GN_DEFINES=ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*

call cef_create_projects.bat
  • 1
  • 2
  • 3
  • 4

这一行是为了激活ffmpeg

// 激活 ffmpeg 内部解码器
set GN_DEFINES=ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true
  • 1
  • 2

然后执行create.bat

遇到错误:

Exception: No supported Visual Studio can be found. Supported versions are: 17.0 (2022), 16.0 (2019), 15.0 (2017).
ERROR at //build/config/win/visual_studio_version.gni:28:7: Script returned non-zero exit code.
      exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
      ^----------
Current dir: E:/CEF/chromium_git/chromium/src/out/Debug_GN_x64/
Command: E:/CEF/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe E:/CEF/chromium_git/chromium/src/build/vs_toolchain.py get_toolchain_dir
Returned 1.
See //third_party/angle/gni/angle.gni:54:5: whence it was imported.
    import("//build/config/win/visual_studio_version.gni")
    ^----------------------------------------------------
See //ui/accessibility/BUILD.gn:16:3: whence it was imported.
  import("//build/toolchain/win/midl.gni")
  ^--------------------------------------
See //BUILD.gn:144:7: which caused the file to be included.
      "//ui/accessibility:accessibility_unittests",
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

因为我的 Microsoft Visual Studio 不是默认安装路径,我安装在D盘,修改create.bat脚本,加上

set GYP_MSVS_VERSION=2022
set GYP_MSVS_OVERRIDE_PATH=D:\Program Files\Microsoft Visual Studio\2022\Community
set WINDOWSSDKDIR=C:\Program Files (x86)\Windows Kits\10
  • 1
  • 2
  • 3

即create.bat:

set GN_DEFINES=ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true

set GYP_MSVS_VERSION=2022
set GYP_MSVS_OVERRIDE_PATH=D:\Program Files\Microsoft Visual Studio\2022\Community
set WINDOWSSDKDIR=C:\Program Files (x86)\Windows Kits\10

set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
call cef_create_projects.bat
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

然后就生成成功了,同时生成了Debug、Release的 x86、 x64版本,可以在chromium_git\chromium\src\out看到对应的产物

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZuN1ZZ0S-1691654584190)(../AppData/Roaming/Typora/typora-user-images/image-20230808154807626.png)]

问题处理

由于环境变量设置错误,导致开启音视频的环境变量被覆盖。所以我删掉out下的文件,重新编译了一次,结果这次,提示需要pgo_profiles文件,并且生成的文件夹多了后缀带_sandbox的。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0SbYwQFe-1691654584190)(../AppData/Roaming/Typora/typora-user-images/image-20230809144017271.png)]

如果遇到pgo_profiles的报错,可以按照提示进行修改

Generating CEF project files...
Generating Visual Studio projects took 2203ms
Done. Made 17846 targets from 3213 files in 12500ms
Applying issue #1999 fix to E:\CEF\chromium_git\chromium\src\out\Debug_GN_x64\obj\cef\libcef.ninja
Traceback (most recent call last):
  File "E:/CEF/chromium_git/chromium/src/tools/update_pgo_profiles.py", line 154, in <module>
    sys.exit(main())
  File "E:/CEF/chromium_git/chromium/src/tools/update_pgo_profiles.py", line 150, in main
    return args.func(args)
  File "E:/CEF/chromium_git/chromium/src/tools/update_pgo_profiles.py", line 106, in _get_profile_path
    raise RuntimeError(
RuntimeError: requested profile "E:\CEF\chromium_git\chromium\src\chrome\build\pgo_profiles\chrome-win32-5672-1683023364-7247966391e939f36249c5509b49406c09455a6d.profdata" doesn't exist, please make sure "checkout_pgo_profiles" is set to True in the "custom_vars" section of your .gclient file, e.g.:
solutions = [
  {
    "name": "src",
    # ...
    "custom_vars": {
      "checkout_pgo_profiles": True,
    },
  },
],
and then run "gclient runhooks" to download it. You can also simply disable the PGO optimizations by setting |chrome_pgo_phase = 0| in your GN arguments.
ERROR at //build/config/compiler/pgo/BUILD.gn:81:23: Script returned non-zero exit code.
      pgo_data_path = exec_script("//tools/update_pgo_profiles.py",
                      ^----------
Current dir: E:/CEF/chromium_git/chromium/src/out/Release_GN_x86/
Command: E:/CEF/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe E:/CEF/chromium_git/chromium/src/tools/update_pgo_profiles.py --target win32 get_profile_path
Returned 1.
See //build/config/BUILDCONFIG.gn:352:3: which caused the file to be included.
  "//build/config/compiler/pgo:default_pgo_flags",
  ^----------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

我这里尝试运行gclient runhooks但是还是提示不存在,所以我这里将其禁用了,在create.bat的第一行追加chrome_pgo_phase = 0

set GN_DEFINES=ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true chrome_pgo_phase=0
  • 1

编译

cd 到CEF/chromium_git/chromium/src路径下执行ninja命令

cd ~/CEF/chromium_git/chromium/src
ninja -C out/Release_GN_x64 cef
  • 1
  • 2

开始编译,我这里需要编译56602个文件

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-oOcIzu2f-1691654584191)(../AppData/Roaming/Typora/typora-user-images/image-20230808155244690.png)]

然后再编译sandbox

ninja -C out/Release_GN_x64_sandbox cef_sandbox
  • 1

问题处理

  1. UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0x92 in position 231: illegal multibyte sequence

遇到这个错误好像不影响编译,最终也能编译成功。但不确定是否有缺陷。

[31649/56602] ACTION //chrome/browser/resources/settings:build_bundle(//build/toolchain/win:win_clang_x64)
Exception in thread Thread-2:
Traceback (most recent call last):
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\subprocess.py", line 1370, in _readerthread
    buffer.append(fh.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0x92 in position 231: illegal multibyte sequence
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

来自网络解决方法:

Windows下默认是gbk,导致读取文件时出错,这里在cmd里改为UTF-8编码,设置全局环境UTF-8

set PYTHONLEGACYWINDOWSSTDIO=utf8
set PYTHONIOENCODING=utf8
set PYTHONUTF8=1
  • 1
  • 2
  • 3

cmd终端编码修改为UTF-8,chcp会显示当前的编码编号

  • 936 GBK
  • 65001 UTF-8
chcp 65001
  • 1

编译了X86的测试,发现没有报错了。

解决此问题时,最好清理一下

ninja -C out/Release_GN_x64 -t clean
  • 1
  1. 第二次编译时,我提前设置了set PYTHONUTF8=1,结果又报这个UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 706: invalid continuation byte错误,挺迷惑的,于是又改回来set PYTHONUTF8=0
FAILED: obj/sandbox/win/acls.stamp
E:/CEF/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe ../../build/win/set_appcontainer_acls.py --stamp=obj/sandbox/win/acls.stamp --dir=.
Traceback (most recent call last):
  File "../../build/win/set_appcontainer_acls.py", line 35, in <module>
    main()
  File "../../build/win/set_appcontainer_acls.py", line 29, in main
    common.set_lpac_acls(os.path.abspath(args.dir))
  File "E:\CEF\chromium_git\chromium\src\testing\scripts\common.py", line 72, in set_lpac_acls
    existing_acls = subprocess.check_output(['icacls', acl_dir],
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\subprocess.py", line 495, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\subprocess.py", line 1015, in communicate
    stdout = self.stdout.read()
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 706: invalid continuation byte
[2139/57096] ACTION //net/base/registry_controlled_domains...ry_controlled_domains(//build/toolchain/win:win_clang_x64)
ninja: build stopped: subcommand failed.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

打包cef

这里为了能打包standard版本的cef二进制分发包,所以我又编译了一次debug版本的。然后在\chromium_git\chromium\src\cef\tools路径下执行

make_distrib.bat --ninja-build --no-docs --x64-build
  • 1
  • –ninja-build:使用ninja构建
  • –no-docs:不创建文档
  • –x64-build:64位

不加--x64-build默认为x86版本

然后等待片刻就可以在chromium\src\cef\binary_distrib看到制作好的二进制分发包了

问题处理

  1. ERROR: Failed to find vcvars
ERROR: Failed to find vcvars
Traceback (most recent call last):
  File "E:\CEF\chromium_git\chromium\src\cef\tools\\make_distrib.py", line 949, in <module>
    os.path.join(dst_dir, 'cef_sandbox.lib'))
  File "E:\CEF\chromium_git\chromium\src\cef\tools\\make_distrib.py", line 404, in combine_libs
    run(cmdline, os.path.join(cef_dir, 'tools'))
  File "E:\CEF\chromium_git\chromium\src\cef\tools\\make_distrib.py", line 442, in run
    args, cwd=working_dir, env=os.environ, shell=(sys.platform == 'win32'))
  File "E:\CEF\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python\bin\lib\subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

设置CEF_VCVARS环境变量

set CEF_VCVARS=D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
  • 1

之后就可正常执行了。

总结

晒个测试截图
在这里插入图片描述

在Windows上编译CEF源码,反而没有Linux上顺畅。

https://html5test.com/
https://zhuanlan.zhihu.com/p/133675543
记录一次项目中CEF版本的升级(二):CEF编译 - river12 - 博客园 (cnblogs.com)

https://www.moguf.com/post/wincefbuild

https://longxuan.ren/2021/07/24/CEF-Build-On-Windows/

https://www.magpcss.org/ceforum/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/912455
推荐阅读
相关标签
  

闽ICP备14008679号