参考:
https://longxuan.ren/2021/07/24/CEF-Build-On-Windows/
https://cloud.tencent.com/developer/article/1566083
https://cloud.tencent.com/developer/article/1667952
版本对应编译平台
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md
同步project错误解决方案
[CEF Forum • SOLVED]NoUsableRevError occurs when syncing projects (magpcss.org)
老版本需要使用python2.7版本
https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=17992&p=47390&hilit=gclient+revert#p47390
https://learn.microsoft.com/zh-cn/windows-hardware/drivers/debugger/debugger-download-tools](https://learn.microsoft.com/zh-cn/windows-hardware/drivers/debugger/debugger-download-tools)
https://learn.microsoft.com/zh-cn/windows-hardware/drivers/download-the-wdk
https://learn.microsoft.com/zh-cn/windows-hardware/drivers/other-wdk-downloads
编译3809版本
1.!!记住!!!!!!!
127.0.0.1:1801
2.环境安装
编译版本对应:https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md
vs安装:MSDN我告诉你
ed2k://|file|mu_visual_studio_professional_2017_version_15.1_x86_x64_10254675.exe|1037136|59A51C540A42BE9832D75B77EDB6CD98|/
Debugging Tools for Windows安装:默认路径!!
https://learn.microsoft.com/zh-cn/windows-hardware/drivers/debugger/debugger-download-tools
python 2.7安装:
git安装:
3.代理
cmd http和https都要配置
set http_proxy=127.0.0.1:1801
set https_proxy=127.0.0.1:1801
##测试一下:
curl www.google.com
git http和https都要配置
#因为已经设置了环境变量%http_proxy%和%https_proxy%
git config --global http.proxy %http_proxy%
git config --global https.proxy %https_proxy%
#所以也等同以下命令
git config --global http.proxy 127.0.0.1:1801
git config --global https.proxy 127.0.0.1:1801
#设置完后,用下面命令看是否成功
git config --get http.proxy
git config --get https.proxy
git config -l
gitssl证书配置
git config --global sslCAInfo "C:\\Program Files\\Git\\mingw64\\etc\\ssl\\cert.pem"
git config --global sslBackend openssl
设置环境变量
#设置git最大缓冲区
git config --global postBuffer 524288000
也可以配置.gitconfig文件
.boto文件
[Boto]
proxy = 127.0.0.1
proxy_port = 1080
设置,boto代理环境变量
set NO_AUTH_BOTO_CONFIG=C:\cef\chromium_git\.boto
4.目录准备
cef/automate
cef/chromium_git
cef/depot_tools
5.执行更新工具脚本
下载https://storage.googleapis.com/chrome-infra/depot_tools.zip
或者执行
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
执行
updata_depot_tools.bat
完成之后会出现:
compiler_proxy is not running
更新完了可以测试一下
gclient
cef源码git:https://bitbucket.org/chromiumembedded/cef.git
6.将depot_tools目录路径配置到环境变量
设置不主动升级
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
7.chromium_git 目录下创建一个名为 update.bat 的批处理文件,内容如下:
模板(–no-build只下载,不编译)
set GN_DEFINES=ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true
set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
:: 只更新代码
python ..\automate\automate-git.py --download-dir=e:\code\chromium_git --depot-tools-dir=e:\code\depot_tools --branch=3809 --no-build --no-distrib --force-clean
修改:
–download-dir
–depot-tools-dir
–branch
–no-depot-tools-update --no-update
8.修改支持MP3,MP4
打开文件chromium_git\chromium\src\third_party\ffmpeg\chromium\config\Chrome\win\ia32\config.h
大概修改以下内容
#define CONFIG_FLV_DECODER 1
#define CONFIG_H263_DECODER 1
#define CONFIG_H263I_DECODER 1
#define CONFIG_MPEG4_DECODER 1
#define CONFIG_MPEGVIDEO_DECODER 1
#define CONFIG_MSMPEG4V1_DECODER 1
#define CONFIG_MSMPEG4V2_DECODER 1
#define CONFIG_MSMPEG4V3_DECODER 1
#define CONFIG_RV10_DECODER 1
#define CONFIG_RV20_DECODER 1
#define CONFIG_RV30_DECODER 1
#define CONFIG_RV40_DECODER 1
#define CONFIG_AC3_DECODER 1
#define CONFIG_AMRNB_DECODER 1
#define CONFIG_AMRWB_DECODER 1
#define CONFIG_COOK_DECODER 1
#define CONFIG_SIPR_DECODER 1
#define CONFIG_FLV_ENCODER 1
#define CONFIG_H263_ENCODER 1
#define CONFIG_MPEG4_ENCODER 1
#define CONFIG_MSMPEG4V2_ENCODER 1
#define CONFIG_MSMPEG4V3_ENCODER 1
#define CONFIG_RV10_ENCODER 1
#define CONFIG_RV20_ENCODER 1
#define CONFIG_AAC_ENCODER 1
#define CONFIG_AC3_ENCODER 1
#define CONFIG_AC3_PARSER 1
#define CONFIG_COOK_PARSER 1
#define CONFIG_H263_PARSER 1
#define CONFIG_MPEG4VIDEO_PARSER 1
#define CONFIG_MPEGVIDEO_PARSER 1
#define CONFIG_RV30_PARSER 1
#define CONFIG_RV40_PARSER 1
#define CONFIG_SIPR_PARSER 1
#define CONFIG_AC3_DEMUXER 1
#define CONFIG_AMR_DEMUXER 1
#define CONFIG_AMRNB_DEMUXER 1
#define CONFIG_AMRWB_DEMUXER 1
#define CONFIG_AVI_DEMUXER 1
#define CONFIG_AVISYNTH_DEMUXER 1
#define CONFIG_FLV_DEMUXER 1
#define CONFIG_H263_DEMUXER 1
#define CONFIG_H264_DEMUXER 1
#define CONFIG_MPEGTS_DEMUXER 1
#define CONFIG_MPEGTSRAW_DEMUXER 1
#define CONFIG_MPEGVIDEO_DEMUXER 1
#define CONFIG_RM_DEMUXER 1
#define CONFIG_AC3_MUXER 1
#define CONFIG_AMR_MUXER 1
#define CONFIG_AVI_MUXER 1
#define CONFIG_FLV_MUXER 1
#define CONFIG_H263_MUXER 1
#define CONFIG_H264_MUXER 1
#define CONFIG_MPEGTS_MUXER 1
#define CONFIG_RM_MUXER 1
可以保存起来,后面拷贝到方案里面
9.创建解决方案
创建create.bat
set GN_DEFINES=ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true
set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
rem 拷贝增加了多媒体配置的头文件到 ffmpeg 目录下
rem copy config.h .\chromium\src\third_party\ffmpeg\chromium\config\Chrome\win\ia32 /y
rem 进入 cef 目录创建项目解决方案
cd .\chromium\src\cef
call cef_create_projects.bat
**如果没装WDK,这里会报错!!!
如果没有意外,提示如下
10.编译
##到chromium_git\chromium\src
cd c:\cef\chromium_git\chromium\src
##X86发布,不要丢了cef的参数
ninja -C out\Release_GN_x86 cef
ninja -C out\Debug_GN_x86 cef
ninja -C out\Release_GN_x64 cef
ninja -C out\Debug_GN_x64 cef
1.找不到ninja工具
全局搜索存在nanja工具,设置环境变量path,添加配套的第三方nanja工具路径
原来只加了c:\cef\depot_tools\在path,现在再加上C:\cef\chromium_git\chromium\src\third_party\depot_tools\
set path=C:\cef\chromium_git\chromium\src\third_party\depot_tools\;%path%
2.错误
找不到win32file模块 ImportError: No module named win32file
全局查找win32file,发现在别的路径有这个文件,于是将site-packages覆盖到原来site-packages。。
顺利编译完成
11.打包编译结果
#进入到src/cef/tools目录下
cd /chromium_git/chromium/src/cef/tools
#执行make_distrib.bat脚本
.\make_distrib.bat --ninja-build --minimal
下载代码update.bat,中途失败了,要清理git
执行以下脚本(模板,需要修改)(可以另存为clean_checkout.bat)
cd path\to\chromium\src
git checkout refs/tags/[CHROMIUM_VERSION]
gclient sync --with_branch_heads --nohooks
cd cef
tools\patch.bat
cd ..
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
gclient runhooks
cd cef
cef_create_projects.bat
修改以下内容
-
cd path\to\chromium\src =具体路径=> cd .\chromium\src
-
[CHROMIUM_VERSION] =查看CHROMIUM_BUILD_COMPATIBILITY.txt=> refs/tags/76.0.3809.132
cd .\chromium\src
git checkout refs/tags/76.0.3809.132
##原来推荐用这个
gclient sync --with_branch_heads --nohooks
##这个不行,更具提示,用这个
gclient sync -D
gclient sync -D --force
##找到src的cef,如chromium_git\chromium\src\cef,没有就从C:\cef\chromium_git\cef拷贝过去
cd cef
tools\patch.bat
cd ..
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
#在chromium_git\chromium\src下执行
gclient runhooks
#以下是创建解决方案的,我们用脚本执行,所以现在不需要调用下面两条
cd cef
cef_create_projects.bat