CEF / Chromium 重新編譯2018 官網地址 一路是坑 千萬別跟着官方step by step走一定多思考多查資料 因為改動地方太多了編譯都每個版本都不一樣


CEF/ chromium重新編譯2018 官網地址 一路是坑 千萬別跟着官方step by step走一定多思考多查資料 因為改動地方太多了編譯都每個版本都不一樣
 
參考文章:
Windows下從源碼編譯CEF  
https://blog.csdn.net/foruok/article/details/50498740
 
 帶你玩轉Visual Studio——帶你跳出坑爹的Runtime Library坑 
https://blog.csdn.net/luoweifu/article/details/49055933
 
我記錄有點亂直接看下面這個文章好了,其他信息作為參考. 
 
直接看下面這個文章即可圖文說明我自己的就不寫了基本一致.
https://www.cnblogs.com/Forever-Kenlen-Ja/p/7653144.html
 
Windows上使用GN&Ninja編譯Chromium通用參數配置
https://blog.csdn.net/Vincent95/article/details/78477822
http://magpcss.org/ceforum/viewtopic.php?f=6&t=15687
 
編譯CEF(2171分支) https://blog.csdn.net/sunve_163/article/details/49735895
 
我嘗試編譯當前版本:Current Release Branches (Supported)
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md#markdown-header-release-branches

NowVer[windows]:
Release Branch:3359
Chromium Version:66
Windows Build Requirements:Win 7+, VS2017 15.3.2+, Win10.0.15063.468 SDK, Ninja
 
用到的SDK下載地址
Windows SDK and emulator archive
https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
 
編譯步驟地址:
https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart#markdown-header-windows-setup
 
 
 
 
配置Git
git config --global user.name "My Name"
git config --global user.email "my-name@chromium.org"
git config --global core.autocrlf false
git config --global core.filemode false
git config --global branch.autosetuprebase always


gn gen out\Debug_GN_x86

配置:
\chromium\src\build\config\win\visual_studio_version.gni

修改:
GYP_MSVS_VERSION=2013
修改為:
GYP_MSVS_VERSION=2017
 
Check out your branch
This branch does not contain any changes — check it out on your local machine to do some work.

Check out in Sourcetree

You can also use this command to check out your branch:

git fetch && git checkout 3282

 

 
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
Run the "update.bat" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "c:\code\chromium_git\cef" and Chromium source code will be downloaded to "c:\code\chromium_git\chromium\src". After download completion the CEF source code will be copied to "c:\code\chromium_git\chromium\src\cef".

cd c:\code\chromium_git
update.bat
本機代碼:
cmd.bat
cmd.exe


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=D:\ws\chromium_git --depot-tools-dir=D:\ws\depot_tools --no-distrib --no-build 

改為:

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=D:\ws\chromium_git --depot-tools-dir=D:\ws\depot_tools --no-distrib --no-build --branch=3359


后面改成,--branch=3359 --minimal-distrib --client-distrib --force-clean 
會開始編譯,並且開始runhook


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 --branch=3359 --minimal-distrib --client-distrib --force-clean

set CEF_USE_GN=1
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome enable_precompiled_headers=false 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 --branch=3359 --no-distrib


set CEF_USE_GN=1
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome enable_precompiled_headers=false 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 --branch=3359 --minimal-distrib --client-distrib --force-clean

 

 

gclient can't find visual studio? 

Following the instructions on  https://bitbucket.org/chromiumembedded/ ... dows-setup, after installing MSVS 2015 community edition, as well as the Win 10 SDK, and I'm stuck with an error that seems to indicate that gclient can't find Visual Studio ...

Exception: Visual Studio Version 2015 (from GYP_MSVS_VERSION) not found.
 
請參考:http://magpcss.org/ceforum/viewtopic.php?f=6&t=14292
 
 
 
 
下面是Google自帶翻譯的安裝文 僅供參考
 

檢出並構建Windows的Chromium

獲取代碼鏈接到其他平台的說明

Google員工指南

你是Google員工嗎?請參閱go / building-chrome-win

系統要求

  • 具有至少8GB內存的64位英特爾機器。強烈建議超過16GB。
  • NTFS格式的硬盤上至少有100GB的可用磁盤空間。由於一些Git包文件大於4GB,FAT32將無法工作。
  • 一個合適的Visual Studio版本,如下所述。
  • Windows 7或更新版本。

