Linux:chromium.googlesource.com/chromium/sr…javascript
Windows:chromium.googlesource.com/chromium/sr…php
Mac:chromium.googlesource.com/chromium/sr…java
headless模式:chromium.googlesource.com/chromium/sr…python
Vscode配置:chromium.googlesource.com/chromium/sr…linux
源碼查看:source.chromium.org/chromium/ch…c++
GN構建參數:www.chromium.org/developers/…git
安裝上依賴,不安裝會有缺庫等問題。chrome
yum install git python bzip2 tar pkgconfig atk-devel alsa-lib-devel \
bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel \
cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel \
freetype-devel gcc-c++ glib2-devel glibc.i686 gperf glib2-devel gtk2-devel \
gtk3-devel java-1.*.0-openjdk-devel libatomic libcap-devel libffi-devel \
libgcc.i686 libgnome-keyring-devel libjpeg-devel libstdc++.i686 libX11-devel \
libXScrnSaver-devel libXtst-devel libxkbcommon-x11-devel ncurses-compat-libs \
nspr-devel nss-devel pam-devel pango-devel pciutils-devel \
pulseaudio-libs-devel zlib.i686 httpd mod_ssl php php-cli python-psutil wdiff \
xorg-x11-server-Xvfb
複製代碼
git 設置代理:shell
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
複製代碼
全局代理:json
export http_proxy="http://127.0.0.1:1080"
export https_proxy="https://127.0.0.1:1080"
複製代碼
Boto代理設置:
[Boto文件]
proxy=127.0.0.1
proxy_port = 1080
而後設置:
export NO_AUTH_BOTO_CONFIG=/usr/local/dev/chromium/chromium_src/http_proxy.boto(linux)
set NO_AUTH_BOTO_CONFIG=E:\chromium_src\httpproxy.boto (windows)
複製代碼
參考文章: Windows源碼下載編譯:blog.berd.moe/archives/ge…
踩坑文章:blog.wils0n.cn/archives/17…
代理使用心得:blog.csdn.net/Vincent95/a…
爲了不受權和專利的問題,在 Chromium 中是不能直接內置音頻以及視頻解碼器的,因此就形成了默認編譯出來的 Chromium 不能播放音視頻。
解決方法是,在args.gn文件中增長編譯參數
proprietary_codecs = true
ffmpeg_branding = "Chrome"
複製代碼
chromium官方文檔中對此說明
GN Flags
There are a few GN flags which can alter the behaviour of Chromium's HTML5 audio/video implementation.
ffmpeg_branding
Overrides which version of FFmpeg to use
Default: $(branding)
Values:
Chrome - includes additional proprietary codecs (MP3, etc..) for use with Google Chrome
Chromium - builds default set of codecs
proprietary_codecs
Alters the list of codecs Chromium claims to support, which affects <source> and canPlayType() behaviour
Default: 0(gyp)/false(gn)
Values:
0/false - <source> and canPlayType() assume the default set of codecs
1/true - <source> and canPlayType() assume they support additional proprietary codecs
複製代碼
Chromium官方文檔中提供了一些能夠加速編譯的GN編譯項。
symbol_level = 0
blink_symbol_level= 0
enable_nacl = false
複製代碼
is_debug。這個選項值能夠爲true或者false。當爲true時編譯debug版本,false時編譯release版本。
is_component_build。這個選項值能夠爲true或者false。當爲true時將chromium代碼編譯成多個小的dll,false時代碼編譯成單個dll。通常咱們編譯debug版本時,設置is_component_build = true,這樣每次改動編譯連接花費的時間就會減小不少。編譯release版本時,設置is_component_build = false,這樣就能夠把全部代碼編譯到一個dll裏面。
target_cpu。這個選項值爲字符串,控制咱們編譯出的程序所匹配的cpu。編譯32位x86版本設置成target_cpu =」x86″,編譯64位x64版本設置成target_cpu =」x64″。若是咱們沒有顯式指定target_cpu的值,那麼target_cpu的值爲編譯它的電腦所用的cpu類型。一般target_cpu的值爲x86會比x64編譯速度更快,而且支持增量編譯。另外若是設置了target_cpu =」x86″,也必須設置enable_nacl = false,不然編譯速度會慢不少。
enable_nacl。這個選項值能夠爲true或者false。控制是否啓用Native Client,一般咱們並不須要。因此把其值設置成enable_nacl = false。
is_clang。這個選項值能夠爲true或者false。控制是否啓用clang進行編譯。目前m63 clang編譯還不穩定,因此這個選項設置成is_clang = false。m64開始支持clang編譯。
ffmpeg_branding=」Chrome」 proprietary_codecs=true。這個兩個選項是控制代碼編譯支持的多媒體格式跟chrome同樣,支持mp4等格式。
symbol_level。其值爲整數。當值爲0時,不生成調試符號,能夠加快代碼編譯連接速度。當值爲1時,生成的調試符號中不包含源代碼信息,沒法進行源代碼級調試,可是能夠加快代碼編譯連接速度。當值爲2時,生成完整的調試符號,編譯連接時間比較長。
is_official_build。這個選項值能夠爲true或者false。控制是否啓用official編譯模式。official編譯模式會進行代碼編譯優化,很是耗時。僅發佈的時候設置成is_official_build = true開啓優化。
# 生成編譯目錄
gn gen out/Default
# 設置編譯目錄的編譯參數
gn args out/Default
# 查看編譯目錄的編譯參數
gn args --list out/Default
# 啓動編譯
ninja -C out/Default
# headless_shell編譯
ninja -C out/Release headless_shell
複製代碼
##### debug
import("//build/args/headless.gn")
is_component_build = true
is_debug = true
symbol_level = 0
blink_symbol_level= 0
enable_nacl = false
proprietary_codecs = true
ffmpeg_branding = "Chrome"
#### release
import("//build/args/headless.gn")
is_component_build = false
is_debug = false
symbol_level = 0
blink_symbol_level= 0
enable_nacl = false
proprietary_codecs = true
ffmpeg_branding = "Chrome"
複製代碼
chromuim 66 版本之後的內核,在默認狀況下和標籤已經不能自動播放了。須要用戶點擊觸發後才播放,或者要把播放設置爲靜音模式纔可自動播放。
解決方法是,啓動參數中增長--autoplay-policy=no-user-gesture-required來關閉這個默認策略。
chrome:
./out/Default/chrome --headless --no-sandbox --ignore-certificate-errors --ignore-ssl-errors --disable-gpu --disable-software-rasterizer --remote-debugging-port=9222 https://www.baidu.com
複製代碼
headless_shell:
./out/Release/headless_shell --no-sandbox --ignore-certificate-errors --ignore-ssl-errors --disable-gpu --disable-software-rasterizer --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.baidu.com
複製代碼
查看headless_shell進程是否存在
ps -ef | grep headless_shell
複製代碼
關閉headless_shell進程
pkill -f '(chrome)?(--headless)'
複製代碼
調試地址:chrome://inspect/#devices
一些調試接口:
仿照extensions_v8::LoadTimesExtension
在ChromeContentRendererClient的函數RenderThreadStarted()中註冊
thread->RegisterExtension(extensions_v8::XXXXExtension::Get());