赞
踩
编译好的结果下载地址在最后
=========================================================================
工 作中需要使用cef3,来展示web页面,也就是我们做的软件 = 我们做的壳 + cef3做浏览器。但是由于许可原因,cef3官方并没有开放mp3、mp4、h264等音视频的支持。如果想要浏览器支持这些音视频,就需要自己修改并编译cef3的源码来进行生成支持mp3、mp4、h264等音视频的浏览器。
但是cef3的源码过大(大约十几G),并且国内的网络也下载不下来,只能使用vpn。并且编译对机器要求很高,编译过程会遇到很多问题,编译过程很长(1-2天)。所以,最初我们是在网络上直接下载别人编译好的支持mp4等音视频cef3,版本是3071(大家需要可以在网络上搜)。
但是随着业务的增长,与前端(web端)可能需要一些js新特性,所以我们要进行对我们使用的浏览器进行升级。(但是如果需要支持xp系统,就必须使用2623版本,因为它是最后一个支持xp系统的cef3版本)。
我们首先要做的就是选定一个cef3的版本进行使用,所以,我对cef的版本进行了一个调研,现在是2018.12.06,cef3最新版本为3578,具体调研结果如下:
如果要下载cef3 release版本,可以在这里下载(不过这些都不支持mp3、mp4、h264等音视频):http://opensource.spotify.com/cefbuilds/index.html
=====================================下载源码=================================================
刚开始使用3282版本,但是经过一周多折腾,很多错误,到处是坑(最后再说)。
最终我们确定了使用当前释放的3578分支,最终然后说干就干,不过中间遇到了很多坑(最后再说)。
对于3578版本,我们需要的环境如下,查看相应cef版本对应的系统要求查看这里
Current Release Branches (Supported)
Support for newer branches begins when they enter the Chromium beta channel. Support for older branches ends when they exit the Chromium stable channel. The Spotify automated builder provides CEF builds for the current Chromium stable channel and will switch to the next Chromium branch when that branch is promoted to the stable channel. Updating CEF branches is currently a manual process so there will likely be a delay between Chromium release announcements and the availability of associated CEF builds. See the Chromium release calendar for estimated Chromium release dates and versions.
Branch Date Release Branch Windows Build Requirements macOS Build Requirements Linux Build Requirements Oct 2018 3578 Win 7+, VS2017 15.7.1+, Win10.0.17134.0 SDK, Ninja macOS 10.10-10.13, 10.10+ build system, 10.10+ deployment target, 10.10 base SDK, Xcode 9.3, Ninja, 64-bit only Ubuntu 14.04+, Debian Jessie+, Ninja Sep 2018 3538 Win 7+, VS2017 15.7.1+, Win10.0.17134.0 SDK, Ninja macOS 10.10-10.13, 10.10+ build system, 10.10+ deployment target, 10.10 base SDK, Xcode 9.3, Ninja, 64-bit only Ubuntu 14.04+, Debian Jessie+, Ninja
C:.
└─code
├─automate
│ automate-git.py
├─chromium_git
6. 安装python 2.7,并将路径添加到环境变量中。
7. 创建下载脚本 c:\code\download.bat
- set CEF_USE_GN=1
- set GN_DEFINES=is_official_build=true ffmpeg_branding=Chrome proprietary_codecs=true
- set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
- set GYP_DEFINES=buildtype=Official
- set GYP_MSVS_VERSION=2017
- set CEF_ARCHIVE_FORMAT=tar.bz2
- set DEPOT_TOOLS_UPDATE=0
- python automate\automate-git.py --download-dir=C:\code\chromium_git --branch=3578--no-build --no-distrib --no-update --force-clean
- pause
- // 以下为参数说明
- --download-dir 源码下载目录
- --depot-tools-dir 工具包目录(如果没下载的话,可以不用指定,就会下载匹配版本的depot_tools)
- --branch 源码分支(如果不指定,就默认选择编译master分支)
- --no-build 下载完不自动开始编译
- --no-update 不进行工具升级
- --force-build 强制编译
- --no-debug-build 只编译release版本
- --no-release-build 只编译debug版本
- --no-distrib 不进行打包发布
- --force-clean 用于清理chromium和cef的一些检出信息,如果下载失败,重新执行下载时,需要带上这个参数来清理一些信息,否则会失败。
-
-
- 8. 运行c:\code\download.bat 脚本,进行漫长的下载源码,约14G+的大小。下载后会自动计算展开,展开后总大小约为27G+,如果失败则重试。
============================下载完成后,添加mp3,mp4支持==============================
1.打开c:\code\chromium_git\chromium\src\third_party\ffmpeg\chromium\scripts\build_ffmpeg.py
- 将
- configure_flags['Chrome'].extend([
- '--enable-decoder=aac,h264',
- '--enable-demuxer=aac',
- '--enable-parser=aac,h264',
- ])
-
- 修改为
-
- configure_flags['Chrome'].extend([
- '--enable-decoder=aac,h264,mp3,mpeg4,amrnb,amrwb,flv',
- '--enable-demuxer=aac,mp3,mov,avi,amr,flv',
- '--enable-parser=aac,h264,mpegaudio,mpeg4video,h263',
- ])
2.分别打开c:\code\chromium_git\chromium\src\third_party\ffmpeg\chromium\src\third_party\ffmpeg\chromium\config\Chrome\win\ia32\config.h
与
c:\code\chromium_git\chromium\src\third_party\ffmpeg\chromium\src\third_party\ffmpeg\chromium\config\Chrome\win\x64\config.h
搜索 #define FFMPEG_CONFIGURATION 将前后的/**/ 删除,并将最后的 “-- elide long configuration string from binary” 删除掉,并添加
--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'
=================================编译======================================
1.创建debug版本的编译脚本build_debug.bat:
- set CEF_USE_GN=1
- set GN_DEFINES=is_official_build=true ffmpeg_branding=Chrome proprietary_codecs=true
- set GYP_DEFINES=branding=Chromium buildtype=Official proprietary_codecs=true ffmpeg_branding=Chrome
- set GYP_MSVS_VERSION=2017
- set CEF_ARCHIVE_FORMAT=tar.bz2
-
- set GYP_GENERATORS=ninja,msvs-ninja
- set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
-
- set WIN_CUSTOM_TOOLCHAIN=1
- set CEF_VCVARS=none
- set GYP_MSVS_OVERRIDE_PATH=D:\Program Files (x86)\Microsoft Visual Studio\2017\Community
- set SDK_ROOT=E:\Windows Kits\10
- set INCLUDE=E:\Windows Kits\10\Include\10.0.17134.0\um;E:\Windows Kits\10\Include\10.0.17134.0\ucrt;E:\Windows Kits\10\Include\10.0.17134.0\shared;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include;%INCLUDE%
- set PATH=E:\Windows Kits\10\bin\10.0.17134.0\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.16.27012\x64\Microsoft.VC141.CRT;%PATH%
- set LIB=E:\Windows Kits\10\Lib\10.0.17134.0\um\x86;E:\Windows Kits\10\Lib\10.0.17134.0\ucrt\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\lib\x86;%LIB%
- set VS_CRT_ROOT=D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\crt\src\vcruntime
- python C:\code\automate\automate-git.py --download-dir=C:\code\chromium_git --depot-tools-dir=C:\code\chromium_git\depot_tools --branch=3578 --no-update --no-release-build --build-log-file --verbose-build --force-distrib --force-build
- pause
2.创建release版本的编译脚本build_release.bat:
- set CEF_USE_GN=1
- set GN_DEFINES=is_official_build=true ffmpeg_branding=Chrome proprietary_codecs=true
- set GYP_DEFINES=branding=Chromium buildtype=Official proprietary_codecs=true ffmpeg_branding=Chrome
- set GYP_MSVS_VERSION=2017
- set CEF_ARCHIVE_FORMAT=tar.bz2
-
- set GYP_GENERATORS=ninja,msvs-ninja
- set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
-
- set WIN_CUSTOM_TOOLCHAIN=1
- set CEF_VCVARS=none
- set GYP_MSVS_OVERRIDE_PATH=D:\Program Files (x86)\Microsoft Visual Studio\2017\Community
- set SDK_ROOT=E:\Windows Kits\10
- set INCLUDE=E:\Windows Kits\10\Include\10.0.17134.0\um;E:\Windows Kits\10\Include\10.0.17134.0\ucrt;E:\Windows Kits\10\Include\10.0.17134.0\shared;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include;%INCLUDE%
- set PATH=E:\Windows Kits\10\bin\10.0.17134.0\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.16.27012\x64\Microsoft.VC141.CRT;%PATH%
- set LIB=E:\Windows Kits\10\Lib\10.0.17134.0\um\x86;E:\Windows Kits\10\Lib\10.0.17134.0\ucrt\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x86;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\lib\x86;%LIB%
- set VS_CRT_ROOT=D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\crt\src\vcruntime
- python C:\code\automate\automate-git.py --download-dir=E:\code\chromium_git --depot-tools-dir=C:\code\chromium_git\depot_tools --branch=3578 --no-update --no-debug-build --build-log-file --verbose-build --force-distrib --force-build
- pause
特别注意:
1>上面脚本中环境变量,一定要精确的指出来,其中WIN10 SDK的地址,一定要仔细检查
2>SET CEF_USE_GN=1 说明使用GN进行编译
3>下面这两句也一定要加上,使刚才更改的支持mp3,mp4生效
set GN_DEFINES=is_official_build=true ffmpeg_branding=Chrome proprietary_codecs=true
set GYP_DEFINES=branding=Chromium buildtype=Official proprietary_codecs=true ffmpeg_branding=Chrome
4>对于编译时间:使用机器 i7-7700, 32G内存
debug版本编译了大约:17小时
release版本编译了大约:5小时
5>编译完成后,输出路径为:c:\code\chromium_git\chromium\src\cef\binary_distrib\ 目录下
==================遇到的问题及一些说明======================
automate.py 是可以下载,更新cef源码与编译工具(depot_tools.zip ,git, python,clang),也可以进行编译、清理、打包发布等,主要根据参数决定。
下载完成时,我们可以进入下面目录中的 每个.sha1是否有同名的.exe,如果没有,就说明这些工具下载失败,就要想办法修复。(一般来讲,gs下载都会失败,所以,一定要检查这一步)
- code\chromium_git\chromium\src\buildtools\win\
- code\chromium_git\chromium\src\buildtools\win\
- code\chromium_git\chromium\src\buildtools\win\
- code\chromium_git\chromium\src\third_party\apache-win32\bin\
- code\chromium_git\chromium\src\third_party\apache-win32\modules\
我们需要下载 wget.exe 与RunWget.bat 脚本,对于列表中的文件进行逐一下载:可以网上下载wget.exe 或者在这里下载修复gs://下载错误 的工具与列表。
1> 然后将wget.exe、RunWget.bat、downTool.bat 三个文件放入到code\chromium_git\chromium\ 目录下
2>分别打开以下目录中的 *.sha1 ,将其中的值与downTool.bat中响应名称的值对应起来,如果不一致,以.sh1中的值,复制到downTool.bat中
- code\chromium_git\chromium\src\buildtools\win\
- code\chromium_git\chromium\src\buildtools\win\
- code\chromium_git\chromium\src/buildtools\win\
- code\chromium_git\chromium\src\third_party\apache-win32\bin\
- code\chromium_git\chromium\src\third_party\apache-win32\modules\
3>downTool.exe 每执行一次就会下载第一个文件,所以,当下载完第一个后,将downTool.exe中第一个删除或者注释掉,再次执行,直到列表中所有文件都下载完成即可。
下载列表 downTool.bat
RunWget.bat gs://chromium-gn/22d302b1658a293a4997205350751ff309b138c9 src/buildtools/win/gn.exe RunWget.bat gs://chromium-clang-format/c8455d43d052eb79f65d046c6b02c169857b963b src/buildtools/win/clang-format.exe RunWget.bat gs ://chromium-apache-win32/11ba0c1941b9c46ad279f33c2db3e3c628197ae8 src/third_party/apache-win32\bin\httpd.exe RunWget.bat gs ://chromium-apache-win32/199cb003a5a40db260f29128ae630f298aaf7702 src/third_party/apache-win32\bin\libapriconv-1.dll RunWget.bat gs ://chromium-apache-win32/d76ccf8a113227d63927616a45d7c8eb8df44cc7 src/third_party/apache-win32\bin\libapr-1.dll RunWget.bat gs ://chromium-apache-win32/4e51ce1a90b99d7b08a0ed1d151eee023d43966c src/third_party/apache-win32\bin\libaprutil-1.dll RunWget.bat gs ://chromium-apache-win32/230b1d13ba0c4c90089e5e239b2f206ce313bb1e src/third_party/apache-win32\bin\libhttpd.dll RunWget.bat gs ://chromium-apache-win32/4dca3606f57e1ea9bde5d1e088bda0ae0d4ad3e0 src/third_party/apache-win32\bin\libeay32.dll RunWget.bat gs ://chromium-apache-win32/2c7b52a7f6b9651a9ba19119d3d842247d541af6 src/third_party/apache-win32\bin\ApacheMonitor.exe RunWget.bat gs ://chromium-apache-win32/02c3d37fac86cd239fe02a1842134775e40a3331 src/third_party/apache-win32\bin\ssleay32.dll RunWget.bat gs ://chromium-apache-win32/923f8e771902c6da79ae720817cba8b389a6b275 src/third_party/apache-win32\bin\php5ts.dll RunWget.bat gs ://chromium-apache-win32/c54ee354a2cdc075b9b4379cf58aba90ebea774b src/third_party/apache-win32\bin\zlib1.dll RunWget.bat gs ://chromium-apache-win32/27b23f5fc9f2ace1ae53edbee3f32ef0a5d37287 src/third_party/apache-win32\bin\openssl.exe RunWget.bat gs ://chromium-apache-win32/eb6e8b068a8db9dfa80180ea16b0927b33760298 src/third_party/apache-win32\modules\mod_asis.so RunWget.bat gs ://chromium-apache-win32/49345ed7627a7019402c46db98bca55a6da80ace src/third_party/apache-win32\modules\mod_alias.so RunWget.bat gs ://chromium-apache-win32/99b9959e5fbec830fd08a8d398c52f23894dd485 src/third_party/apache-win32\modules\mod_autoindex.so RunWget.bat gs ://chromium-apache-win32/333d1d54b459797d9419fce049e7d5efe7fb0a69 src/third_party/apache-win32\modules\mod_cgi.so RunWget.bat gs ://chromium-apache-win32/b2a72bb8447cda2800be56db3959bb8bac68e810 src/third_party/apache-win32\modules\mod_authz_host.so RunWget.bat gs ://chromium-apache-win32/f6eebd3da324d7a4c36593677ccefcb626ac9548 src/third_party/apache-win32\modules\mod_log_config.so RunWget.bat gs ://chromium-apache-win32/5926b9d7d4f1e3aae31c10e0498923cb2fbc19a9 src/third_party/apache-win32\modules\mod_headers.so RunWget.bat gs ://chromium-apache-win32/b7dd1e015a88c96e03bb8845636472bb256e862b src/third_party/apache-win32\modules\mod_mime.so RunWget.bat gs ://chromium-apache-win32/8c81e5e9fa1d6d07d5235e553b42ac02be49b996 src/third_party/apache-win32\modules\mod_ssl.so RunWget.bat gs ://chromium-apache-win32/81c42674bc5865c3df35a9f47e3bc6910d89c4b1 src/third_party/apache-win32\modules\php5apache2_2.dll RunWget.bat gs ://chromium-apache-win32/ee17b7f92645403edb0c3bb80ceeb49791989995 src/third_party/apache-win32\modules\mod_rewrite.so RunWget.bat gs ://chromium-apache-win32/3158bdd7fabd47b3ff5188d3dd9cee42c97b334a src/third_party/apache-win32\modules\mod_env.so
RunWget.bat:
- @echo off
- if "%1"=="" goto error
-
- @rem ##########
- @rem 2> File gs://chromium-apache-win32/11ba0c1941b9c46ad279f33c2db3e3c628197ae8 for
- @rem src/third_party/apache-win32\bin\httpd.exe does not exist, skipping.
- @rem 3> File gs://chromium-apache-win32/199cb003a5a40db260f29128ae630f298aaf7702 for
- @rem src/third_party/apache-win32\bin\libapriconv-1.dll does not exist, skipping.
- @rem ##########
- set SRC_DIR=D:\code\chromium_git\chromium
-
- @rem set param1=gs://chromium-apache-win32/11ba0c1941b9c46ad279f33c2db3e3c628197ae8
- @rem set param2=src/third_party/apache-win32\bin\httpd.exe
- set param1=%1
- set param2=%2
- echo [INFO][%time%] ==========Begin==================
- echo [INFO][%time%] gs_url=%param1%
- set baseurl=https://storage.googleapis.com/
- set baseurl=%baseurl%%param1:~5%
- echo [INFO][%time%] httpBaseUrl=%baseurl%
-
-
- :StartDownload
- @rem 进行一次 文件是否 覆盖的用户交互
- pushd .
- cd %SRC_DIR%
- set cover
- if "%cover%"=="" set cover=2
- if exist %param2% (
- if %cover%==2 (
- set /p cover=文件已存在,是否覆盖?[0=不覆盖 1=覆盖]:
- )
- )
- popd
- if not exist %param2% (
- goto :continue
- )
- if %cover%==1 goto :continue
- echo [INFO][%time%]================END================
- goto :eof
-
- :continue
- pushd .
- cd %SRC_DIR%
- wget --no-check-certificate %baseurl% -O %param2%
- echo [%time%][SUCCESS] Dwonloads to url:%param2% success!!!
- echo [INFO][%time%]===============END=================
- popd
- goto :eof
-
- :error
- echo Help:
- echo %0 [gs://name/hash] [saveToPath]
- pause
Error: Command git reset --hard returned non-zero exit status 128 in C:\Users\...\CEF\chromium\src\third_party\WebKit
Traceback (most recent call last):
File "c:\code\automate-git.py", line 844, in <module>
run("gclient revert --nohooks", chromium_dir, depot_tools_dir)
File "c:\code\automate-git.py", line 59, in run
shell=(sys.platform == 'win32'))
File "c:\code\depot_tools\python276_bin\lib\subprocess.py"
, line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gclient', 'sync', '--reset', '--nohooks' ' '--with_branch_heads', '--disable-syntax-validation' '--jobs', '16']' returned non-zero exit status 1
j解决: 在经过漫长的下载之后,会突然出现了这个问题,然后打开 automate.py 中,搜索"gclient sync" 然后将其屏蔽,然后再次运行download.bat ,等到执行完毕后,再将其打开,重新运行。
解决:控制面板->区域和语言->修改成美国
error: '../../build/util/LASTCHANGE.blink', needed by 'gen/webkit_version.h', missing and no known rule to make it
解决:进入 c:\code\chromium_git\chromium\src\文件夹 执行
- ./build/util/lastchange.py build/util/LASTCHANGE
- ./build/util/lastchange.py -s third_party/WebKit/ -o build/util/LASTCHANGE.blink
就算没有出现这个错误,也一定要检查
c:\code\chromium_git\chromium\src\third_party\llvm-build\cr_build_revision 文件,检查其有没有内容。如果没有,需要手动查看c:\code\chromium_git\chromium\src\third_party\llvm-build\Release+Asserts\buildlog.txt 中的版本号,将其复制到cr_build_revision中
如果有错误,需要使用以下解决方式解决:
解决:参考 clang官网说明,对clang进行构建,或者升级。
方式一:执行 clang升级脚本:
python c:\code\chromium_git\chromium\src\tools\clang\scripts\update.py
方式二:
- pyton c:\code\chromium_git\chromium\src\tools\clang\scripts\update.py --force-local-build --without-android to build the plugin.
- ninja -C c:\code\chromium_git\chromium\src\third_party\llvm-build\Release+Asserts
最后特别说明:我们在编译某个版本的时候,首先要认真阅读几遍官方文档。我就是刚开始i选定的3282版本,进行下载编译,中间出了很多错误,修改了很多脚本。最终也没能成功,仔细阅读官方的文档,注意到一个细节:
Legacy Release Branches (Unsupported)
Legacy CEF builds are available from the Spotify automated builder back to 2704 branch. Building legacy branches is not supported. If you choose to build a legacy branch you will need to solve any build errors on your own.
- Newer legacy branches (within the past year) can often be built using the same tooling as current branches. You will need to (a) manually download depot_tools, (b) sync depot_tools to a revision that existed at the time of the branch, and (c) set the
DEPOT_TOOLS_UPDATE=0
environment variable to keep it from updating automatically.- Older legacy branches can potentially be built by downloading a CEF source archive at the desired branch from here and a Chromium source archive at the associated/required version from here, and then combining them to create the required directory structure.
- See the Build Notes section at the end of this page for historical build details.
也就是说,官方不支持编译过往的分支,如果你选择进行编译过往分支,出错的机率很大,并且需要你自己解决。
并且需要做到以下2点:特别重要(在编译3282分支的时候,就是没有遵守下面的这两点,导致很多错误,无法进行)
1.自己手动下载你进行编译的 分支发行时间 发布的 depot_tools。(也就是说这个depot_tools不是最新的,一定要是和你选择版本一起发布的才行)。
2.要设置DEPOT_TOOLS_UPDATE=0,防止工具更新。
========================下载地址============================
cef 3578 加入MP3 MP4功能的libcef.dll 以及编译好的结果在这里下载:cef_binary_3.3578.1859.g3563564_windows32.zip
没有积分的小伙伴,留下你的邮箱,看到后会第一时间发给你。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。