設置Windows

視覺工作室

截至2017年9月(R503915)Chromium需要Visual Studio 2017更新3.x才能構建。使用clang-cl編譯器,但Visual Studio的頭文件,庫和一些工具是必需的。如果許可證適合您,Visual Studio Community Edition應該可以正常工作。您必須安裝“使用C ++進行桌面開發”組件以及“MFC和ATL支持”子組件。這可以通過將這些參數傳遞給您下載的Visual Studio安裝程序從命令行完成:

- 添加微軟VisualStudio 工作量NativeDesktop - 添加Microsoft VisualStudio 組件VC ATLMFC - includeRecommended 

您必須安裝10.0.15063版本的Windows 10 SDK。這可以單獨安裝或通過選中Visual Studio安裝程序中的相應框來安裝。

SDK調試工具也必須安裝。如果Windows 10 SDK是通過Visual Studio安裝程序安裝的,則可以通過以下方式安裝它們:控制面板→程序→程序和功能→選擇“Windows軟件開發工具包”→更改→更改→選中“Windows調試工具“→更改。或者,您可以下載獨立的SDK安裝程序並使用它來安裝調試工具。

安裝 depot_tools

下載depot_tools包並將其解壓到某處。

警告:  請勿 使用資源管理器中的拖放或復制粘貼提取,它不會提取depot_tools自動更新自身所需的隱藏“.git”文件夾。不過,您可以使用上下文菜單中的“全部提取...”。

將depot_tools添加到PATH的開始處(必須在Python的任何安裝之前)。假設您將軟件包解壓縮到C:\ src \ depot_tools,請打開:

控制面板→系統和安全→系統→高級系統設置

如果您具有管理員訪問權限,請修改PATH系統變量並放在C:\src\depot_tools前面(或者至少在任何可能已經有Python或Git副本的目錄的前面)。

如果您沒有管理員訪問權限,則可以添加用戶級別的PATH環境變量並將其置於C:\src\depot_tools前端,但如果您的系統PATH中包含Python,那么您將不會運氣。

此外,以相同的方式添加DEPOT_TOOLS_WIN_TOOLCHAIN系統變量,並將其設置為0.這將告訴depot_tools使用您本地安裝的Visual Studio版本(默認情況下,depot_tools將嘗試使用谷歌內部版本)。

從cmd.exe shell中運行命令gclient(不帶參數)。第一次運行時,gclient將安裝所有需要使用代碼的Windows特定位,包括msysgit和python。

  • 如果您從非cmd shell(例如,cygwin,PowerShell)運行gclient,它可能會正常運行,但msysgit,python和其他工具可能無法正確安裝。
  • 如果您在第一次運行gclient時發現文件系統出現奇怪的錯誤,則可能需要禁用Windows索引

運行gclient后,打開命令提示符並鍵入where python並確認depot_tools超出python.batpython.exe的任何副本。如果使用gn時未能確保這會導致過度構建 - 請參閱crbug.com/611087

獲取代碼

首先,配置Git:

$ git config - 全局用戶名稱“我的名字”  $ git config - 全局用戶電子郵件“my-name@chromium.org”  $ git config - 全局核心autocrlf false  $ git config - 全局核心filemode false  $ git config - 全局分支始終autosetuprebase 

chromium為結賬創建一個目錄並更改為它(只要完整路徑沒有空格,您可以隨意調用此目錄並將其放在任何位置):

$ mkdir鉻&& cd鉻 

運行該fetch工具depot_tools檢查代碼及其依賴關系。

$取鉻

如果您不想要完整的回購歷史記錄,則可以通過添加--no-history標志來節省大量時間fetch

即使是快速連接,預計該命令也需要30分鍾,在較慢的連接上需要幾個小時。

fetch完成時,它會創建一個隱藏的.gclient文件和一個名為目錄src在工作目錄。其余說明假定您已切換到src目錄:

$ cd src

可選如果您希望構建與某些Google服務對話,則還可以安裝API密鑰,但對於大多數開發和測試目的而言,這不是必需的。

設置構建

Chromium使用忍者作為它的主要構建工具以及稱為GN的工具來生成.ninja文件。您可以創建具有不同配置的任意數量的構建目錄要創建一個構建目錄:

