迫於對現有項目的升級,最近開始考慮更新在項目中所使用到的CEF(Chromium Embedded Framework)瀏覽器庫,但CEF/Chromium出於版權考慮保留了對於mp3/mp4等多媒體格式的支持,沒有對外開放。無奈在各個社區中沒有找到較新的支持mp3/mp4播放的版本,只得本身動手編譯CEF源代碼加入對mp3/mp4等多媒體格式的支持。通過多天的資料收集,發現很多前輩在下載代碼的環節中遇到了不少問題,因而本着避免重蹈覆轍以及儘可能減輕外部環境影響的原則,在某農貿市場買了一個"土豆"html
來完成本次的CEF編譯工做╮( ̄▽ ̄)╭。python
照例,仍是先從master分支開始摸索,折騰成功了,再嘗試編譯branche。git
環境準備(初定):chrome
一、Windows Server 2016 Standard x64 (官方標準: Windows 7 or newer,64-bit OS)。api
二、Visual Studio VS2017 15.3.2+ 安裝在默認位置。瀏覽器
三、Windows 10.0.15063.486 SDK 安裝在默認位置,必須確保SDK的準確版本,以避免在後續的編譯過程當中出現問題。網絡
四、至少8GB的內存以及40GB的硬盤空間(←_← emmmm....,官方標準,僅作參考),在看了某 前輩 在這個問題上趟過的大坑以後,更改配置爲: 16GB內存,以及200GB的硬盤空間。less
五、6核處理器 2.59GHz(→_→ 官方標準: 4核處理器 2.6GHz)。ide
六、保持良好通暢且穩定的網絡環境。svn
下載CEF和Chromium的源代碼
建立目錄結構
c:/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
PS: 如下摘自官方文檔:
With this file structure you can develop multiple CEF/Chromium branches side-by-side. For example, repeat the below instructions using "chromium_git1" as the directory name instead of "chromium_git".
WARNING: If you are using VS2017 15.5.* to build 3282 branch then you must add enable_precompiled_headers=false to GN_DEFINES in steps 6 and 7 to avoid a known issue with clang.
經過這個文件結構,您能夠並排開發多個CEF / Chromium分支。 例如,請使用「chromium_git1」做爲目錄名稱而不是「chromium_git」來重複如下說明。
警告:若是您使用VS2017 15.5。*構建3282分支,那麼您必須在步驟6和7中將GNU DEFINE添加到enable_precompiled_headers = false以免已知的問題。
WARNING: If you change the above directory names/locations make sure to (a) use only ASCII characters and (b) choose a short file path (less than 35 characters total). Otherwise, some tooling may fail later in the build process due to invalid or overly long file paths.
警告:若是更改上述目錄名稱/位置,請確保(a)僅使用ASCII字符,並(b)選擇一個短文件路徑(總共少於35個字符)。 不然,因爲無效或過長的文件路徑,某些工具可能會在構建過程的後期失敗。
1.下載 depot_tools.zip 並解壓縮到"c:\code\depot_tools"目錄。不要使用資源管理器中的拖放或複製粘貼提取,它不會提取depot_tools自動更新自身所需的隱藏「.git」文件夾。 不過,您可使用上下文菜單中的「所有提取...」。 7-zip 也是一個很好的工具。
打開 "cmd.exe" 運行"update_depot_tools.bat"腳本,安裝 Python、Git 和 SVN。
cd c:\code\depot_tools update_depot_tools.bat
2.下載 automate-git.py 腳本並保存至"c:\code\automate\automte-git.py".
建立"c:\code\chromium_git\update.bat"腳本並添加如下代碼:
set CEF_USE_GN=1 set GN_DEFINES=use_jumbo_build=true set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* python ..\automate\automate-git.py --download-dir=c:\code\chromium_git --depot-tools-dir=c:\code\depot_tools --no-distrib --no-build
運行"cmd.exe" 執行腳本"update.bat"並等待CEF和Chromium源代碼下載。CEF源代碼將被下載到"c:\code\chromium_git\cef",Chromium源代碼將被下載到"c:\code\chromium_git\chromium\src",下載完成後,CEF源代碼將被複制到"c:\code\chromium_git\chromium\src\cef"。
cd c:\code\chromium_git update.bat
注:在執行腳本期間遇到下面這個錯誤:
File "..\automate\automate-git.py",line 1163,in <module>
raise Exception("Not a valid CEF Git checkout: %s" %s (cef_dir))
Exception: Not a valid CEF Git checkout: c:\code\chromium_git\cef
能夠嘗試使用下面的方法進行解決( (〜 ̄△ ̄)〜,爲這個先後瞎折騰了好幾個小時 ):
1.刪除"c:\code\depot_tools"文件夾下的全部文件。
2.並再次打開"cmd.exe"運行"update.bat"腳本。
cd c:\code\chromium_git update.bat
安裝 Visual Studio 2017(我選擇的版本: Visual Studio Community 2017.15.7.1)
在選擇Windows Kits時必定要符合官方文檔(Windows 10.0.15063.486 SDK)的建議標準,不然看看這位 前輩 的血淚使吧。