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?
Exception: Visual Studio Version 2015 (from GYP_MSVS_VERSION) not found.
檢出並構建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添加到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.bat
python.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_filter
arg 運行哪些測試,例如:
$ out \ Default \ unit_tests 。exe - gtest_filter = “PushClientTest。*”
你可以在它的GitHub頁面找到更多關於GoogleTest的信息。
更新結帳
要更新現有結帳,您可以運行
$ git rebase - 更新 $ gclient同步
第一個命令更新主要的Chromium源代碼庫,並在樹的頂端(即Git分支origin/master
)之上重新綁定任何本地分支。如果你不想使用這個腳本,你也可以使用git pull
其他常用的Git命令來更新回購。
第二個命令將子庫與適當的版本同步,並根據需要重新運行鈎子。
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.