$ gn gen out / 默認
  • 你只需要為每個新建立目錄運行一次,Ninja會根據需要更新構建文件。
  • 你可以Default用另一個名字替換,但它應該是一個子目錄out
  • 有關其他構建參數(包括發布設置),請參閱GN構建配置缺省值將是一個與當前主機操作系統和CPU相匹配的調試組件。
  • 有關GN的更多信息,請gn help在命令行上運行或閱讀快速入門指南

使用Visual Studio IDE

如果您想使用Visual Studio IDE,請在生成輸出目錄時使用--ide命令行參數gn gen(如獲取代碼頁所述):

$ gn gen - ide = vs out \ Default $ devenv out \ Default \ all SLN 

GN將all.sln在您的build目錄中生成一個文件它將在內部使用Ninja進行編譯,同時仍然允許大多數IDE功能工作(沒有本機Visual Studio編譯模式)。如果您再次手動運行“gen”,則需要重新提供此參數,但通常GN會在構建時自動保持構建和IDE文件的最新狀態。

生成的解決方案將包含數千個項目,加載速度非常慢。使用--filters參數限制僅為您感興趣的代碼生成項目文件。雖然這也會限制項目資源管理器中顯示的文件,但調試仍然有效,並且可以在手動打開的文件中設置斷點。一個可讓您在IDE中編譯和運行Chrome的最小解決方案,但不會顯示任何源文件:

$ gn gen --ide = vs --filters = // chrome --no-deps out \ Default

您可以選擇性地將其他目錄關注到過濾器中,如下所示:--filters=//chrome;//third_party/WebKit/*;//gpu/*

還有其他選項用於控制如何生成解決方案,並運行gn help gen當前文檔。

默認情況下,當您在Visual Studio中開始調試時,調試器將只附加到主瀏覽器進程。要調試所有Chrome,請安裝Microsoft的子進程調試強大工具您還需要以管理員身份運行Visual Studio,否則它將默默無法附加到某些Chrome的子進程。

無需解決方案文件,也可以在Visual Studio中調試和開發Chrome。只需File->Open->Project/Solution使用Visual Studio命令提示符“打開”您的chrome.exe二進制文件,如下所示:devenv /debugexe out\Debug\chrome.exe <your arguments>許多Visual Studio的代碼編輯功能在此配置中不起作用,但通過安裝VsChromium Visual Studio Extension,您可以將源代碼與其他有用的功能(如代碼搜索)一起顯示在解決方案資源管理器窗口中。

建造速度更快

  • 通過從防病毒和索引軟件中排除構建目錄來減少文件系統開銷。
  • 將構建樹存儲在快速磁盤(最好是SSD)上。
  • 內核越多越好(20+不會過多),需要大量內存(64 GB不會過多)。

