1. 程式人生 > >【CEF3編譯】增加對mp3/mp4等格式支持的編譯手記 搭建編譯環境的過程中所遇到的問題(1) 2018-5-19

【CEF3編譯】增加對mp3/mp4等格式支持的編譯手記 搭建編譯環境的過程中所遇到的問題(1) 2018-5-19

代碼 問題 enable img oid bit orm redist def

迫於對現有項目的升級,最近開始考慮更新在項目中所使用到的CEF(Chromium Embedded Framework)瀏覽器庫,但CEF/Chromium出於版權考慮保留了對於mp3/mp4等多媒體格式的支持,沒有對外開放。無奈在各個社區中沒有找到較新的支持mp3/mp4播放的版本,只得自己動手編譯CEF源代碼加入對mp3/mp4等多媒體格式的支持。經過多天的資料收集,發現不少前輩在下載代碼的環節中遇到了很多問題,於是本著避免重蹈覆轍以及盡量減輕外部環境影響的原則,在某農貿市場買了一個"土豆"

來完成本次的CEF編譯工作╮( ̄▽ ̄)╭。

照例,還是先從master分支開始摸索,折騰成功了,再嘗試編譯branche。

環境準備(初定):

1、Windows Server 2016 Standard x64 (官方標準: Windows 7 or newer,64-bit OS)。

2、Visual Studio VS2017 15.3.2+ 安裝在默認位置。

3、Windows 10.0.15063.486 SDK 安裝在默認位置,必須確保SDK的準確版本,以免在後續的編譯過程中出現問題。

4、至少8GB的內存以及40GB的硬盤空間(←_← emmmm....,官方標準,僅做參考),在看了某 前輩 在這個問題上趟過的大坑之後,更改配置為: 16GB內存,以及200GB的硬盤空間。

5、6核處理器 2.59GHz(→_→ 官方標準: 4核處理器 2.6GHz)。

6、保持良好通暢且穩定的網絡環境。

下載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
( ̄3 ̄),如果沒有裝上 Python、Git、SVN 可以嘗試手動安裝(全部使用默認設置一路下一步即可),設置系統環境變量,在"PATH"中分別添加路徑"C:\code\depot_tools" 還有Python、Git、SVN的運行目錄,參照: 技術分享圖片

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)的建議標準,否則看看這位 前輩 的血淚使吧。

下面是我勾選的安裝項目:
  • .NET Framework 4.5 targeting pack
  • .NET Framework 4.6.1 SDK
  • .NET Native
  • .NET Protable Library targeting pack
  • ClickOnce Publishing
  • Developer Analtyics tools
  • NuGet package manager
  • Static analysis tools
  • Text TemplateTrnsformation
  • C# and Visual Bsic Roslyn compilers
  • C++/CLI support
  • MSBuild
  • VC++ 2015.3 v14.00 (v140) toolset for desktop
  • VC++ 2017 version 15.7 v14.14 latest v141 tools
  • Visual C++ 2017 Redistributable Update
  • Visual C++ tools for CMake
  • Windows Universal CRT SDK
  • Windows XP support for C++
  • .NET profiling tools
  • C++ profiling tools
  • JavaScript diagnostics
  • Just-In-Time debugger
  • Test Adapterfor Boost.Test
  • Test Adapter for Google Test
  • Testing tools core features
  • C# and Visual Basic
  • JavaScript nd TypeScript language support
  • Visual Studio C++ core features
  • Visual Studio Tools for Office (VSTO)
  • Graphicsdebugger and GPU profiler for DirectX
  • Image and 3D model editors
  • Graphics Tools Windows 8.1 SDK
  • TypeScript 2.8 SDK
  • Visual C++ ATL (x86/x64) with Spectre Mitigtions
  • Visual C++ ATL for x86 and x64
  • Visual C++ MFC for x86 and x64
  • Visual C++ MFC for x86/x64 with Spectre Mitigations
  • Windows 10 SDK(10.0.15063.0) for Desktop C++ [x86 and x64]
  • Windows 10 SDK(10.0.15063.0) For UWP; C#,VB, JS
  • Windows 10 SDK(10.0.15063.0) For UWP; C++
  • Windows 10 SDK(10.0.17134.0)
  • Windows 8.1 SDK
  • Windows Universal C Runtime

【CEF3編譯】增加對mp3/mp4等格式支持的編譯手記 搭建編譯環境的過程中所遇到的問題(1) 2018-5-19