预读
- 不懂就请参考官方地址
- 一般要2步,下载 和 编译
- 创建文件结构1 
 2
 3
 4
 5
 6
 7
 8
 9~/code/ 
 automate/ <-- 全部脚本放到这里
 automate-git.py <-- CEF build script
 chromium_git/
 cef/ <-- CEF source checkout
 chromium/
 src/ <-- Chromium source checkout
 update.[bat|sh] <-- Bootstrap script for automate-git.py
 depot_tools/ <-- Chromium build tools
- 安装ninja,并加添到系统环境变量Clicked Me
- 最好不要在nvme盘上clone,可能导致clone卡死
详说
下载
- 打开打SS,服务器选择一个本地代理端口为1081,勾选来自局域网连接,不用启动代理!!!!
- 在automate下创建update.bat,内容为如下,执行该脚本,支持mp3 mp4~下载很快,代码可能就20来G样子,我下载速度10M/s还是很快,主要参考地址
- 该脚本会先下载depot_tools这个项目,再通过depot_tools下载源码,如果源码下载失败,需要重新下载源码可以不用再下载depot_tools,调用automate-git.py加一个参数,例: –depot-tools-dir=D:\code\chromium_git\depot_tools1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15::set proxys for depot_tools 
 set HTTP_PROXY=http://127.0.0.1:1081
 set HTTPS_PROXY=http://127.0.0.1:1081
 ::download
 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
 python automate-git.py --download-dir=F:\code\chromium_git --branch=3809 --minimal-distrib --client-distrib --force-clean --no-build
 pause
 ::automate-git.py脚本下载地址和为什么选择--branch=3809 参考 https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md
 :: 注:set https_proxy=http://localhost:1081的解决方案来自https://github.com/termux/termux-app/issues/698
编译过程
- 如下的全部脚本文件放到code/automate下 
- 修改源文件准备支持mp3,mp4,针对win32的话,修改F:\code\chromium_git\chromium\src\third_party\ffmpeg\chromium\config\Chrome\win\ia32\config.h,把部分#define 由0改为1,针对此操作,我写了一个脚本修改支持 
- 这些是要改的内容,写到本地文件mp4_support.txt - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55- #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
- SupportMp4.py - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40- ## 第一参数为上面要修改的#define 的文件路径,第二参数为 F:\code\chromium_git\chromium\src\third_party\ffmpeg\chromium\config\Chrome\win\ia32\config.h 
 import sys
 import shutil
 import re
 import os
 def Replace(change,content):
 str_array = re.findall("#define\s\w+\s",change)
 str_replace =str_array[0]
 str_replace+="0"
 str_dest =str_array[0]
 str_dest+="1"
 return content.replace(str_replace,str_dest)
 if len(sys.argv) > 2 :
 src_file_name =sys.argv[1]
 dest_file_name=sys.argv[2]
 else:
 src_file_name =raw_input("Please input src file path name:").replace("\r","")
 dest_file_name =raw_input("Please input dest file path name:").replace("\r","")
 file_src_handle = open(src_file_name,"r")
 file_src_lines = file_src_handle.readlines()
 file_src_handle.close()
 file_dest_handle = open(dest_file_name,"r")
 dest_file_content = file_dest_handle.read()
 file_dest_handle.close()
 for line in file_src_lines:
 dest_file_content = Replace(line,dest_file_content)
 write_file_path = os.getcwd()+"\\"+ os.path.basename(dest_file_name)
 ready_copy = open(write_file_path,"w")
 ready_copy.write(dest_file_content)
 ready_copy.close()
 shutil.copy(write_file_path,dest_file_name)
 os.remove(write_file_path)
 print("Support mp4 Success!!!")
- 再创建一个启动RunSupportMp4.bat 并运行 - 1 
 2- python SupportMp4.py F:/code/automate/mp4_support.txt F:/code/chromium_git/chromium/src/third_party/ffmpeg/chromium/config/Chrome/win/ia32/config.h 
 pause
- 创建env.bat脚本 - 1 - set path=%path%;F:\code\depot_tools;F:\code\chromium_git\chromium\src 
- 创建BuildNinga,Ninga是一个超快的编译工具,并小巧 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21- env.bat 
 set CEF_USE_GN=1
 set GN_DEFINES=is_official_build=true ffmpeg_branding=Chrome proprietary_codecs=true
 set GYP_DEFINES=buildtype=Official
 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=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
 set SDK_ROOT=C:\Program Files (x86)\Windows Kits\10
 set INCLUDE=C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\atlmfc\include;%INCLUDE%
 set PATH=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\bin\HostX64\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.13.26020\x64\Microsoft.VC141.CRT;%PATH%
 set LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\lib\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\atlmfc\lib\x86;%LIB%
 set VS_CRT_ROOT=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\crt\src\vcruntime
 ::python automate-git.py --download-dir=e:\buildLib\cef\source --depot-tools-dir=e:\buildLib\cef\depot_tools --branch=3359 --no-update --no-debug-build --build-log-file --verbose-build --force-distrib --force-build
 python automate-git.py --download-dir=F:\code\chromium_git --depot-tools-dir=F:\code\depot_tools --branch=3809 --no-update --no-debug-build --build-log-file --verbose-build --force-distrib --force-build
 pause- 如果前面全部都顺利的话,你会看到F:\code\chromium_git\chromium\src\out目录,里面有一堆准备使用ninga来编译的工程!!! 
 最后一步,执行如下操作,然后进行死亡等待- 1 
 2- cd F:\code\chromium_git\chromium\src 
 ninja -C out\Release_GN_x86 cef
编译好后,打开地址F:\code\chromium_git\chromium\src\out\Release_GN_x86 测试有没有成功支持mp4: http://html5test.com/
出错解决方案
源码下载完毕,卡到Resolving deltas: 100% (10224481/10224481), done
这个问题,折腾了我2天,想通过设置代理的方式解决,失败告终,但我通过奇技淫巧也成功编译了,首先停止脚本运行,修改一下automate-git.py,把13**多行的,sync git clone — job 16这句注释调,再执行下载脚本,跳过下载源码的过程
python ImportError: No module named win32file
参考:点这里
解决方法:cd 到depot_tools下的bootstrap-3_8_0_chromium_8_bin,然后进入python里面,给python安装 pywin32这个库
python -m pip install pywin32
卡到下载depot_tool位置
修改脚本 automate-git.py 188行,使用下载支持proxy请求
| 1 | proxies = {'http': 'http://127.0.0.1:1024'} |