安装windows最新版本git,硬盘建议空闲空间大于100G,内存16G。
安装vs2019,选择默认安装路径,组件选择最新的windows sdk和c++环境,因为google chromium的源码庞大,第三库极多,所以MFC和ATL也需要勾选安装。
打开控制面板,选中windows software development kit的修改选项勾上Debuging Tools for window进行更改。
至于其他版本请参考cef官方编译指导,可能你需要穿越伟大的封锁:),有个列表是每个分支对windows编译的要求。
这个是最难受的一部分,我尝试过几次,前几次都止步于此,这个时候你需要某种穿越代理,但是按照官方流程拉代码经常失败。
所以自己总结了下步骤:
1.根据官方文档先创建以下结构目录:
~/code/ automate/ chromium_git/ depot_tools/
2.设置代理
在/code/目录下设置代理,xxxxx代表你自己的某种穿越代理端口
git config --global http.proxy "http://127.0.0.1:xxxxx"git config --global https.proxy "http://127.0.0.1:xxxxx"
3.从官方下载automate-git.py文件然后放到/code/automate/目录里。这里是特指4430分支版本,实际上是需要根据你想编译的分支,
将cef的具体某个分支里的/tools/automate/automate-git.py文件拷贝到上述目录里去。
4.从官方下载depot_tools.zip,然后提取到/code/depot_tools/目录里,
但是我这边是在/code/目录下直接从git拉取的源码
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
5.下载chromium源码
在chromium_git 目录下克隆github 上的仓库,虽然官方不建议这么做,但是我建议这么搞,因为即使你有某种穿越代理,代码很难完整拉下来。git同样需要设置代理,到这步基本上就是等git 把代码拉下来了,26个G左右,慢慢等吧。
git clone https://github.com/chromium/chromium.git
以上步骤做完基本上目录结构如下:
~/code/ automate/ automate-git.py <-- CEF build script chromium_git/ chromium/ src/ <-- Chromium source checkout depot_tools/ <-- Chromium build tools
1.先从浏览器把cef官网源码切换到4430分支,然后查看CHROMIUM_BUILD_COMPATIBILITY.txt
# The Chromium Embedded Framework (CEF) project is built on top of the Chromium# project source tree. Chromium should be updated to the URL and revision listed# below before building CEF. Chromium compatibility information for older CEF# revisions is available by viewing this file‘s change history.## Instructions for building CEF are available at:# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding{ ‘chromium_checkout‘: ‘refs/tags/90.0.4430.93‘, ‘depot_tools_checkout‘: ‘9757ad5883‘}
这个时候我们需要git进入到/code/depot_tools/这个目录切换分支,并且把depot_tools目录的路径添加到系统环境变量放在首位。
git checkout 9757ad5883
同样的我们用git进入到/code/chromium_git/chromium/src这个目录,然后切换分支
git checkout tags/90.0.4430.93 -b 90.0.4430.93
D:\code>set http_proxy=http://127.0.0.1:xxxxxD:\code>set https_proxy=http://127.0.0.1:xxxxxD:\code>cd depot_toolsD:\code\depot_tools>gclient
D:\code\chromium_git>set DEPOT_TOOLS_WIN_TOOLCHAIN=0D:\code\chromium_git>set GN_DEFINES=is_component_build=trueD:\code\chromium_git>set GN_ARGUMENTS=--ide=vs2019 --sln=cef --filters=//cef/*D:\code\chromium_git>python ..\automate\automate-git.py --download-dir=D:\code\chromium_git --depot-tools-dir=D:\code\depot_tools --branch=4430 --no-distrib --no-build
这个步骤完了基本上会把cef源码和chromium源码下载和同步完毕,等上面的命令执行完毕,进入到/code/chromium_git/chromium/src目录:
执行gclient sync -D --force 拉取和同步chromium的第三方库和其他源文件以及环境
D:\code\chromium_git\chromium\src>gclient sync -D --force
#define CONFIG_SIPR_PARSER 1#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
5.进入到chromium/src目录下的cef目录,执行以下命令
D:\code\chromium_git\chromium\src\cef>set DEPOT_TOOLS_WIN_TOOLCHAIN=0D:\code\chromium_git\chromium\src\cef>set GN_DEFINES=is_component_build=trueD:\code\chromium_git\chromium\src\cef>set GN_ARGUMENTS=--ide=vs2019 --sln=cef --filters=//cef/*D:\code\chromium_git\chromium\src\cef>call cef_create_projects.bat
此时会生成cef 项目文件,
6.进入到chromium/src 目录,执行ninja 编译文件,大概编译八九个小时左右,o(╯□╰)o,
D:\code\chromium_git\chromium\src>ninja -C out\Debug_GN_x86 cefninja: Entering directory `out\Debug_GN_x86‘[51139/51139] STAMP obj/cef/cef.stamp基本上到这一步算是结束了,然后用cef自带的例子跑一下测试以下功能,打包可以参考其他人的博客,编译遇到问题,以google 和cef官方和论坛为准或者去论坛提issues