有一些gn標志可以提高構建速度。您可以在創建輸出目錄(gn args out/Default)或gn gen命令行(gn gen out/Default --args="is_component_build = true is_debug = true"時出現的編輯器中指定它們需要考慮的一些有用的設置包括:

  • use_jumbo_build = true實驗 巨無霸/團結建立。
  • is_component_build = true - 這使用更多,更小的DLL和增量鏈接。
  • enable_nacl = false - 這會禁用本地構建通常不需要的Native Client。
  • target_cpu = "x86" - x86構建比x64構建稍快,並支持更多目標的增量鏈接。請注意,如果你設置了這個,但不要'設置enable_nacl = false,那么構建時間可能會變得更糟。
  • remove_webcore_debug_symbols = true - 關閉對blink的源代碼級調試以減少構建時間,如果您不打算調試blink,則適當。

為了確保鏈接足夠快,我們建議您使用以下設置之一 - 它們都有權衡:

  • use_lld = true - 此鏈接器在完整鏈接上速度非常快,但不支持增量鏈接。
  • is_win_fastlink = true - 此選項使Visual Studio鏈接器運行得更快,並支持增量鏈接,但它可能導致調試器速度變慢或內存不足崩潰。
  • symbol_level = 1 - 這個選項減少了鏈接器必須做的工作,但是當這個選項被設置時,你不能進行源碼級的調試。

另外,Google員工應該使用分布式編譯系統goma。詳細信息在內部可用,但相關的gn arg是:

  • use_goma = true

為了從goma中獲得任何好處,將一個很大的-j值傳給忍者很重要。一個很好的默認值是10 * numCores到20 * numCores。如果你運行autoninja,那么它會自動將一個合適的-j值傳遞給忍者,用於goma或不。

$ autoninja - C out \ Default chrome 

當調用忍者時,指定'chrome'作為目標,以避免構建所有的測試二進制文件。

盡管如此,構建將會在很多機器上花費很多時間。

為什么我的構建變慢?

許多事情可以讓構建變得緩慢,而Windows Defender減緩流程初創公司是一個常見的罪魁禍首。您是否確保將整個Chromium src目錄從防病毒掃描中排除(在Google計算機上,這意味着將其放入src驅動器根目錄中)?你是否嘗試了上面列出的不同設置,包括不同的鏈接設置和-j值?您是否在鉻-dev郵件列表上詢問了您的機器規格是否比預期慢?

下一步是收集一些數據。有幾個選項。通過設置NINJA_STATUS,您可以配置Ninja的輸出,例如,您可以看到在任何給定時間有多少個進程正在運行,構建已經運行了多長時間等等,如下所示:

$ set NINJA_STATUS = [%r processes f /%t @ o / s es ]  $ autoninja - C out \ Default base  ninja 進入目錄`out \ Default'     [1進程,86/86 @ 2.7 / s:31.785s] LINK(DLL)base.dll base.dll.lib base.dll.pdb 

另外,如果將NINJA_SUMMARIZE_BUILD環境變量設置為1,那么autoninja將在構建完成時打印構建性能匯總,顯示最慢的構建步驟和構建步驟類型,如下所示:

$ set NINJA_SUMMARIZE_BUILD = 1  $ autoninja - C out \ Default base 最長構建步驟... 1.2 加權s構建基礎DLL 基地DLL lib base DLL pdb 1.2 s CPU時間8.5 加權s來構建obj / base / base / base_jumbo_38 obj 30.1      的CPU時間時間通過構建- 步驟類型... 1.2 小號加權時間,以產生1 PEFile 鏈接的文件1.2 的CPU時間30.3 小號加權時間,以產生45 OBJ文件688.8 的CPU時間31.8 小號加權時間693.8 的CPU時間21.8x 並行86 構建步驟完成平均的2.71 /           小號 

您還可以通過在構建后手動運行腳本來生成這些報告:

$ python depot_tools \ post_build_ninja_summary py - C out \ Default 

您還可以通過ninjatracing獲得構建性能的可視化報告這將.ninja_log文件轉換成可加載到chrome中的.json文件:// tracing

$ python ninjatracing out \ Default \ .ninja_log > build JSON 

最后,忍者可以報告自己的開銷,這可能會有所幫助,例如,如果進程創建使構建變慢,可能是由於叮當聲不在排除目錄中導致的防病毒干擾:

$ autoninja - d stats - C out \默認基本 度量計數avg us  total ms 忍者解析 3555 1539.4 5472.6  canonicalize str 1383032 0.0 12.7  規范化路徑 1402349 0.0 11.2  查找節點 1398245 0.0 8.1 ninja_log load 2 118.0 0.2 ninja_deps加載 2              67.5 0.1  節點stat 2516 29.6 74.4  depfile加載 2 1132.0 2.3 StartEdge 88 3508.1 308.7 FinishCommand 87 1670.9 145.4 CLParser :: Parse 45 1889.1 85.0

建立鉻

使用以下命令與Ninja(或autoninja)構建Chromium(“chrome”目標):

$忍者- C \默認鉻 

您可以gn ls out/Default從命令行運行從GN獲得所有其他構建目標的列表要編譯一個,傳給忍者GN標簽沒有前面的“//”(所以//chrome/test:unit_tests使用ninja -C out /默認chrome / test:unit_tests)。

運行鉻

一旦建成,你可以簡單地運行瀏覽器:

$ out \ Default \ chrome 可執行程序 

(命令中的“.exe”后綴實際上是可選的)。

運行測試目標

您可以用相同的方式運行測試。您還可以限制使用--gtest_filterarg 運行哪些測試,例如:

$ out \ Default \ unit_tests exe - gtest_filter = “PushClientTest。*”

你可以在它的GitHub頁面找到更多關於GoogleTest的信息

更新結帳

要更新現有結帳,您可以運行

$ git rebase - 更新 $ gclient同步 

第一個命令更新主要的Chromium源代碼庫,並在樹的頂端(即Git分支origin/master之上重新綁定任何本地分支如果你不想使用這個腳本,你也可以使用git pull其他常用的Git命令來更新回購。

第二個命令將子庫與適當的版本同步,並根據需要重新運行鈎子。

 
 
 
 
 
 
編譯過程遇到問題零碎筆記:
 
在window編譯步驟中的第八步之前加入一個步驟
gn args out/Default

然后在 args.gn文件最下面加入

ffmpeg_branding = "Chrome"
proprietary_codecs = true

 

GN工具:

https://chromium.googlesource.com/chromium/src/tools/gn/

C:\code\chromium_git\chromium\src\buildtools\win 找個可用的GN工具丟這里去

以下是編譯時候遇到問題咨詢大牛的網友的一些零碎知識點筆記下(僅供參考): 

 

在chromium_grit目錄下的src目錄下用cmd執行這個命令就好

現在chromium的src目錄下執行git stash
然后在chromium執行gclient sync --with_branch_heads
最后執行 gclient runhooks

gclient sync是重新拉取依賴的第三方庫

runhooks是要切換指定的分支

 

Windows Setup

What's Required

  • Windows 7 or newer, 64-bit OS.
  • Visual Studio VS2017 15.3.2+ installed in the default location.
  • Windows 10.0.15063.468 SDK installed in the default location. You must install this exact SDK version to avoid build issues.
  • At least 8GB of RAM and 40GB of free disk space.
  • Approximately 2 hours with a fast internet connection (25Mbps) and fast build machine (2.6Ghz+, 4+ logical cores).

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.

Step-by-step Guide

All of the below commands should be run using the system "cmd.exe" and not a Cygwin shell.

1. Create the following directories.

c:\code\automate
c:\code\chromium_git

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.

2. Download depot_tools.zip and extract to "c:\code\depot_tools". Do not use drag-n-drop or copy-n-paste extract from Explorer, this will not extract the hidden ".git" folder which is necessary for depot_tools to auto-update itself. You can use "Extract all..." from the context menu though. 7-zip is also a good tool for this.

3. Run "update_depot_tools.bat" to install Python, Git and SVN.

cd c:\code\depot_tools
update_depot_tools.bat

4. Add the "c:\code\depot_tools" folder to your system PATH. For example, on Windows 10:

  • Run the "SystemPropertiesAdvanced" command.
  • Click the "Environment Variables..." button.
  • Double-click on "Path" under "System variables" to edit the value.

5. Download the automate-git.py script to "c:\code\automate\automate-git.py".

6. Create the "c:\code\chromium_git\update.bat" script with the following contents.

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

Run the "update.bat" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "c:\code\chromium_git\cef" and Chromium source code will be downloaded to "c:\code\chromium_git\chromium\src". After download completion the CEF source code will be copied to "c:\code\chromium_git\chromium\src\cef".

cd c:\code\chromium_git
update.bat

7. Create the "c:\code\chromium_git\chromium\src\cef\create.bat" script with the following contents.

set CEF_USE_GN=1
set GN_DEFINES=use_jumbo_build=true
set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
call cef_create_projects.bat

這里沒有cef拷貝一個cef過來

Run the "create.bat" script to generate Ninja and Visual Studio project files.

cd c:\code\chromium_git\chromium\src\cef
create.bat

This will generate a "c:\code\chromium_git\chromium\src\out\Debug_GN_x86\cef.sln" file that can be loaded in Visual Studio for debugging and compiling individual files. Replace “x86” with “x64” in this path to work with the 64-bit build instead of the 32-bit build. Always use Ninja to build the complete project. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).

 

第8步這里執行前加一步 弄個GN工具

gn args out/Default
(gn args out\Debug_GN_x86)

 

 

8. Create a Debug build of CEF/Chromium using Ninja. Replace “x86” with “x64” in the below example to generate a 64-bit build instead of a 32-bit build. Edit the CEF source code at "c:\code\chromium_git\chromium\src\cef" and repeat this step multiple times to perform incremental builds while developing.

cd c:\code\chromium_git\chromium\src
ninja -C out\Debug_GN_x86 cef

9. Run the resulting cefclient sample application.

cd c:\code\chromium_git\chromium\src
out\Debug_GN_x86\cefclient.exe

Developers on Windows may wish to use component builds, which are supported in 3202 branch and newer, for faster link times. See issue #1617 for details.

See the Windows debugging guide for detailed debugging instructions.

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM