参考:
http://blog.csdn.net/baidu_32237719/article/details/79509819(3239 版本编译)
http://blog.csdn.net/qpshen/article/details/78559710(2987版本编译)
http://blog.csdn.net/doon/article/details/9287693(gclient介绍)
如果在编译时提示python.bat找不到,直接把G:\cef3325\source\depot_tools加到系统默认的path中就好了
编译条件
1.搬瓦工的shadowsocks,使用的CN2
2.win7或者更新的系统,必须64位,至少8GB的RAM,我采用win10 64位,16GRAM
3.比较新的VS,最近免费的社区版(编译不同版本要求不一样,具体看Cef官网帮助,我用的是VS2017),需要安装“C++桌面组件” 和 “MFC和ATL支持”,最好安装在默认路径,VS2017还需要特殊配置
4.Win10 SDK(官方10.0.15063,VS2017中有)
5.至少100G剩余空间(官方要求),NTFS文件系统,部分文件超过4G,部分资料显示最少60G,编译结束后发现远超60G
准备工作
1.设置系统区域为英语(美国)。(控制面板-区域-管理-更改系统区域设置-英语(美国)),设置完需要重启
2.创建工作目录,路径不能包含空格及特殊字符。例如g:\cef3325
3.下载编译工具包,解压至工作目录。例如g:\cef3325\depot_tools
4.下载编译脚本至工作目录。例如g:\cef3325\
5.在工作目录下创建源码目录。例如g:\cef3325\source
6.在系统变量Path中加入g:\cef3325\depot_tools ,为避免冲突,写在Path靠前位置
7.若环境变量设置后任有问题,在cmd使用set设置,例如:set DEPOT_TOOLS_WIN_TOOLCHAIN=0
8.增加download.bat至工作目录,例如g:\cef3325\dowload.bat,内容如下:
set CEF_ARCHIVE_FORMAT=tar.bz2 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set CEF_USE_GN=1 set GYP_MSVS_VERSION=2017 set GN_DEFINES=is_official_build=true set GN_DEFINES=use_jumbo_build=true set GN_DEFINES=is_component_build=true set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* python automate-git.py --download-dir=G:\cef3325\source --branch=3325 --no-build --no-distrib --force-clean
设置代理
1.shadowsocks设置为全局模式
2.打开具有管理员权限的cmd,输入如下指令
>netsh netsh>winhttp netsh winhttp> netsh winhttp> netsh winhttp>set proxy 127.0.0.1:1080
其中127.0.0.1:1080为代理的IP地址和端口号。
设置完成后,退出该cmd就可以了。该设置使固化在系统,重新启动之后,该设置依然有效。
3.设置http代理和Git代理
在CMD中输入:
>set http_proxy=http://127.0.0.1:1080 >set https_proxy=http://127.0.0.1:1080 >set socks5_proxy=socks5://127.0.0.1:1080
为git设置代理
a)使用http/https代理服务器
>git config --global http.proxy %http_proxy% >git config --global https.proxy %https_proxy%
或者:b)使用socks5代理服务器
>git config --global http.proxy %socks5_proxy% >git config --global https.proxy %socks5_proxy%
验证git代理
设置完后,用下面命令看是否成功:
>git config --get http.proxy >git config --get https.proxy
4.设置Boto代理
创建.boto文件,可以先创建一个.bot.(后面还有个点)确认就生成了,参考https://jingyan.baidu.com/article/6181c3e065531c152ef1532d.html
内容如下:
[Boto] proxy = 127.0.0.1 proxy_port = 1080
在cmd中
set NO_AUTH_BOTO_CONFIG=g:\cef3325\.boto
用来下gs://开头的文件,千万127.0.0.1前不要加http://
在浏览器下载的方案我只能下载前面一部分文件,中间有一步会清除目录下的文件,重新下载。
检出代码
把cmd切换到g:\cef3325\目录下,运行download.bat开始检出代码, 如下所示:
Microsoft Windows [版本 10.0.16299.192] (c) 2017 Microsoft Corporation。保留所有权利。 C:\WINDOWS\system32>set http_proxy=http://127.0.0.1:1080 C:\WINDOWS\system32>set https_proxy=http://127.0.0.1:1080 C:\WINDOWS\system32>set socks5_proxy=socks5://127.0.0.1:1080 C:\WINDOWS\system32>git config --global http.proxy %http_proxy% C:\WINDOWS\system32>git config --global https.proxy %https_proxy% C:\WINDOWS\system32>set NO_AUTH_BOTO_CONFIG=G:\cef3325\.boto C:\WINDOWS\system32>pushd g:\cef3325 g:\cef3325>download.bat g:\cef3325>set CEF_ARCHIVE_FORMAT=tar.bz2 g:\cef3325>set DEPOT_TOOLS_WIN_TOOLCHAIN=0 g:\cef3325>set CEF_USE_GN=1 g:\cef3325>set GYP_MSVS_VERSION=2017 g:\cef3325>set GN_DEFINES=is_official_build=true g:\cef3325>set GN_DEFINES=use_jumbo_build=true g:\cef3325>set GN_DEFINES=is_component_build=true g:\cef3325>set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* g:\cef3325>python automate-git.py --download-dir=G:\cef3325\source --branch=3325 --no-build --no-distrib --force-clean --> Download Directory: G:\cef3325\source --> Depot Tools Directory: G:\cef3325\source\depot_tools --> Extracting https://storage.googleapis.com/chrome-infra/depot_tools.zip to G:\cef3325\source\depot_tools. --> Updating depot_tools -------- Running "update_depot_tools.bat" in "G:\cef3325\source\depot_tools"...
搬瓦工的速度还是非常快的,很快就从远端下载完成:压缩包10.06G
[0:32:41] Still working on: [0:32:41] src Receiving objects: 98% (10398717/10530135), 10.02 GiB | 5.93 MiB/s [0:32:51] Still working on:R e[0:32:51] srcc remote: Total 10530135 (delta 8049315), reused 10530101 (delta 8049315) Receiving objects: 100% (10530135/10530135), 10.06 GiB | 5.33 MiB/s, done. Resolving deltas: 0% (162/8049315) [0:33:01] Still working on: [0:33:01] src Resolving deltas: 0% (1764/8049315) [0:33:11] Still working on: [0:33:11] src Resolving deltas: 0% (3849/8049315) [0:33:21] Still working on: [0:33:21] src Resolving deltas: 0% (6205/8049315) [0:33:31] Still working on: [0:33:31] src
之后进入漫长的Reloving deltas,最后成功了:
--> Chromium Current Checkout: 8bb58f52036793831d0363c285a6b159b21513d9 --> Chromium Desired Checkout: 8bb58f52036793831d0363c285a6b159b21513d9 (refs/tags/65.0.3325.146) -------- Running "gclient revert --nohooks" in "G:\cef3325\source\chromium"... Syncing projects: 100% (82/82), done. -------- Running "G:\cef3325\source\depot_tools\git.bat fetch" in "G:\cef3325\source\chromium\src"... -------- Running "G:\cef3325\source\depot_tools\git.bat fetch --tags" in "G:\cef3325\source\chromium\src"... -------- Running "G:\cef3325\source\depot_tools\git.bat checkout --force refs/tags/65.0.3325.146" in "G:\cef3325\source\chromium\src"... Checking out files: 100% (64642/64642), done. Previous HEAD position was c079292c73e2 [auto] Update FlagExpectations for LayoutNG HEAD is now at 8bb58f520367 Publish DEPS for Chromium 65.0.3325.146 --> Chromium DEPS file: G:\cef3325\source\chromium\src\DEPS -------- Running "gclient sync --reset --with_branch_heads --disable-syntax-validation --jobs 16" in "G:\cef3325\source\chromium"... Syncing projects: 100% (80/80), done.
尝试了很多次,发下depot tools一直会报错,所以把download.bat改改,不更新depot tools,最后是使用如下这份download.bat下载成功:
set CEF_ARCHIVE_FORMAT=tar.bz2 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set CEF_USE_GN=1 set GYP_MSVS_VERSION=2017 set GN_DEFINES=is_official_build=true set GN_DEFINES=use_jumbo_build=true set GN_DEFINES=is_component_build=true set DEPOT_TOOLS_DIR=E:\cef3325\source\depot_tools set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* python automate-git.py --download-dir=E:\cef3325\source --branch=3325 --no-depot-tools-update --no-build --no-distrib --force-clean
成功的结果如下:
1> Downloading src/chrome/installer/zucchini/testdata\chrome64_2.exe... 0> Downloading src/chrome/installer/zucchini/testdata\chrome64_1.exe... 3> Downloading src/chrome/installer/zucchini/testdata\setup2.exe... Downloading 4 files took 20.757000 second(s) Hook ''E:\cef3325\source\depot_tools\win_tools-2_7_6_bin\python\bin\python.exe' src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --num_threads=4 --bucket chromium-binary-patching -d src/chrome/installer/zucchini/testdata' took 23.96 secs Running hooks: 100% (54/54), done. WARNING: 'src\third_party\angle\third_party\spirv-tools\src' is no longer part of this client. It is recommended that you manually remove it. WARNING: 'src\third_party\libaom\source\libaom' is no longer part of this client. It is recommended that you manually remove it. WARNING: 'src\chrome\browser\resources\media_router\extension\src' is no longer part of this client. It is recommended that you manually remove it. WARNING: 'src\third_party\angle\third_party\glslang\src' is no longer part of this client. It is recommended that you manually remove it. WARNING: 'src\third_party\angle\third_party\vulkan-validation-layers\src' is no longer part of this client. It is recommended that you manually remove it. WARNING: 'src\third_party\angle\third_party\spirv-headers\src' is no longer part of this client. It is recommended that you manually remove it. --> Removing directory E:\cef3325\source\chromium\src\out --> Copying directory E:\cef3325\source\cef to E:\cef3325\source\chromium\src\cef --> Creating directory E:\cef3325\source\chromium\src\out --> Writing file: E:\cef3325\source\chromium\src\out\cef.branch
以后就可以改成不更新,不强制清理了
--no-depot-tools-update --no-update --no-distrib
生成工程
生成工程时有个很大的坑,VS2017自带的10.0.15063.468有问题,会提示找不到Debugging Tools for Windows
1. 必须安装“MFC和ATL支持,系统编译用到这两个控件,解决部分问题。
2. 卸载vs2017安装时默认安装的高于”10.0.15063.468”版本的WIN10 SDK,解决了部分问题。
3. 卸载vs2017安装时默认安装的”10.0.15063.468”版本的WIN10 SDK,重新在官网下载 “10.0.15063.468” 版本的WIN10 SDK进行安装
windows 10 SDK的安装目录是: C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0
在控制面板-删除中可以卸载它
4.如果内存不够,就增加虚拟内存,总内存最好高于20G
新建一个create_sln_vs2017.bat:
set CEF_USE_GN=1 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set GN_DEFINES=use_jumbo_build=true set GN_DEFINES=is_component_build=true set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome set GYP_MSVS_VERSION=2017 set CEF_ARCHIVE_FORMAT=tar.bz2 sset DEPOT_TOOLS_DIR=E:\cef3325\source\depot_tools set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* cd source\chromium\src\cef call cef_create_projects.bat
注意:
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
这句是用来支持MP3,MP4的
我试了三次create_sln_vs2017.bat,前两次都是报:
IOError: [Errno 0] Error
最后一次我重启了,把其他的程序都关掉, 终于显示成功:
________ running 'gn gen out\Release_GN_x86 --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 865ms Done. Made 7154 targets from 1448 files in 8997ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Release_GN_x86\obj\cef\libcef.ninja ________ running 'gn gen out\Debug_GN_x64 --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 875ms Done. Made 6901 targets from 1448 files in 6771ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Debug_GN_x64\obj\cef\libcef.ninja ________ running 'gn gen out\Debug_GN_x64_sandbox --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 901ms Done. Made 6889 targets from 1447 files in 6788ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Debug_GN_x64_sandbox\obj\cef\libcef.ninja ________ running 'gn gen out\Debug_GN_x86 --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 870ms Done. Made 7154 targets from 1448 files in 9712ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Debug_GN_x86\obj\cef\libcef.ninja ________ running 'gn gen out\Release_GN_x86_sandbox --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 921ms Done. Made 7153 targets from 1453 files in 9697ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Release_GN_x86_sandbox\obj\cef\libcef.ninja Creating e:\cef3325\source\chromium\src\out\Release_GN_x64 directory. ________ running 'gn gen out\Release_GN_x64 --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 38052ms Done. Made 6901 targets from 1448 files in 57845ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Release_GN_x64\obj\cef\libcef.ninja Creating e:\cef3325\source\chromium\src\out\Release_GN_x64_sandbox directory. ________ running 'gn gen out\Release_GN_x64_sandbox --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 44241ms Done. Made 6900 targets from 1453 files in 68947ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Release_GN_x64_sandbox\obj\cef\libcef.ninja Creating e:\cef3325\source\chromium\src\out\Debug_GN_x86_sandbox directory. ________ running 'gn gen out\Debug_GN_x86_sandbox --ide=vs2017 --sln=cef --filters=//cef/*' in 'e:\cef3325\source\chromium\src' Generating Visual Studio projects took 39544ms Done. Made 7142 targets from 1447 files in 69321ms Applying issue #1999 fix to e:\cef3325\source\chromium\src\out\Debug_GN_x86_sandbox\obj\cef\libcef.ninja e:\cef3325\source\chromium\src\cef>
gn生成的cef.sln和gyp有所区别,
gyp是直接在source\chromium\src\cef\目录下生成一个统一的sln,vc
而gn它是在source\chromium\src\out\的分目录下的,每个目录一个,如Debug_GN_x86,同时会把很多系统依赖的dll拷到当前目录,如下图:
而所有的VC工程都在对应分目\obj\目录下,如Debug_GN_x86\obj\cef\cef.vcxproj
编译代码
编译代码前也会默认先生成工程,所以如果生成工程失败,请多次尝试就可以了,build.bat如下:(只编译了release)
set CEF_USE_GN=1 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set GN_DEFINES=use_jumbo_build=true set GN_DEFINES=is_component_build=true set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome set GYP_MSVS_VERSION=2017 set CEF_ARCHIVE_FORMAT=tar.bz2 sset DEPOT_TOOLS_DIR=E:\cef3325\source\depot_tools set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* python automate-git.py --download-dir=E:\cef3325\source --branch=3325 --no-depot-tools-update --no-update --no-distrib --no-debug-build --force-build --build-log-file --verbose-build
我运行了两次,编译成功:
--> E:\cef3325\source\chromium\src\out\Release_GN_x86_sandbox\args.gn contents: clang_use_chrome_plugins=false enable_basic_printing=true enable_nacl=false enable_print_preview=false enable_widevine=true ffmpeg_branding="Chrome" is_component_build=false is_debug=false is_official_build=false proprietary_codecs=true target_cpu="x86" use_allocator_shim=false -------- Running "ninja -v -Cout\Release_GN_x86_sandbox cef_sandbox" in "E:\cef3325\source\chromium\src"... e:\cef3325>
此时,可以在out\Release_GN_X86目录下找到cefclient了:
打包
cef发布是有个打包流程的,其实就是把最后的python参数改改,还是完整的贴出distrib_vs2017.bat:
set CEF_USE_GN=1 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set GN_DEFINES=use_jumbo_build=true set GN_DEFINES=is_component_build=true set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome set GYP_MSVS_VERSION=2017 set CEF_ARCHIVE_FORMAT=tar.bz2 sset DEPOT_TOOLS_DIR=E:\cef3325\source\depot_tools set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* python automate-git.py --download-dir=E:\cef3325\source --minimal-distrib --force-distrib --no-distrib-docs --no-distrib-archive --branch=3325 --no-build --no-debug-build --no-update --distrib-subdir=cef_binary
运行后,生成目录在E:\cef3325\source\chromium\src\cef\binary_distrib\下:
Transferring E:\cef3325\source\chromium\src\cef\include/internal/cef_win.h file. Creating tar.bz2 archive for cef_binary_minimal... e:\cef3325>
这样打包会有点问题,就是生成包的名字和官网提供的二进制名称不同,最好还是在build.bat中直接使用--force-distrib这个参数:这时build.bat如下:
set CEF_USE_GN=1 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 set GN_DEFINES=use_jumbo_build=true set GN_DEFINES=is_component_build=true set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome set GYP_MSVS_VERSION=2017 set CEF_ARCHIVE_FORMAT=tar.bz2 sset DEPOT_TOOLS_DIR=E:\cef3325\source\depot_tools set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* python automate-git.py --download-dir=E:\cef3325\source --branch=3325 --no-depot-tools-update --no-update --force-distrib --no-debug-build --force-build --build-log-file --verbose-build
最后测试
测试网址是:
http://html5test.com/
http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
结果如下:
合智互联客户成功服务热线:400-1565-661
留言评论
暂无留言