首页 CEF系列1:windows平台自己拉分支编译支持H264
文章
取消

CEF系列1:windows平台自己拉分支编译支持H264

CEF,全称为Chromium Embedded Framework,它可以让你在应用里面嵌入浏览器

https://bitbucket.org/chromiumembedded/cef/

先配置好 depot_tools

编译,没有用官方的automate-git.py

最好始终在一个cmd终端里面操作。

1
git clone https://bitbucket.org/chromiumembedded/cef.git -b 6167 --depth 1

cef与chromium和depot_tools的版本对应关系在 “cef\CHROMIUM_BUILD_COMPATIBILITY.txt”

1
2
3
4
{
'chromium_checkout': 'refs/tags/121.0.6167.16',
'depot_tools_checkout': '6444de14d1'
}

根据对应关系,下载相应版本:

把depot_tools切换到对应的commitId(切换之前最好备份下目录),并禁用更新,不然后面gclient时又会更新到新版了。

1
git reset --hard 6444de14d1
1
2
3
4
5
6
7
8
git clone https://chromium.googlesource.com/chromium/src.git -b 121.0.6167.16 --depth 1 #如果要编译其它cef版本最好也这样下载,不要通过切换分支去切换代码。
gclient config  https://chromium.googlesource.com/chromium/src.git --unmanaged # 生成.gclient

gclient sync --nohooks --no-history  #在.gclient文件同级目录执行

gclient runhooks

git tag

然后将cef拷贝到chromium源码目录的src\cef下,

进入cef目录,以下都在cmd终端里面一条一条运行

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
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
call cef_create_projects.bat # generate Ninja and Visual Studio project files.会生成cef.sln

输出:
Generating CEF version header file...
Patching build configuration and source files for CEF...
95 patches total (95 applied, 0 skipped, 0 failed)
...
Generating CEF project files...
Creating C:\code\cef_compile\6167\src\out\Debug_GN_x64 directory.
Generating Visual Studio projects took 4498ms
Done. Made 19516 targets from 3565 files in 15462ms

Creating C:\code\cef_compile\6167\src\out\Release_GN_x64 directory.
在C:/code/cef_compile/6167/src/tools/update_pgo_profiles.py里面报错了:
RuntimeError: requested profile "C:\code\cef_compile\6167\src\chrome\build\pgo_profiles\chrome-win64-6167-1702403312-82d61bcc654e9a17abfd09e1a6b05cf3c78be59e.profdata" doesn't exist

原因是没有下载profdata 文件
根据提示修复,在.gclient 文件里面添加
"custom_vars": {
      "checkout_pgo_profiles": True,
},
then run "gclient runhooks" to download it.

Running hooks:  49% (84/171) Fetch PGO profiles for win-arm64
重新运行call cef_create_projects.bat

生成了Debug_GN_x64,Debug_GN_x64_sandbox,Release_GN_x64等8份目录,我们只要其中一个:

编译

1
2
3
4
5
6
7
8
cd C:\code\cef_compile\6167\src  #chromium源码目录下
autoninja -C out\Release_GN_x64 cef
ninja: Entering directory `out\Release_GN_x64'
[61904/61904] STAMP obj/cef/cef.stamp  # 跟chromium一样,要几个小时

运行下 cefclient.exe,加载一下<https://html5test.com/> 看看是否支持H264

但最后打包失败了,下一篇单独讲。

参考

https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart

https://www.cnblogs.com/zgliubo/p/16423247.html

本文由作者按照 CC BY 4.0 进行授权