武漢網(wǎng)頁制作速成班成都做整站優(yōu)化
Linux CEF(Chromium Embedded Framework)源碼下載編譯
背景
由于CEF默認(rèn)的二進(jìn)制分發(fā)包不支持音視頻播放,需要自行編譯源碼,將ffmpeg開關(guān)打開才能支持。這里介紹的是Linux平臺(tái)下的CEF源碼下載編譯過程。
前置條件
下載的過程非常艱辛,因?yàn)橛残砸蟊容^高。
- 16GB RAM (推薦 32GB+ )
- 120GB SSD硬盤空閑空間起步(避免機(jī)械硬盤)
- 100Mbps帶寬(包括代理帶寬)以及100G以上的代理流量
這里額外說明一下,下載過程總是失敗,大概率原因是因?yàn)榫W(wǎng)絡(luò)的問題,尤其是網(wǎng)絡(luò)帶寬和代理帶寬。這里為什么要單獨(dú)提代理帶寬呢,因?yàn)楣居刑峁┐矸?wù),但是只有10Mbps,所以會(huì)導(dǎo)致下載超時(shí),服務(wù)端關(guān)閉連接。
注意,由于一些因素,下載代碼的環(huán)境是基于WSL,編譯的時(shí)候是在UOS V20 1050系統(tǒng)上,但總體差異不大,相關(guān)路徑會(huì)有區(qū)別,仍有參考價(jià)值。
接下來開始下載CEF的代碼
下載
創(chuàng)建目錄結(jié)構(gòu)
首先,先創(chuàng)建目錄結(jié)構(gòu),最終的目錄結(jié)構(gòu)如下:
~/CEF/automate/automate-git.py <-- CEF build scriptchromium_git/cef/ <-- CEF source checkoutchromium/src/ <-- Chromium source checkoutupdate.[bat|sh] <-- Bootstrap script for automate-git.pydepot_tools/ <-- Chromium build tools
可以使用以下命令,創(chuàng)建目錄
mkdir CEF && cd CEF && mkdir automate && mkdir chromium_git
終端設(shè)置代理
這一步非常重要,因?yàn)樾枰尳K端走代理,才能正常下載代碼
設(shè)置終端代理
export http_proxy=127.0.0.1:7890
export https_proxy=127.0.0.1:7890
通常情況下,這樣就可以了,但由于公司的代理問題,設(shè)置了代理之后,bitbucket.org
域名無法訪問,所以我這里將bitbucket.org
域名排除在外,這一步因人而異,但基本是不需要這一步的。
export no_proxy=localhost,bitbucket.org
驗(yàn)證代理是否設(shè)置成功
leoya@leoya-PC:~$ curl -I https://chromium.googlesource.com
HTTP/1.1 200 Connection establishedHTTP/2 200
content-security-policy: script-src 'nonce-WfQMl6EHcID6PtyTna5LNQ' 'unsafe-inline' 'strict-dynamic' https: http: 'unsafe-eval';object-src 'none';base-uri 'self';report-uri https://csp.withgoogle.com/csp/gerritcodereview/1
content-type: text/html; charset=utf-8
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 0
date: Fri, 30 Jun 2023 02:04:17 GMT
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
這里通過curl去獲取響應(yīng)信息,能獲取到狀態(tài)碼200或者304,即說明訪問正常??梢灶~外對(duì)bitbucket.org
也測試一下,如果訪問失敗,那說明需要將它排除在代理規(guī)則內(nèi),通過上述方法或者代理軟件(如clash)設(shè)置代理規(guī)則為直連即可。
設(shè)置git代理
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
下載腳本
在CEF根目錄下,下載depot_tools,并配置環(huán)境變量
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=/home/leoya/CEF/depot_tools:$PATH
下載automate-git.py腳本,這里需要在CEF/automate目錄下
cd automate/
wget https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py
創(chuàng)建 ~/CEF/chromium_git/update.sh
腳本
#!/bin/bash
python3 ../automate/automate-git.py --download-dir=/home/leoya/CEF/chromium_git --depot-tools-dir=/home/leoya/CEF/depot_tools --no-distrib --no-build
執(zhí)行腳本
設(shè)置權(quán)限并執(zhí)行
chmod 755 update.sh
./update.sh
接下來就是無盡的等待。
這里要特別注意depot_tools的更新進(jìn)度,每次執(zhí)行腳本的時(shí)候,它都會(huì)先更新depot_tools,如果更新狀態(tài)過慢,可能網(wǎng)絡(luò)有問題。
下載cef倉庫的時(shí)候一般是沒什么問題的。
這里最關(guān)鍵的是下載chromium源碼的環(huán)節(jié),因?yàn)槟_本執(zhí)行中斷往往就是在這個(gè)環(huán)節(jié)。因?yàn)榫W(wǎng)絡(luò)穩(wěn)定性、下載速率等問題,導(dǎo)致出錯(cuò)。
當(dāng)你看到Still working on
字樣的時(shí)候,恭喜你,你已經(jīng)邁過了最艱難的環(huán)節(jié),接下來就是下載終端,重試的成本也比較低,因?yàn)椴挥弥匦孪螺dchromium源碼。
接下來見證下載成功的時(shí)刻!!!
報(bào)錯(cuò)信息總結(jié)
以下原因解釋不一定正確,僅供參考
1.
[1:38:14] error: RPC failed; curl 56 GnuTLS recv error (-9):Error decoding the received TLS packet.[1:30:14] fatal:the remote end hung up unexpectedly
[1:30:14] fatail:"early EOF
[1:30:14] fatat: index-pack failed1:30:16]
這里大概率是網(wǎng)絡(luò)不穩(wěn)定導(dǎo)致下載中斷
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: 遠(yuǎn)端意外掛斷了
fatal: 過早的文件結(jié)束符(EOF)
fatal: index-pack 失敗
這個(gè)就是因?yàn)橄螺d速率太慢,導(dǎo)致長時(shí)間占用連接,服務(wù)端就主動(dòng)關(guān)閉了連接。
編譯 CEF
接下來即可修改ffmpeg文件以添加音視頻的支持了
設(shè)置ffmpeg
chromium_git/chromium/src/third_party/ffmpeg/chromium/config/Chromium/linux/x64/config_components.h
文件的宏#define CONFIG_SIPR_PARSER 1
由0設(shè)置為1,即啟用。
生成工程
終端輸入
export GN_DEFINES="use_sysroot=true symbol_level=1 is_cfi=false use_thin_lto=false use_vaapi=false ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true use_gnome_keyring=false chrome_pgo_phase=0"
- ffmpeg_branding和proprietary_codecs 表示開啟多媒體編解碼支持,但默認(rèn)僅支持一小部分,想要支持更多可修改上面 ffmpeg 配置文件。
- is_official_build 決定了是否是編譯正式版本,指定該參數(shù)為 true 基本上都是為了產(chǎn)品發(fā)布使用,同時(shí)也會(huì)在創(chuàng)建解決方案的時(shí)候生成帶有 sandbox 的解決方案,而不指定這個(gè)參數(shù)是沒有的。
- use_jumbo_build 官方資料默認(rèn)指定,表示是否啟用試驗(yàn)性的 jumbo 編譯,編譯過程會(huì)加快很多(至少快 1 小時(shí)),但是占用 CPU 和內(nèi)存(尤其是內(nèi)存)會(huì)劇增。
- is_component_build 官方資料默認(rèn)指定,但我們沒有開啟,這個(gè)參數(shù)表示是否啟用組件化編譯,設(shè)置為 true 以后,base、ffmpeg 等等都會(huì)被編譯為動(dòng)態(tài)庫,使用時(shí)也是動(dòng)態(tài)鏈接,編譯出來的 cef_sandbox 只有幾兆大小,并且你需要復(fù)制很多 dll 文件到項(xiàng)目目錄下才能運(yùn)行。
這里需要注意幾個(gè)參數(shù)use_vaapi如果未設(shè)置為false,即使安裝了vaapi,也會(huì)出現(xiàn)頭文件的一些錯(cuò)誤信息。
chrome_pgo_phase=0 禁用pgo文件。
use_gnome_keyring設(shè)置為false
進(jìn)入code/chromium_git/chromium/src/cef
路徑,執(zhí)行腳本,生成工程文件
./cef_create_projects.sh
問題處理
在生成工程的過程中,我這里遇到了很多錯(cuò)誤,大多是缺失庫。
printing:printing_unittests
ERROR at dynamically parsed input that //printing/BUILD.gn:464:16 loaded :1:1: Invalid token in literal value
-------------------------------------
^
See //BUILD.gn:287:15: which caused the file to be included. deps += [ "//printing:printing_unittests" ]^------------------------------
Traceback (most recent call last): File "tools/gclient_hook.py", line 149, in <module>RunAction(src_dir, cmd)File "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/cef/tools/gclient_util.py", line 36, in RunActioncommand, cwd=dir, always_show_header=True, print_stdout=True)File "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/depot_tools/gclient_utils.py", line 716, in CheckCallAndFilterrv, args, kwargs.get('cwd', None), command_output.getvalue(), None)
subprocess2.CalledProcessError: Command 'gn gen out/Debug_GN_x64' returned non-zero exit status 1 in /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src
ERROR at dynamically parsed input that //printing/BUILD.gn:464:16 loaded :1:1: Invalid token in literal value
-------------------------------------
^
See //BUILD.gn:287:15: which caused the file to be included. deps += [ "//printing:printing_unittests" ]^------------------------------
缺失庫,安裝libcups2-dev庫即可
sudo apt install libcups2-dev
Package glib-2.0 was not found in the pkg-config search path
ERROR at //build/config/linux/pkg_config.gni:104:17: Script returned non-zero exit code.pkgresult = exec_script(pkg_config_script, args, "value")^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Debug_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/build/config/linux/pkg-config.py glib-2.0
Returned 1.
stderr:Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Could not run pkg-config.See //cef/BUILD.gn:2090:5: whence it was called.pkg_config("glib") {^-------------------
See //BUILD.gn:283:15: which caused the file to be included. deps += [ "//cef" ]^------
Traceback (most recent call last): File "tools/gclient_hook.py", line 149, in <module>RunAction(src_dir, cmd)File "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/cef/tools/gclient_util.py", line 36, in RunActioncommand, cwd=dir, always_show_header=True, print_stdout=True)File "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/depot_tools/gclient_utils.py", line 716, in CheckCallAndFilterrv, args, kwargs.get('cwd', None), command_output.getvalue(), None)
subprocess2.CalledProcessError: Command 'gn gen out/Debug_GN_x64' returned non-zero exit status 1 in /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src
ERROR at //build/config/linux/pkg_config.gni:104:17: Script returned non-zero exit code.pkgresult = exec_script(pkg_config_script, args, "value")^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Debug_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/build/config/linux/pkg-config.py glib-2.0
Returned 1.
stderr:Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Could not run pkg-config.See //cef/BUILD.gn:2090:5: whence it was called.pkg_config("glib") {^-------------------
See //BUILD.gn:283:15: which caused the file to be included. deps += [ "//cef" ]
安裝
sudo apt install libglib2.0-dev
Package gnome-keyring-1 was not found in the pkg-config search path.
ERROR at //build/config/linux/pkg_config.gni:104:17: Script returned non-zero exit code.pkgresult = exec_script(pkg_config_script, args, "value")^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Debug_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/build/config/linux/pkg-config.py gnome-keyring-1
Returned 1.
stderr:Package gnome-keyring-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gnome-keyring-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gnome-keyring-1' found
Could not run pkg-config.
這里就是前面提到的需要將use_gnome_keyring設(shè)置為false禁用掉。
終端輸入,將其禁用
export GN_DEFINES="use_sysroot=true symbol_level=1 is_cfi=false use_thin_lto=false use_vaapi=false ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true use_gnome_keyring=false chrome_pgo_phase=0"
Package dbus-1 was not found in the pkg-config search path
ERROR at //build/config/linux/pkg_config.gni:104:17: Script returned non-zero exit code.pkgresult = exec_script(pkg_config_script, args, "value")^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Debug_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/build/config/linux/pkg-config.py dbus-1
Returned 1.
stderr:Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dbus-1' found
Could not run pkg-config.
安裝
sudo apt install libdbus-1-dev
Package nss was not found in the pkg-config search path
ERROR at //build/config/linux/pkg_config.gni:104:17: Script returned non-zero exit code.pkgresult = exec_script(pkg_config_script, args, "value")^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Debug_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/build/config/linux/pkg-config.py nss -v -lssl3
Returned 1.
stderr:Package nss was not found in the pkg-config search path.
Perhaps you should add the directory containing `nss.pc'
to the PKG_CONFIG_PATH environment variable
No package 'nss' found
Could not run pkg-config.
安裝
sudo apt install libnss3-dev
Package libva was not found in the pkg-config search path
ERROR at //build/config/linux/pkg_config.gni:104:17: Script returned non-zero exit code.pkgresult = exec_script(pkg_config_script, args, "value")^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Debug_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/build/config/linux/pkg-config.py libva
Returned 1.
stderr:Package libva was not found in the pkg-config search path.
Perhaps you should add the directory containing `libva.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libva' found
Could not run pkg-config.
安裝
sudo apt install libva-dev
Package gbm was not found in the pkg-config search path
ERROR at //build/config/linux/pkg_config.gni:104:17: Script returned non-zero exit code.pkgresult = exec_script(pkg_config_script, args, "value")^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Debug_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/build/config/linux/pkg-config.py gbm
Returned 1.
stderr:Package gbm was not found in the pkg-config search path.
Perhaps you should add the directory containing `gbm.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gbm' found
Could not run pkg-config.
sudo apt install libgbm-dev
run “gclient runhooks” to download it. You can also simply disable the PGO optimizations by setting |chrome_pgo_phase = 0| in your GN arguments
即pgo文件問題
ERROR at //build/config/compiler/pgo/BUILD.gn:81:23: Script returned non-zero exit code.pgo_data_path = exec_script("//tools/update_pgo_profiles.py",^----------
Current dir: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Release_GN_x64/
Command: python3 /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/tools/update_pgo_profiles.py --target linux get_profile_path
Returned 1.
stderr:Traceback (most recent call last):File "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/tools/update_pgo_profiles.py", line 154, in <module>sys.exit(main())File "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/tools/update_pgo_profiles.py", line 150, in mainreturn args.func(args)File "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/tools/update_pgo_profiles.py", line 122, in _get_profile_pathprofile_path)
RuntimeError: requested profile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/chrome/build/pgo_profiles/chrome-linux-5672-1683023364-b47f9a07c616c94cac9f564aa6b00a8aaaec191a.profdata" doesn't exist, please make sure "checkout_pgo_profiles" is set to True in the "custom_vars" section of your .gclient file, e.g.:
solutions = [ { "name": "src", # ... "custom_vars": { "checkout_pgo_profiles": True, }, },
],
and then run "gclient runhooks" to download it. You can also simply disable the PGO optimizations by setting |chrome_pgo_phase = 0| in your GN arguments.See //build/config/BUILDCONFIG.gn:352:3: which caused the file to be included."//build/config/compiler/pgo:default_pgo_flags",
嘗試了下載pgo文件,但失敗,于是將其chrome_pgo_phase
禁用
export GN_DEFINES="use_sysroot=false symbol_level=1 is_cfi=false use_thin_lto=false use_vaapi=false ffmpeg_branding=Chrome proprietary_codecs=true is_official_build=true use_gnome_keyring=false chrome_pgo_phase=0"
若還是提示此錯(cuò)誤,則可修改chromium_git/chromium/src/build/config/compiler/pgo/pgo.gni
文件,最后的位置處加上chrome_pgo_phase = 0
chrome_pgo_phase = 0if (!dcheck_always_on && is_official_build &&# TODO(crbug.com/1052397): Remove chromeos_is_browser_only once# target_os switch for lacros-chrome is completed.# TODO(crbug.com/1336055): Update this now-outdated condition with regard# to chromecast and determine whether chromeos_is_browser_only is# obsolete.(is_high_end_android || is_win || is_mac || is_fuchsia ||(is_linux && !is_castos && !chromeos_is_browser_only))) {chrome_pgo_phase = 2}
# 手動(dòng)添加chrome_pgo_phase = 0# When using chrome_pgo_phase = 2, read profile data from this path.pgo_data_path = ""
}
當(dāng)問題都解決后,就可以開始編譯源碼了。
開始編譯
到code/chromium_git/chromium/src
路徑下
# debug lib
ninja -C out/Debug_GN_x64 cefclient cefsimple ceftests chrome_sandbox
# release lib
ninja -C out/Release_GN_x64 cefclient cefsimple ceftests chrome_sandbox
這里直接執(zhí)行的第二條命令
在編譯過程中,也會(huì)出現(xiàn)錯(cuò)誤,不過好在是增量編譯,報(bào)錯(cuò)不會(huì)影響已經(jīng)編譯好的產(chǎn)物。
問題處理
gperf錯(cuò)誤
sudo apt install gperf
No module named ‘importlib_metadata’
Traceback (most recent call last):File "../../third_party/blink/renderer/bindings/scripts/generate_bindings.py", line 12, in <module>import bind_genFile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/third_party/blink/renderer/bindings/scripts/bind_gen/__init__.py", line 36, in <module>from .callback_function import generate_callback_functionsFile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/third_party/blink/renderer/bindings/scripts/bind_gen/callback_function.py", line 8, in <module>from .blink_v8_bridge import blink_class_nameFile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py", line 8, in <module>from .code_node import FormatNodeFile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py", line 13, in <module>from .mako_renderer import MakoRendererFile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py", line 7, in <module>import mako.runtimeFile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/third_party/mako/mako/mako/runtime.py", line 14, in <module>from mako import compatFile "/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/third_party/mako/mako/mako/compat.py", line 68, in <module>import importlib_metadata # noqa
ModuleNotFoundError: No module named 'importlib_metadata'
[559/47120] CXX obj/v8/cppgc_base/heap-consistency.o
ninja: build stopped: subcommand failed.
這個(gè)錯(cuò)誤提示是最明顯的了,安裝python的importlib_metadata庫即可
pip3 install importlib_metadata
如果pip命令未找到,那么先安裝pip再執(zhí)行上面的命令
sudo apt install python3-pip
fatal error: ‘pulse/pulseaudio.h’ file not found
gen/media/audio/pulse/pulse_stubs.cc:17:10: fatal error: 'pulse/pulseaudio.h' file not found
#include <pulse/pulseaudio.h>^~~~~~~~~~~~~~~~~~~~
1 error generated.
[6644/46562] CXX obj/extensions/common/api/generated_api_types/networking_private.o
ninja: build stopped: subcommand failed.
sudo apt install libpulse-dev
fatal error: ‘curl/curl.h’ file not found
../../third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc:17:10: fatal error: 'curl/curl.h' file not found
#include <curl/curl.h>^~~~~~~~~~~~~
1 error generated.
[845/39891] CXX obj/third_party/crashpad/crashpad/util/util/metrics.o
ninja: build stopped: subcommand failed.
sudo apt install libcurl4-openssl-dev
fatal error: ‘pci/pci.h’ file not found
../../third_party/angle/src/gpu_info_util/SystemInfo_libpci.cpp:12:10: fatal error: 'pci/pci.h' file not found
#include <pci/pci.h>^~~~~~~~~~~
1 error generated.
[3735/39047] CXX obj/third_party/vulkan-deps/vulkan-validation-layers/src/VkLayer_khronos_validation/chassis.o
ninja: build stopped: subcommand failed.
sudo apt install libpci-dev
fatal error: ‘a(chǎn)lsa/asoundlib.h’ file not found
../../media/midi/midi_manager_alsa.h:8:10: fatal error: 'alsa/asoundlib.h' file not found
#include <alsa/asoundlib.h>^~~~~~~~~~~~~~~~~~
1 error generated.
[4066/35313] CXX obj/media/mojo/mojom/speech_recognition/speech_recognition.mojom.o
ninja: build stopped: subcommand failed.
sudo apt install libasound2-dev
fatal error: ‘gssapi.h’ file not found
../../net/http/http_auth_gssapi_posix.h:26:10: fatal error: 'gssapi.h' file not found
#include <gssapi.h>^~~~~~~~~~
1 error generated.
[483/31248] CXX obj/net/net/http_cache_transaction.o
ninja: build stopped: subcommand failed.
sudo apt install libkrb5-dev
當(dāng)編譯完成時(shí),終端顯示內(nèi)容:
Leou@Leou-PC:/media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src$ ninja -C out/Debug_GN_x64 cefclient cefsimple ceftests chrome_sandbox
ninja: Entering directory `out/Debug_GN_x64'
[57156/57156] LINK ./ceftests
生成CEF二進(jìn)制分發(fā)包
記得選上--x64-build
,否則默認(rèn)為x86,會(huì)提示找不到頭文件。生成的路徑為/code/chromium_git/chromium/src/cef/binary_districhromium/src/cef/binary_distrib
,會(huì)默認(rèn)打包為zip壓縮包
code/chromium_git/chromium/src/cef/tools$
# 打包Release
./make_distrib.sh --ninja-build --minimal --x64-build
生成的包名:
cef_binary_113.3.5+g0b33855+chromium-113.0.5672.129_linux64_minimal
# 同時(shí)打包Debug和Release
./make_distrib.sh --ninja-build --x64-build
生成的包名:
cef_binary_113.3.5+g0b33855+chromium-113.0.5672.129_linux64
ERROR: Please install Doxygen
ERROR: No docs generated.
Traceback (most recent call last):File "make_distrib.py", line 1251, in <module>copy_files_list(build_dir, dst_dir, binaries)File "make_distrib.py", line 325, in copy_files_listraise Exception('Missing required path: %s' % source_path)
Exception: Missing required path: /media/Leou/53e0f2ac-c225-409c-ad9d-0cf8392c641f/code/chromium_git/chromium/src/out/Release_GN_x64/chrome_sandbox
sudo apt install doxygen
當(dāng)然也可以禁用生成doc文檔,就不需要安裝了。
總結(jié)
由于是事后記錄,出錯(cuò)的問題未記錄解決方案難免有疏漏。我在下載、編譯、生成的階段中,都會(huì)出現(xiàn)很多問題,但總體而言,Linux平臺(tái)的CEF源碼編譯還算比較順暢。
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart.md
https://zhuanlan.zhihu.com/p/133675543
https://keqingrong.cn/blog/2021-12-20-building-chromium-on-windows/
https://www.mycode.net.cn/language/cpp/2784.html