先在D盘创建一个cef2623文件夹,用来存放源代码
1.下载
win10 SDK安装在默认目录下,我是直接安装了16299版本,很多人是用了15063版本,C:\Program Files (x86)\Windows Kits\10下可以看到,bin里显示了安装过哪些版本,注意看版本里有没有东西,有可能是空版本,并没有安装。
只需要安装就可以了,C:\Program Files (x86)\Windows Kits\10\SDKManifest.xml中不一定要显示成15063版本号。
python276 32位安装在默认目录(c:\python27),并在系统环境变量中加入。
2.创建cef2623\source目录,用来保存源代码
下载源代码是使用automate-git.py 来下载,使用–help可以看到它支持的所有命令
Microsoft Windows [版本 10.0.15063]
(c) 2017 Microsoft Corporation。保留所有权利。
C:\Users\hgy>pushd D:\cef2623
D:\cef2623>python automate-git.py --help
Usage: automate-git.py [options]
This utility implements automation for the download, update, build and
distribution of CEF.
Options:
-h, --help show this help message and exit
--download-dir=DIR Download directory with no spaces [required].
--depot-tools-dir=DIR
Download directory for depot_tools.
--depot-tools-archive=DEPOTTOOLSARCHIVE
Zip archive file that contains a single top-level
depot_tools directory.
--branch=BRANCH Branch of CEF to build (trunk, 1916, ...). This will
be used to name the CEF download directory and to
identify the correct URL if --url is not specified.
The default value is trunk.
--url=URL CEF download URL. If not specified the default URL
will be used.
--chromium-url=CHROMIUMURL
Chromium download URL. If not specified the default
URL will be used.
--checkout=CHECKOUT Version of CEF to checkout. If not specified the most
recent remote version of the branch will be used.
--chromium-checkout=CHROMIUMCHECKOUT
Version of Chromium to checkout (Git branch/hash/tag).
This overrides the value specified by CEF in
CHROMIUM_BUILD_COMPATIBILITY.txt.
--force-config Force creation of a new gclient config file.
--force-clean Force a clean checkout of Chromium and CEF. This will
trigger a new update, build and distribution.
--force-clean-deps Force a clean checkout of Chromium dependencies. Used
in combination with --force-clean.
--dry-run Output commands without executing them.
--dry-run-platform=DRYRUNPLATFORM
Simulate a dry run on the specified platform (windows,
macosx, linux). Must be used in combination with the
--dry-run flag.
--force-update Force a Chromium and CEF update. This will trigger a
new build and distribution.
--no-update Do not update Chromium or CEF. Pass --force-build or
--force-distrib if you desire a new build or
distribution.
--no-cef-update Do not update CEF. Pass --force-build or --force-
distrib if you desire a new build or distribution.
--no-chromium-update Do not update Chromium.
--no-depot-tools-update
Do not update depot_tools.
--force-build Force CEF debug and release builds. This builds
[build-target] on all platforms and chrome_sandbox on
Linux.
--no-build Do not build CEF.
--build-target=BUILDTARGET
Target name(s) to build (defaults to "cefclient").
--build-tests Also build the ceftests target.
--no-debug-build Don't perform the CEF debug build.
--no-release-build Don't perform the CEF release build.
--verbose-build Show all command lines while building.
--build-log-file Write build logs to file. The file will be named
"build-[branch]-[debug|release].log" in the download
directory.
--x64-build Create a 64-bit build.
--arm-build Create an ARM build.
--force-distrib Force creation of a CEF binary distribution.
--no-distrib Don't create a CEF binary distribution.
--minimal-distrib Create a minimal CEF binary distribution.
--minimal-distrib-only
Create a minimal CEF binary distribution only.
--client-distrib Create a client CEF binary distribution.
--client-distrib-only
Create a client CEF binary distribution only.
--sandbox-distrib Create a cef_sandbox static library distribution.
--sandbox-distrib-only
Create a cef_sandbox static library distribution only.
--no-distrib-docs Don't create CEF documentation.
--no-distrib-archive Don't create archives for output directories.
--clean-artifacts Clean the artifacts output directory.
--distrib-subdir=DISTRIBSUBDIR
CEF distrib dir name, child of
chromium/src/cef/binary_distrib
3.创建一个download.bat放在cef目录下
set CEF_ARCHIVE_FORMAT=tar.bz2
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set CEF_USE_GN=0
set GYP_DEFINES=buildtype=Official
set GYP_MSVS_VERSION=2013
set GYP_GENERATORS=ninja,msvs-ninja
python automate-git.py --download-dir=D:\ceforg\source --branch=2623 --checkout=b90a3be1860b0647e8a62c218ff7c054390365b1 --chromium-checkout=6345e75c7d4450f4ad929e338df8137f678a02cc --force-clean --no-distrib --no-build
因为2623最后版本的sha-1就是b90a3,所以可指定可不指定
--no-build --no-distrib只下载代码而不编译,--force-clean用来防止一次没有下载成功
运行download.bat,一次不成功就继续运行,直到成功为止
4.下载了一天,它会先在D:\ceforg\source\chromium\文件夹下生成_gclient_src_d9_xp3类似的两个文件夹,最后生成D:\cef2623\source\chromium\src文件夹,如果你看到下面的内容,说明离下载成功不远了:
有时如果一直报错,就注销下电脑,再运行download.bat
运行到最后报错:
这是gn.exe下载失败,这里下载了一个:
win.zip 扔到D:\cef2623\source\chromium\src\buildtools\win\内部
继续运行download.bat,最后如果报错
这时可以试着把--force-clean从download.bat中去掉,继续运行,OK,成功:
此时右击D:\cef2623\source\cef\可以看到cef的版本为b90a3be
下载完后,如果是TortoiseGit,src文件夹应该是绿色的小勾,如果不同,那就Revert下
为了安全起见,我们复制一份源代码到D:\cefbuild目录下,我用的是vs2013 update4,扔个update4的补丁包在此
在D:\cefbuild\source\chromium\src\cef\cef.gypi的'variables':节下增加
'proprietary_codecs': 1, 'ffmpeg_branding': 'Chrome',
如下图:
同时可参考《让Chrome的HTML5 video/audio tag支持更多种音视频格式》加入更多格式支持。
从D:\cefbuild\source\chromium\src\third_party\ffmpeg\chromium\config\Chrome\win\ia32\config.h可以得知Chrome采用的FFmpeg的配置选项,在原有的配置选项后面添加如下选项:
--enable-decoder='rv10,rv20,rv30,rv40,cook,h263,h263i,mpeg4,msmpeg4v1,msmpeg4v2,msmpeg4v3,amrnb,amrwb,ac3,flv' --enable-demuxer='rm,mpegvideo,avi,avisynth,h263,aac,amr,ac3,flv,mpegts,mpegtsraw' --enable-parser='mpegvideo,rv30,rv40,h263,mpeg4video,ac3'
即修改为:
#define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-valgrind-backtrace --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vda --disable-vdpau --disable-videotoolbox --enable-decoder=vorbis --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav' --enable-parser='opus,vorbis' --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --toolchain=msvc --enable-yasm --extra-cflags=-I/cygdrive/d/src/chromium/src/third_party/ffmpeg/chromium/include/win --cc='cygwin-wrapper cl' --ld='cygwin-wrapper link' --nm='cygwin-wrapper dumpbin -symbols' --ar='cygwin-wrapper lib' --enable-decoder='aac,h264,mp3' --enable-demuxer='aac,mp3,mov' --enable-parser='aac,h264,mpegaudio' --enable-decoder='rv10,rv20,rv30,rv40,cook,h263,h263i,mpeg4,msmpeg4v1,msmpeg4v2,msmpeg4v3,amrnb,amrwb,ac3,flv' --enable-demuxer='rm,mpegvideo,avi,avisynth,h263,aac,amr,ac3,flv,mpegts,mpegtsraw' --enable-parser='mpegvideo,rv30,rv40,h263,mpeg4video,ac3'"
在D:\cefbuild\下创建create_sln_vs2013.bat:
set CEF_USE_GN=0
set GYP_DEFINES=buildtype=Official
set GYP_MSVS_VERSION=2013
set GYP_GENERATORS=ninja,msvs-ninja
set DEPOT_TOOLS_DIR=%~dp0\source\depot_tools
set path=path;%~dp0\source\depot_tools
cd source\chromium\src\cef
call cef_create_projects.bat
:: 返回本文件所在目录
cd /D %~dp0
cef_create_projects.bat内部会使用python.bat,它位于D:\cefbuild\source\depot_tools,所以要设置path
运行create_sln_vs2013.bat,完成后,会在D:\cefbuild\source\chromium\src\cef生成相关的vs工程及cef.sln
编译时D:\cefbuild\source\build-2623-release.log默认会非常大,一堆全是什么注意: 包含文件,先把这玩意干掉!
打开D:\cefbuild\source\chromium\src\build\toolchain\win\BUILD.gn,搜索/showIncludes并删除
template("msvc_toolchain") {
大约77行处和92行,即:
command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
变为:
command = "ninja -t msvc -e $env -- $cl /nologo /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
打开D:\cefbuild\source\chromium\src\build\common.gypi,搜索msvs_disabled_warnings
设置编译项为:
4091,4127,4351,4355,4503,4589,4611,4100,4121,4244, 4505,4510,4512,4610, 4838, 4995, 4996,4334,4819,4396, 4125,4130,4131,4189, 4201,4067,4800,4251,4702,4456, 4457, 4458, 4459,4312,
https://codereview.chromium.org/1673323002
打开D:\cefbuild\source\chromium\src\ui\gl\BUILD.gn和
在sources=中删除 在deps中删除skia
--- a/ui/gl/BUILD.gn
+++ b/ui/gl/BUILD.gn
@@ -34,8 +34,6 @@ component("gl") {
"gl_bindings_autogen_gl.h",
"gl_bindings_autogen_osmesa.cc",
"gl_bindings_autogen_osmesa.h",
- "gl_bindings_skia_in_process.cc",
- "gl_bindings_skia_in_process.h",
"gl_context.cc",
"gl_context.h",
"gl_context_android.cc",
@@ -126,7 +124,6 @@ component("gl") {
deps = [
"//base/third_party/dynamic_annotations",
- "//skia",
]
--- a/ui/gl/gl.gyp
+++ b/ui/gl/gl.gyp
@@ -47,8 +47,6 @@
'gl_bindings_autogen_gl.h',
'gl_bindings_autogen_osmesa.cc',
'gl_bindings_autogen_osmesa.h',
- 'gl_bindings_skia_in_process.cc',
- 'gl_bindings_skia_in_process.h',
'gl_context.cc',
'gl_context.h',
'gl_context_android.cc',
在d:\cefbuild\目录下增加一个批处理build_vs2013.bat:
set CEF_ARCHIVE_FORMAT=tar.bz2
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set CEF_USE_GN=0
set GYP_DEFINES=buildtype=Official
set GYP_MSVS_VERSION=2013
set GYP_GENERATORS=ninja,msvs-ninja
set DEPOT_TOOLS_DIR=%~dp0\source\depot_tools
python automate-git.py --download-dir=%~dp0\source --branch=2623 --no-distrib --no-debug-build --force-build --no-update --build-log-file --verbose-build
cd /D %~dp0
运行build_vs2013.bat,先进入此界面:
报错,注意,cmd只会报python的错误,真实错误在D:\cefbuild\source\build-2623-release.log下搜索FAILED查看:如果报:
ninja: fatal: CreateProcess: 参数错误。
或
ninja: fatal: CreateProcess: The parameter is incorrect
参考http://blog.csdn.net/heartrude/article/details/49019989
把 D:\cefbuild\source\chromium\src\out\Release\build.ninja修改:
cl_x86 = "D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe"
cl_x64 = ""
或者重启下电脑吧,特别注意create_sln_vs2013.bat运行完,要退出cmd,再重新打开cmd,再运行build_vs2013.bat
[61/7031] ninja -t msvc -e environment.x86 -- "D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\ui\gl\gl.egl_util.obj.rsp /c ..\..\ui\gl\egl_util.cc /Foobj\ui\gl\gl.egl_util.obj /Fdobj\ui\gl\gl.cc.pdb
FAILED: obj/ui/gl/gl.egl_util.obj
ninja -t msvc -e environment.x86 -- "D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\ui\gl\gl.egl_util.obj.rsp /c ..\..\ui\gl\egl_util.cc /Foobj\ui\gl\gl.egl_util.obj /Fdobj\ui\gl\gl.cc.pdb
打开D:\cefbuild\source\chromium\src\third_party\swiftshader\include\EGL\eglext.h,在第62行后(63行)加入
typedef EGLAttribKHR EGLAttrib;
之后编译通过,没有遇到其他的错误
写一个distrib_vs2013.bat
set CEF_USE_GN=0
set GYP_DEFINES=buildtype=Official
set GYP_MSVS_VERSION=2013
set GYP_GENERATORS=ninja,msvs-ninja
set DEPOT_TOOLS_DIR=%~dp0\source\depot_tools
python automate-git.py --download-dir=%~dp0\source --minimal-distrib --force-distrib --no-distrib-docs --no-distrib-archive --branch=2623 --no-build --no-debug-build --no-update --distrib-subdir=cef_binary
cd /D %~dp0
运行,打包文件
在D:\cefbuild\source\chromium\src\cef\binary_distrib下打包了pdb和文件
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。