1. 程式人生 > >在windows上編譯chrome瀏覽器Building Chromium for Windows

在windows上編譯chrome瀏覽器Building Chromium for Windows

web端用webRTC實現的一對一視訊,互動直播和會議。https://github.com/starrtc/android-demo

 

 

 

 

Chromium requires Visual Studio 2017 (15.7.2) to build.

錯誤:Exception: Visual Studio Version 2017 (from GYP_MSVS_VERSION) not found.

安裝“使用C ++進行桌面開發”元件和“MFC和ATL支援”子元件。

 

您必須安裝版本10.0.17134 Windows 10 SDK。可以通過選中Visual Studio Installer中的相應框來安裝。

還必須安裝SDK除錯工具(The SDK Debugging Tools)。如果通過Visual Studio安裝程式安裝了Windows 10 SDK,則可以通過以下方式安裝它們:控制面板→程式→程式和功能→選擇“Windows軟體開發工具包”→更改→更改→檢查“Windows除錯工具(Debugging Tools For Windows)” “→改變。

 

安裝 depot_tools

https://storage.googleapis.com/chrome-infra/depot_tools.zip

新增PATH,放在開頭

 

DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set it to 0.

這告訴depot_tools使用本地安裝的Visual Studio版本(預設情況下,depot_tools將嘗試使用google內部版本)

 

GYP_MSVS_VERSION = 2017

GYP_MSVS_OVERRIDE_PATH = D:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise

 

disable Windows Indexing.

  • Click on “Indexing Options也可以在控制面板中開啟索引選項” that should come up in the search
  • When the Indexing Options box comes up, Click on the Modify button. This will pop up an Indexed Locations dialog, where you should see a list of some “locations”, with your hard drive(s) being in the list.
  • Expand the desired hard drive, down to the root folder of the files you’re using SVN with, and make sure the box is unchecked. Also note that the hard drive will most likely be collapsed, and will have its box unchecked, even though once you expand it, you may find checked boxes.

 

如果有其它版本python,最好先解除安裝掉

 

From a cmd.exe,  run the command gclient (without arguments). On first run, gclient will install all the Windows-specific bits needed to work with the code, including msysgit and python.

 

where python

 

獲取程式碼

首先,配置Git

$ git config --global user.name "My Name" $ git config --global user.email "[email protected]" $ git config --global core.autocrlf false $ git config --global core.filemode false $ git config --global branch.autosetuprebase always

 

mkdir chromium && cd chromium

如果您不想要完整的倉庫歷史記錄,可以通過新增--no-history標記來節省大量時間

fetch --no-history chromium

webrtc 下載只需要把chromium改成webrtc即可,chromium大概有10幾個G,webrtc有6個G左右。

中間斷了的話,可以通過gclient sync來同步程式碼

 

The remaining instructions assume you have switched to the src directory

cd src

use GN to generate .ninja files.

 

gn gen out/Default

out目錄是可以刪除的,剛開始是空的

 

 

autoninja -C out\Default chrome

(花了將近5個小時編譯出來了 chrome.exe 不過又多出來了50多個G的編譯臨時檔案,在out目錄)

傳遞給Ninja,前面沒有“//”(因此//chrome/test:unit_tests使用ninja -C out / Default chrome / test:unit_tests`)。

 

 

run the browser:

$ out\Default\chrome.exe

 

 

update an existing checkout, you can run

在 src同級目錄

$ git rebase-update $ gclient sync

 

生成vs2017解決方案:

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

 

 

之前就有4701多個projects

will be very slow to load.

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

其它:--filters=//chrome;//third_party/WebKit/*;//gpu/*

 

 

 

 

 

 

錯誤:

Exception: Visual Studio Version 2017 (from GYP_MSVS_VERSION) not found.

please supply those settings in a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environment var.

 

 

這個一般是running hooks造成的

在src/DEPS的hooks = [ 區域裡面,這個主要下載一些檔案

因為在老版的指南https://www.chromium.org/developers/how-tos/old-get-the-code裡面有

Run hooks to fetch everything needed for your build setup.

gclient runhooks

 

 

Failed to fetch file gs://chromium-gn/22d302b1658a293a4997205350751ff309b138c9 for src/buildtools/win/gn.exe,

 

gn.exe.sha1裡面內容為

22d302b1658a293a4997205350751ff309b138c9

 

gs:// 替換為 https://storage.googleapis.com/ 就可以直接在瀏覽器下載了。前提當然是你還開著翻牆代理。所以任務就變成了下載下面這個地址的檔案到剛剛那個目錄。

https://storage.googleapis.com/chromium-gn/a68b194afb05d6a6357cf2e2464136ed7723c305

 

wget --no-check-certificate https://storage.googleapis.com/chromium-gn/a68b194afb05d6a6357cf2e2464136ed7723c305 -O src/buildtools/mac/gn

 

 

http://www.debugrun.com/a/86KOtUb.html

https://idom.me/articles/843.html

放在src同級目錄下

chmod +x ./gs

./gs src/DEPS

windows下

node gs.js src/DEPS

 

gs.js

 

 

_downloader_worker_thread使用封裝類gsutil實現對google雲端儲存的訪問。上述程式碼中file_url代表下載的url,是gs://格式的。該方法首先採用gsutil.check_call('ls', file_url)檢查目標檔案是否存在,之後採用gsutil.check_call('cp', file_url, output_filename)將file_url下載到目標檔案output_filename。

上述的方法均要訪問gs://,我們的代理目前訪問不了這個地址,

 

 

 

 

You have unstaged changes.

Please commit, stash, or reset.

 

gclient sync -f

Failed to fetch file gs://chromium-clang-format/c8455d43d052eb79f65d046c6b02c169857b963b for src/buildtools/win/clang-format.exe

 

 

gs://chromium-browser-clang/rc/ba51d69039ffb88310b72b6568efa9f0de148f8f for src/build/toolchain/win/rc/win/rc.exe

 

 

gs://chromium-fonts/a22de844e32a3f720d219e3911c3da3478039f89 for src/third_party/test_fonts/test_fonts.tar.gz

並解壓

 

gs://chromium-browser-clang/orderfiles/f7e302e7d120961ef0cda7faeb1f53bcdad01a33 for src/chrome/build\chrome_child.x86.orderfile

 

gs://chromium-browser-clang/orderfiles/a0ff6a0859090f8a990b54acf18310a9bd8b2c85 for src/chrome/build\chrome_child.x64.orderfile

 

錯誤2

UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position

 

 

mimetypes.py檔案

if sys.getdefaultencoding() != 'gbk':

reload(sys)

sys.setdefaultencoding('gbk')

 

 

chromium的編譯和webrtc的編譯方式相同,webrtc官網也是使用的chromium的編譯文件

 

 

https://www.cnblogs.com/Forever-Kenlen-Ja/p/7653144.html

https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md