原文地址:http://blog.csdn.net/tiplip/article/details/42047815
下載
-
解壓到本地:D:\Develop\CEF3\cef_binary_3.2526.1361.g456ea5a_windows32
配置
-
下載最新的CMake,比如http://www.onlinedown.net/softdown/254393_2.htm
-
安裝CMake后運行gui,設置使用VC2012,操作過程可參考http://blog.sina.com.cn/s/blog_53b7ddf00101mjo7.html
編譯
-
最后進入D:\Develop\CEF3\cef_binary_3.2526.1361.g456ea5a_windows32\build
-
使用VC2012打開cef.sln,在IDE下build solution
warning C4610/C4510
- typedef const struct __log_rec_spec {
- log_rec_type_t type;
- u_int32_t offset;
- const char *name;
- const char fmt[4];
- } DB_LOG_RECSPEC;
關閉這種警告C/C++,Advanced,Disable Specific Warnings:4100;4127;4244;4481;4512;4701;4702;4996;4510;4610
關於_HAS_EXCEPTIONS
CEF3項目默認的編譯開關是_HAS_EXCEPTIONS=0,這會在有些情況下導致編譯錯誤,比如有些Windows平台上的std庫無法使用而產生的編譯錯誤,這時候需要開啟_HAS_EXCEPTIONS
設置:
_HAS_EXCEPTIONS=1 必須同時設置EHsc
Code Generation --> Enable C++ Exceptions: EHsc
配置命令行commandline
比如使用--disable-web-security,有兩種使用方式
- 啟動:cef.exe --disable-web-security
- 代碼實現:AppendSwitch,
AppendArgument
,在代碼中使用前面的兩個橫線就不需要了,AppendSwitch("disable-gpu")
注意:--disable-web-security有可能會影響屏幕中iframe的尺寸,進而影響到css,@media screen and (max-width : 1024px),比如沒有設置--disable-web-security,@media screen and (max-width : 1024px)中的樣式不會包含到頁面中,如果設置了--disable-web-security,@media screen and (max-width : 1024px)中的樣式就會起作用,從而影響了頁面的顯示
關於iframe
比如我們想知道當前iframe的路徑,使用js怎么做?
html
- <div class="panel-width-start" id="map">
- <iframe allowTransparency=true name="I2" id="site" frameborder="0" src="http://www.58.com/changecity/"></iframe>
- </div>
js
- var currentUrl = document.getElementById("site").contentWindow.location.href;
這樣可以一直獲取到iframe當前頁面的url,運行CEF3必須使用--disable-web-security,否則js執行會失敗,告訴你當前為跨域操作不允許
控件顯示與manifest
如果修改既有的cefclient工程,比如你修改了項目的名稱,可執行exe的文件名,這時需要注意Post-Build Event中需要做相應的修改
mt.exe -nologo -manifest "D:/Develop/CEF3/cef_binary_3.2623.1401.gb90a3be_windows32/cefclient/resources/win/cefclient.exe.manifest" "D:/Develop/CEF3/cef_binary_3.2623.1401.gb90a3be_windows32/cefclient/resources/win/compatibility.manifest" -outputresource:"D:/Develop/CEF3/cef_binary_3.2623.1401.gb90a3be_windows32/build/cefclient/Debug/UI_example.exe";#1
常見問題
- warning C4510:'ATL::_NoAddRefReleaseOnCComPtr<T>' : default constructor could not begenerated
配置時,關閉-DUSE_ATL=Off to CMake
-
error C2220: warning treated as error - no 'object' file generated
解決辦法:參考http://blog.csdn.net/home1410/article/details/6004089
即:報錯的文件頭部添加類似#pragma warning(disable: 4510 4610) // tiplip
編譯錯誤
gdiplusimaging.h(74) error c4430 missing type specifier - int assumed
我在window_test_win.cc中需要用到gdiplus,於是添加#include <gdiplus.h>
編譯報錯
答案:http://stackoverflow.com/questions/3489373/visual-studio-c-2010-express-gets-errors-using-gdi
If you have this line somewhere before the inclusion of <windows.h>
#define WIN32_LEAN_AND_MEAN
Then comment it out.
#define WIN32_LEAN_AND_MEAN啥意思?
支持flash
使用Chrome帶的pepflashplayer.dll
以下兩種方法的版本號可以省去,在CEF3.2623版本上測試有效
啟用命令行
- --ppapi-flash-path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\53.0.2785.143\\PepperFlash\\pepflashplayer.dll" --ppapi-flash-version=23.0.0.162
版本需要對於,比如都是32位的
使用代碼
- command_line->AppendSwitchWithValue("ppapi-flash-path","pepflashplayer.dll");
- //command_line->AppendSwitchWithValue("ppapi-flash-version","23.0.0.162");
具體位置
void ClientAppBrowser::OnBeforeCommandLineProcessing
不使用代理
啟動參數:
--no-proxy-server=1
自定義添加資源resource
cefclient.rc文件
比如添加網頁html文件,手動添加如下一行
- IDS_ORDER_HTML 256 "..\\root_lottery\\order.html"
然后編譯build,會產生新的resource.h文件,如下所述
resource.h文件
有兩處resource.h文件,
\cefclient\resources\win\resource.h,編譯cefclient.rc產生
\cefclient\browser\resource.h,手動修改,數值來自上面的resource.h文件
支持Windows XP
官方論壇顯示,最后一個支持Windows XP的CEF3版本號為,3.2623.1401.gb90a3be
使用VC2012編譯XP版本時,需要選擇Visual Studio 2012 - Windows XP (v110_xp)
這樣編譯出來的exe,如果出現瀏覽器黑屏,可以嘗試啟動選項:--disable-gpu
截屏Screen Capture
參考
測試版本,2924上驗證通過,使用--enable-media-stream --enable-usermedia-screen-capturing
測試網址
https://mgechev.github.io/jscapture/
支持HTTP HTTPS Mixed Content
比如給當前頁面加載資源時,如果頁面本身的url以https開始,那么加載http的資源時會報類似錯誤
- 2 Mixed Content: The page at 'https://www.xxxx.com' was loaded over HTTPS, but requested an insecure script
解決辦法
- command_line->AppendSwitch("allow-running-insecure-content");
Render與Browser的進程間交互
自定義JS函數操作與Browser相關的功能,比如修改窗口,傳遞參數
參考:http://blog.csdn.net/foruok/article/details/50584985
JS binding中傳遞JSON給C++
參數傳遞
參考代碼Cef_message_router.cc (libcef_dll\wrapper) 38985 2016/5/13
- if (name == config_.js_query_function) {
- if (arguments.size() != 1 || !arguments[0]->IsObject()) {
- exception = "Invalid arguments; expecting a single object";
- return true;
- }
- CefRefPtr<CefV8Value> arg = arguments[0];
- CefRefPtr<CefV8Value> requestVal = arg->GetValue(kMemberRequest);
- if (!requestVal.get() || !requestVal->IsString()) {
- exception = "Invalid arguments; object member '"+
- std::string(kMemberRequest) +"' is required and must "
- "have type string";
- return true;
- }
參數類型互換
參考:http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11104#
拖拽截取頁面的圖片
參考問答:http://stackoverflow.com/questions/28099145/creating-a-drag-select-screen-capture-for-google-chrome
demo:http://jsfiddle.net/x2xmjrya/
下載編譯chromium支持MP3/MP4
背景
使用了VPN和http代理
參考
http://www.cnblogs.com/himax/p/how_to_build_cef3_on_windows.html
文件夾結構
設置環境變量
2785及更老版本使用GYP
- DEPOT_TOOLS_WIN_TOOLCHAIN=0
- GYP_DEFINES=buildtype=Official
- GYP_GENERATORS=ninja,msvs-ninja
- GYP_MSVS_VERSION=2015
2785以后的版本使用GN
- CEF_USE_GN=1
- GN_DEFINES=is_official_build=true
- GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
如果需要支持MP3/MP4
- set CEF_USE_GN=1
- set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
- set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
- call cef_create_projects.bat
注意:編譯過程中,最好關閉其他程序,因為最新official版本的編譯需要占用大量的內存RAM,> 8G,理想的內存最好是 14G
以及Path
- Control Panel → System and Security → System → Advanced system settings
- Modify the PATH system variable to include D:\Work_area\CEF3\depot_tools
編譯過程命令匯總
首次編譯
- d:
- cd Work_area\CEF3
- set http_proxy=http://cn-proxy.jp.oracle.com:80
- gclient
- git config --global http.proxy %http_proxy%
- python automate-git.py --download-dir=D:\Work_area\CEF3\source --depot-tools-dir=D:\Work_area\CEF3\depot_tools --branch=2623 --checkout=b90a3be1860b0647e8a62c218ff7c054390365b1 --no-build
按照這個命令步驟,如果遇到問題
修改個別文件后的編譯
直接在第一層目錄下執行
- python automate-git.py --download-dir=c:\src\source --depot-tools-dir=c:\src\depot_tools --branch=2623 --checkout=b90a3be1860b0647e8a62c218ff7c054390365b1 --force-build
編譯參數說明
- set http_proxy=http://www-proxy.us.oracle.com:80
- gclient
- git config --global http.proxy %http_proxy%
- python automate-git.py --download-dir=c:\src\source --depot-tools-dir=c:\src\depot_tools --branch=2623 --checkout=b90a3be1860b0647e8a62c218ff7c054390365b1 --force-build
- --branch=XXXX 指定cef的branch,指定后,會默認下載該branch的cef,以及最新版本的chromium再自動切換到對應版本
- --checkout 手動指定cef的commit(可選參數)
- --chromium-checkout 手動指定chromium的版本(可選參數)
- --no-debug-build 不生成Debug版本,即不生成開發需要的libcef_dll_wrapper庫(可選參數)
- --force-clean 強制清除所有chromium的生成項,將源碼回檔到未編譯前,清除后需要重新下載(可選參數)
- --force-build 強制進行編譯,重新開始或者繼續之前的工作(可選參數)
- --no-update 不再更新cef和chromium(可選參數)
可能遇到的錯誤及解決辦法
執行gclient出現如下錯誤:
- C:\Windows\System32>gclient
- Installing python 2.7.6...
- Fetching from https://src.chromium.org/svn/trunk/tools/third_party/python276_bin
- .zip
- [-] XMLHTTP 80072ee2: Cannot make HTTP request (操作超時
- ... Failed to checkout python automatically.
- You should get the "prebaked" version at https://src.chromium.org/svn/trunk/tool
- s/third_party/
- 系統找不到指定的路徑。
說明當前你的電腦可能是通過代理訪問的,需要修改depot_tools\bootstrap\win\get_file.js如下:
- function Download(url, path, verbose) {
- if (verbose) {
- WScript.StdOut.Write(" * GET " + url + "...");
- }
- try {
- xml_http = new ActiveXObject("MSXML2.ServerXMLHTTP");
- } catch (e) {
- WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
- ": Cannot create Active-X object (" + e.description) + ").";
- WScript.Quit(1);
- }
- try {
- xml_http.open("GET", url, false);
- } catch (e) {
- WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
- ": invalid URL.");
- WScript.Quit(1);
- }
改為
- function Download(url, path, verbose) {
- if (verbose) {
- WScript.StdOut.Write(" * GET " + url + "...");
- }
- try {
- xml_http = new ActiveXObject("MSXML2.ServerXMLHTTP.6.0");
- } catch (e) {
- WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
- ": Cannot create Active-X object (" + e.description) + ").";
- WScript.Quit(1);
- }
- try {
- xml_http.setProxy(2, "cn-proxy.jp.oracle.com:80");
- xml_http.open("GET", url, false);
- } catch (e) {
- WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
- ": invalid URL.");
- WScript.Quit(1);
- }
執行
- python automate-git.py
錯誤
- python automate-git.py --download-dir=D:\Develop\CEF3\Compile\source --depot-tools-dir=D:\Develop\CEF3\Compile\depot_tools --branch=2357 --checkout=d66017718b0f0d44da42b706c3c2aa5c0c103852 --no-build
- D:\Develop\CEF3\Compile>python automate-git.py --download=D:\Develop\CEF3\Compil
- e\source --depot-tools-dir=D:\Develop\CEF3\Compile\depot_tools --branch=2357 --n
- o-build
- --> Download Directory: D:\Develop\CEF3\Compile\source
- --> Depot Tools Directory: D:\Develop\CEF3\Compile\depot_tools
- --> Updating depot_tools
- -------- Running "update_depot_tools.bat" in "D:\Develop\CEF3\Compile\depot_tool
- s"...
- fatal: unable to access 'https://chromium.googlesource.com/chromium/tools/depot_
- tools.git/': Failed connect to chromium.googlesource.com:443; No error
- Cannot rebase: You have unstaged changes.
- Please commit or stash them.
- Failed to update depot_tools.
- --> CEF Branch: 2357
- --> CEF URL: https://bitbucket.org/chromiumembedded/cef.git
- --> CEF Source Directory: D:\Develop\CEF3\Compile\source\cef
- -------- Running "D:\Develop\CEF3\Compile\depot_tools\git.bat clone https://bitb
- ucket.org/chromiumembedded/cef.git D:\Develop\CEF3\Compile\source\cef" in "D:\De
- velop\CEF3\Compile\source"...
- Cloning into 'D:\Develop\CEF3\Compile\source\cef'...
- fatal: unable to access 'https://bitbucket.org/chromiumembedded/cef.git/': Faile
- d connect to bitbucket.org:443; No error
- Traceback (most recent call last):
- File "automate-git.py", line 662, in <module>
- depot_tools_dir)
- File "automate-git.py", line 55, in run
- shell=(sys.platform == 'win32'))
- File "D:\Develop\CEF3\Compile\depot_tools\python276_bin\lib\subprocess.py", li
- ne 540, in check_call
- raise CalledProcessError(retcode, cmd)
- subprocess.CalledProcessError: Command '['D:\\Develop\\CEF3\\Compile\\depot_tool
- s\\git.bat', 'clone', 'https://bitbucket.org/chromiumembedded/cef.git', 'D:\\Dev
- elop\\CEF3\\Compile\\source\\cef']' returned non-zero exit status 128
執行gclient前設置代理
- Microsoft Windows [版本 6.1.7601]
- 版權所有 (c) 2009 Microsoft Corporation。保留所有權利。
- C:\windows\system32>netsh
- netsh>winhttp
- netsh winhttp>show proxy
- 當前的 WinHTTP 代理服務器設置:
- 代理服務器: http=cn-proxy.jp.oracle.com
- 繞過列表 : (無)
- netsh winhttp>set proxy cn-proxy.jp.oracle.com:80
- 當前的 WinHTTP 代理服務器設置:
- 代理服務器: cn-proxy.jp.oracle.com:80
- 繞過列表 : (無)
- netsh winhttp>exit
- C:\windows\system32>set http_proxy=http://cn-proxy.jp.oracle.com:80
- C:\windows\system32>git config -global http.proxy %http_proxy%
- error: did you mean `--global` (with two dashes ?)
- C:\windows\system32>git config --global http.proxy %http_proxy%
- C:\windows\system32>git config --get http.proxy
- http://cn-proxy.jp.oracle.com:80
- C:\windows\system32>d:
- D:\>cd Develop\CEF3\Compile
- D:\Develop\CEF3\Compile>python automate-git.py --download-dir=D:\Develop\CEF3\Co
- mpile\source --depot-tools-dir=D:\Develop\CEF3\Compile\depot_tools --branch=2357
- --checkout=d66017718b0f0d44da42b706c3c2aa5c0c103852 --no-build
- --> Download Directory: D:\Develop\CEF3\Compile\source
- --> Depot Tools Directory: D:\Develop\CEF3\Compile\depot_tools
- --> Updating depot_tools
- -------- Running "update_depot_tools.bat" in "D:\Develop\CEF3\Compile\depot_tool
- s"...
- Cannot rebase: You have unstaged changes.
- Please commit or stash them.
- Failed to update depot_tools.
- --> CEF Branch: 2357
- --> CEF URL: https://bitbucket.org/chromiumembedded/cef.git
- --> CEF Source Directory: D:\Develop\CEF3\Compile\source\cef
- -------- Running "D:\Develop\CEF3\Compile\depot_tools\git.bat clone https://bitb
- ucket.org/chromiumembedded/cef.git D:\Develop\CEF3\Compile\source\cef" in "D:\De
- velop\CEF3\Compile\source"...
- Cloning into 'D:\Develop\CEF3\Compile\source\cef'...
- remote: Counting objects: 32815, done.
- remote: Compressing objects: 100% (8915/8915), done.
- remote: Total 32815 (delta 27309), reused 28831 (delta 23803)
- Receiving objects: 100% (32815/32815), 9.83 MiB | 789.00 KiB/s, done.
- Resolving deltas: 100% (27309/27309), done.
- Checking connectivity... done.
- -------- Running "D:\Develop\CEF3\Compile\depot_tools\git.bat rev-parse HEAD" in
- "D:\Develop\CEF3\Compile\source\cef"...
- -------- Running "D:\Develop\CEF3\Compile\depot_tools\git.bat rev-parse d6601771
- 8b0f0d44da42b706c3c2aa5c0c103852" in "D:\Develop\CEF3\Compile\source\cef"...
- --> CEF Current Checkout: 6d7ee1e08439672050c2c5bd022fbcc2e79770d4
- --> CEF Desired Checkout: d66017718b0f0d44da42b706c3c2aa5c0c103852 (d66017718b0f
- 0d44da42b706c3c2aa5c0c103852)
- -------- Running "D:\Develop\CEF3\Compile\depot_tools\git.bat checkout d66017718
- b0f0d44da42b706c3c2aa5c0c103852" in "D:\Develop\CEF3\Compile\source\cef"...
- Checking out files: 100% (1049/1049), done.
- Note: checking out 'd66017718b0f0d44da42b706c3c2aa5c0c103852'.
- You are in 'detached HEAD' state. You can look around, make experimental
- changes and commit them, and you can discard any commits you make in this
- state without impacting any branches by performing another checkout.
- If you want to create a new branch to retain commits you create, you may
- do so (now or later) by using -b with the checkout command again. Example:
- git checkout -b new_branch_name
- HEAD is now at d660177... Update to Chromium version 43.0.2357.130
- --> CEF Output Directory: D:\Develop\CEF3\Compile\source\out_2357
- --> Creating directory D:\Develop\CEF3\Compile\source\chromium
- --> Writing file: D:\Develop\CEF3\Compile\source\chromium\.gclient
- -------- Running "gclient sync --nohooks --with_branch_heads --jobs 16" in "D:\D
- evelop\CEF3\Compile\source\chromium"...
- Cannot rebase: You have unstaged changes.
- Please commit or stash them.
- Failed to update depot_tools.
- [0:01:00] Still working on:
- [0:01:00] src
- [0:01:14] Still working on:
- [0:01:14] src
- [0:01:25] Still working on:
- [0:01:25] src
- [0:01:35] Still working on:
- [0:01:35] src
- [0:01:45] Still working on:
cipd.ps1錯誤
遇到如下紅字的錯誤可以忽略
- The term 'git' is not recognized as the name of a cmdlet, function, script file
- , or operable program. Check the spelling of the name, or if a path was include
- d, verify that the path is correct and try again.
- At C:\src\depot_tools\cipd.ps1:31 char:25
- + $depot_tools_version = & <<<< git -C $myPath rev-parse HEAD 2>&1
- + CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFound
- Exception
- + FullyQualifiedErrorId : CommandNotFoundException
獲取代碼及依賴工具
報錯
- 0> Failed to fetch file gs://chromium-gn/14b37907020b299b5c6bfae1d7fed7d7a92e4fe
- 6 for src/buildtools/win/gn.exe, skipping. [Err: Traceback (most recent call las
- t):
- File "c:\src\depot_tools\gsutil.py", line 160, in <module>
- sys.exit(main())
- File "c:\src\depot_tools\gsutil.py", line 157, in main
- clean=args.clean)
- File "c:\src\depot_tools\gsutil.py", line 125, in run_gsutil
- gsutil_bin = ensure_gsutil(force_version, target, clean)
- File "c:\src\depot_tools\gsutil.py", line 107, in ensure_gsutil
- target_zip_filename = download_gsutil(version, instance_dir)
- File "c:\src\depot_tools\gsutil.py", line 62, in download_gsutil
- u = urllib2.urlopen(url)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 127, in urlopen
- return _opener.open(url, data, timeout)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 404, in open
- response = self._open(req, data)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 422, in _open
- '_open', req)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 382, in _call_cha
- in
- result = func(*args)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 1222, in https_op
- en
- return self.do_open(httplib.HTTPSConnection, req)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 1184, in do_open
- raise URLError(err)
- urllib2.URLError: <urlopen error [Errno 10060] A connection attempt failed becau
- se the connected party did not properly respond after a period of time, or estab
- lished connection failed because connected host has failed to respond>
- ]
- Downloading 1 files took 21.630000 second(s)
- NOTICE: You have PROXY values set in your environment, but gsutil in depot_tools
- does not (yet) obey them.
- Also, --no_auth prevents the normal BOTO_CONFIG environment variable from being
- used.
- To use a proxy in this situation, please supply those settings in a .boto file p
- ointed to by the NO_AUTH_BOTO_CONFIG environment var.
- Failed to fetch file gs://chromium-gn/14b37907020b299b5c6bfae1d7fed7d7a92e4fe6 f
- or src/buildtools/win/gn.exe. [Err: Traceback (most recent call last):
- File "c:\src\depot_tools\gsutil.py", line 160, in <module>
- sys.exit(main())
- File "c:\src\depot_tools\gsutil.py", line 157, in main
- clean=args.clean)
- File "c:\src\depot_tools\gsutil.py", line 125, in run_gsutil
- gsutil_bin = ensure_gsutil(force_version, target, clean)
- File "c:\src\depot_tools\gsutil.py", line 107, in ensure_gsutil
- target_zip_filename = download_gsutil(version, instance_dir)
- File "c:\src\depot_tools\gsutil.py", line 62, in download_gsutil
- u = urllib2.urlopen(url)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 127, in urlopen
- return _opener.open(url, data, timeout)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 404, in open
- response = self._open(req, data)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 422, in _open
- '_open', req)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 382, in _call_cha
- in
- result = func(*args)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 1222, in https_op
- en
- return self.do_open(httplib.HTTPSConnection, req)
- File "c:\src\depot_tools\python276_bin\lib\urllib2.py", line 1184, in do_open
- raise URLError(err)
- urllib2.URLError: <urlopen error [Errno 10060] A connection attempt failed becau
- se the connected party did not properly respond after a period of time, or estab
- lished connection failed because connected host has failed to respond>
- ]
- Error: Command 'download_from_google_storage --no_resume --platform=win32 --no_a
- uth --bucket chromium-gn -s src/buildtools/win/gn.exe.sha1' returned non-zero ex
- it status 1 in c:\src\source\chromium
- Hook 'download_from_google_storage --no_resume --platform=win32 --no_auth --buck
- et chromium-gn -s src/buildtools/win/gn.exe.sha1' took 23.11 secs
- Traceback (most recent call last):
- File "automate-git.py", line 879, in <module>
- chromium_dir, depot_tools_dir)
- File "automate-git.py", line 55, in run
- shell=(sys.platform == 'win32'))
- File "C:\src\depot_tools\python276_bin\lib\subprocess.py", line 540, in check_
- call
- raise CalledProcessError(retcode, cmd)
- subprocess.CalledProcessError: Command '['gclient', 'sync', '--with_branch_heads
- ', '--jobs', '16']' returned non-zero exit status 2
批處理腳本RunDownloads.py.bat
注意代理https不是http
- @rem When Run Command [gclient runhooks]
- @rem Download_Failed===========================
- @rem download_from_google_storage --no_resume --platform=win32 --directory --recursive --no_auth --num_threads=16 --bucket chromium-apache-win32 --boto=E:\_ChromiumDev\gclient_chromium_src\.boto src/third_party/apache-win32
- @rem Download_Failed===========================
- set <span style="color:#FF0000;">https</span>_proxy=http://cn-proxy.jp.oracle.com:80
- call RunWget.bat gs://chromium-gn/14b37907020b299b5c6bfae1d7fed7d7a92e4fe6 src/buildtools/win/gn.exe
- cmd
RunWget.bat
需要設置wget的環境變量路徑Path,
SRC_DIR要根據自己的代碼路徑設置
- @echo off
- if "%1"=="" goto error
- @rem ##########
- @rem 2> File gs://chromium-apache-win32/11ba0c1941b9c46ad279f33c2db3e3c628197ae8 for
- @rem src/third_party/apache-win32\bin\httpd.exe does not exist, skipping.
- @rem 3> File gs://chromium-apache-win32/199cb003a5a40db260f29128ae630f298aaf7702 for
- @rem src/third_party/apache-win32\bin\libapriconv-1.dll does not exist, skipping.
- @rem ##########
- set SRC_DIR=D:\Work_area\CEF3\source\chromium
- @rem set param1=gs://chromium-apache-win32/11ba0c1941b9c46ad279f33c2db3e3c628197ae8
- @rem set param2=src/third_party/apache-win32\bin\httpd.exe
- set param1=%1
- set param2=%2
- echo [INFO][%time%] ==========Begin==================
- echo [INFO][%time%] gs_url=%param1%
- set baseurl=https://storage.googleapis.com/
- set baseurl=%baseurl%%param1:~5%
- echo [INFO][%time%] httpBaseUrl=%baseurl%
- :StartDownload
- @rem 進行一次 文件是否 覆蓋的用戶交互
- pushd .
- cd %SRC_DIR%
- set cover
- if "%cover%"=="" set cover=2
- if exist %param2% (
- if %cover%==2 (
- set /p cover=文件已存在,是否覆蓋?[0=不覆蓋 1=覆蓋]:
- )
- )
- popd
- if not exist %param2% (
- goto :continue
- )
- if %cover%==1 goto :continue
- echo [INFO][%time%]================END================
- goto :eof
- :continue
- pushd .
- cd %SRC_DIR%
- wget --no-check-certificate %baseurl% -O %param2%
- echo [%time%][SUCCESS] Dwonloads to url:%param2% success!!!
- echo [INFO][%time%]===============END=================
- popd
- goto :eof
- :error
- echo Help:
- echo %0 [gs://name/hash] [saveToPath]
- pause
各個文件的相對位置結構
開始編譯
錯誤skedge.cpp(231) warning C4334
- [4453/15559] CXX obj\third_party\skia\src\core\skia_library.SkEdge.obj
- FAILED: obj/third_party/skia/src/core/skia_library.SkEdge.obj
- ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Stu
- dio 14.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\ski
- a\src\core\skia_library.SkEdge.obj.rsp /c ..\..\third_party\skia\src\core\SkEdge
- .cpp /Foobj\third_party\skia\src\core\skia_library.SkEdge.obj /Fdobj\skia\skia_l
- ibrary.cc.pdb
- c:\src\source\chromium\src\third_party\skia\src\core\skedge.cpp(231): error C222
- 0: warning treated as error - no 'object' file generated
- c:\src\source\chromium\src\third_party\skia\src\core\skedge.cpp(231): warning C4
- 334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit sh
- ift intended?)
- [4458/15559] CXX obj\third_party\skia\src\core\skia_library.SkFlattenable.obj
- ninja: build stopped: subcommand failed.
- Traceback (most recent call last):
- File "automate-git.py", line 980, in <module>
- if options.buildlogfile else None)
- File "automate-git.py", line 55, in run
- shell=(sys.platform == 'win32'))
- File "C:\src\depot_tools\python276_bin\lib\subprocess.py", line 540, in check_
- call
- raise CalledProcessError(retcode, cmd)
- subprocess.CalledProcessError: Command '['ninja', '-C', 'out\\Debug', 'cefclient
- ']' returned non-zero exit status 1
解決
在文件source\chromium\src\skia\skia_common.gypi
\source\chromium\src\google_apis\google_apis.gyp
- # We would prefer this to be direct_dependent_settings,
- # however we currently have no means to enforce that direct dependents
- # re-export if they include Skia headers in their public headers.
- 'all_dependent_settings': {
- 'include_dirs': [
- '..',
- 'config',
- ],
- },
- 'msvs_disabled_warnings': [4244, 4267,<span style="color:#FF6666;"><strong> <span style="color:#FF0000;">4334</span></strong></span>, 4341, 4345, 4390, 4554, 4748, 4800],
error C2679
解決:gl_bindings_skia_in_process.cc和 gl_bindings_skia_in_process.hh已經死代碼了。
ui/gl/BUILD.gn和gl.gyp去除這兩個引用詳見https://codereview.chromium.org/1673323002
- FAILED: obj/ui/gl/gl.gl_bindings_skia_in_process.obj
- ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Stu
- dio 14.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\ui\gl\gl.gl_bin
- dings_skia_in_process.obj.rsp /c ..\..\ui\gl\gl_bindings_skia_in_process.cc /Foo
- bj\ui\gl\gl.gl_bindings_skia_in_process.obj /Fdobj\ui\gl\gl.cc.pdb
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(860): error C267
- 9: binary '=': no operator found which takes a right-hand operand of type 'overl
- oaded-function' (or there is no acceptable conversion)
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: could be 'GrGLInterface::GLPtr<GrGLBufferDataProc> &GrGLInterface::GLPtr<
- GrGLBufferDataProc>::operator =(GrGLInterface::GLPtr<GrGLBufferDataProc> &&)'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: or 'GrGLInterface::GLPtr<GrGLBufferDataProc> &GrGLInterface::GLPtr<
- GrGLBufferDataProc>::operator =(const GrGLInterface::GLPtr<GrGLBufferDataProc> &
- )'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(112):
- note: or 'GrGLInterface::GLPtr<GrGLBufferDataProc> GrGLInterface::GLPtr<G
- rGLBufferDataProc>::operator =(FNPTR_TYPE)'
- with
- [
- FNPTR_TYPE=GrGLBufferDataProc
- ]
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(860): note: whil
- e trying to match the argument list '(GrGLInterface::GLPtr<GrGLBufferDataProc>,
- overloaded-function)'
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(861): error C267
- 9: binary '=': no operator found which takes a right-hand operand of type 'overl
- oaded-function' (or there is no acceptable conversion)
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: could be 'GrGLInterface::GLPtr<GrGLBufferSubDataProc> &GrGLInterface::GLP
- tr<GrGLBufferSubDataProc>::operator =(GrGLInterface::GLPtr<GrGLBufferSubDataProc
- > &&)'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: or 'GrGLInterface::GLPtr<GrGLBufferSubDataProc> &GrGLInterface::GLP
- tr<GrGLBufferSubDataProc>::operator =(const GrGLInterface::GLPtr<GrGLBufferSubDa
- taProc> &)'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(112):
- note: or 'GrGLInterface::GLPtr<GrGLBufferSubDataProc> GrGLInterface::GLPt
- r<GrGLBufferSubDataProc>::operator =(FNPTR_TYPE)'
- with
- [
- FNPTR_TYPE=GrGLBufferSubDataProc
- ]
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(861): note: whil
- e trying to match the argument list '(GrGLInterface::GLPtr<GrGLBufferSubDataProc
- >, overloaded-function)'
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(891): error C267
- 9: binary '=': no operator found which takes a right-hand operand of type 'overl
- oaded-function' (or there is no acceptable conversion)
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: could be 'GrGLInterface::GLPtr<GrGLFlushMappedBufferRangeProc> &GrGLInter
- face::GLPtr<GrGLFlushMappedBufferRangeProc>::operator =(GrGLInterface::GLPtr<GrG
- LFlushMappedBufferRangeProc> &&)'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: or 'GrGLInterface::GLPtr<GrGLFlushMappedBufferRangeProc> &GrGLInter
- face::GLPtr<GrGLFlushMappedBufferRangeProc>::operator =(const GrGLInterface::GLP
- tr<GrGLFlushMappedBufferRangeProc> &)'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(112):
- note: or 'GrGLInterface::GLPtr<GrGLFlushMappedBufferRangeProc> GrGLInterf
- ace::GLPtr<GrGLFlushMappedBufferRangeProc>::operator =(FNPTR_TYPE)'
- with
- [
- FNPTR_TYPE=GrGLFlushMappedBufferRangeProc
- ]
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(891): note: whil
- e trying to match the argument list '(GrGLInterface::GLPtr<GrGLFlushMappedBuffer
- RangeProc>, overloaded-function)'
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(920): error C267
- 9: binary '=': no operator found which takes a right-hand operand of type 'overl
- oaded-function' (or there is no acceptable conversion)
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: could be 'GrGLInterface::GLPtr<GrGLMapBufferRangeProc> &GrGLInterface::GL
- Ptr<GrGLMapBufferRangeProc>::operator =(GrGLInterface::GLPtr<GrGLMapBufferRangeP
- roc> &&)'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(116):
- note: or 'GrGLInterface::GLPtr<GrGLMapBufferRangeProc> &GrGLInterface::GL
- Ptr<GrGLMapBufferRangeProc>::operator =(const GrGLInterface::GLPtr<GrGLMapBuffer
- RangeProc> &)'
- c:\src\source\chromium\src\third_party\skia\include\gpu\gl\grglinterface.h(112):
- note: or 'GrGLInterface::GLPtr<GrGLMapBufferRangeProc> GrGLInterface::GLP
- tr<GrGLMapBufferRangeProc>::operator =(FNPTR_TYPE)'
- with
- [
- FNPTR_TYPE=GrGLMapBufferRangeProc
- ]
- c:\src\source\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(920): note: whil
- e trying to match the argument list '(GrGLInterface::GLPtr<GrGLMapBufferRangePro
- c>, overloaded-function)'
- [757/7473] CXX obj\ui\gl\gl.gl_bindings_autogen_gl.obj
- ninja: build stopped: subcommand failed.
- Traceback (most recent call last):
- File "automate-git.py", line 980, in <module>
- if options.buildlogfile else None)
- File "automate-git.py", line 55, in run
- shell=(sys.platform == 'win32'))
- File "C:\src\depot_tools\python276_bin\lib\subprocess.py", line 540, in check_
- call
- raise CalledProcessError(retcode, cmd)
- subprocess.CalledProcessError: Command '['ninja', '-C', 'out\\Debug', 'cefclient
- ']' returned non-zero exit status 1
error C4430
#解決egl語法錯誤
#修改h:\ws\source\chromium\src\third_party\swiftshader\include\egl\eglext.h
#在62行后加入
typedef EGLAttribKHR EGLAttrib;
- FAILED: obj/ui/gl/gl.egl_util.obj
- ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Stu
- dio 14.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\ui\gl\gl.egl_ut
- il.obj.rsp /c ..\..\ui\gl\egl_util.cc /Foobj\ui\gl\gl.egl_util.obj /Fdobj\ui\gl\
- gl.cc.pdb
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(119): er
- ror C4430: missing type specifier - int assumed. Note: C++ does not support defa
- ult-int
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(119): er
- ror C2143: syntax error: missing ',' before '*'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(120): er
- ror C2061: syntax error: identifier 'EGLAttrib'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(515): er
- ror C2061: syntax error: identifier 'EGLAttrib'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(518): er
- ror C2061: syntax error: identifier 'EGLAttrib'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(585): er
- ror C4430: missing type specifier - int assumed. Note: C++ does not support defa
- ult-int
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(585): er
- ror C2143: syntax error: missing ',' before '*'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(586): er
- ror C4430: missing type specifier - int assumed. Note: C++ does not support defa
- ult-int
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(586): er
- ror C2143: syntax error: missing ',' before '*'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(587): er
- ror C2061: syntax error: identifier 'EGLAttrib'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(588): er
- ror C2061: syntax error: identifier 'EGLAttrib'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(590): er
- ror C2061: syntax error: identifier 'EGLAttrib'
- c:\src\source\chromium\src\third_party\swiftshader\include\egl\eglext.h(591): er
- ror C2061: syntax error: identifier 'EGLAttrib'
Release下鏈接錯誤
- ffmpeg.lib(ffmpeg.wavdec.obj) : error LNK2001: unresolved external symbol _ff_w64_guid_data
chromium/third_party/ffmpeg /ffmpeg_generated.gni
- "libavformat/vorbiscomment.c",
- "libavformat/vorbiscomment.c",
- "libavformat/w64.c",
chromium/third_party/ffmpeg /ffmpeg_generated.gypi
- 'libavformat/vorbiscomment.c',
改成
- 'libavformat/vorbiscomment.c',
- 'libavformat/w64.c',
參考:https://ffmpeg.org/pipermail/ffmpeg-devel/2016-May/194142.html
修改代碼
- Refused to display in a frame because it set 'X-Frame-Options' to
- bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, const KURL& url, unsigned long requestIdentifier)
- {
- return false;
- }
運行錯誤
錯誤代碼:
Error Code: -130 Failed to load web page (unknown error).
原因
IE的代理問題,比如可能是代理沒設置對,或者不需要代理
CEF3版本升級需要porting的代碼文件
比如從cef_binary_3.2454.1323.g71c7271_windows32 -->cef_binary_3.2704.1434.gec3e9ed_windows32
cefclient\browser\client_handler.cc
操作視窗,拖放客戶區,縮放
- // Window Manipulator
- const char kDrag[] = "kDrag";
- const char kRestore[] = "kRestore";
- const char kMinimize[] = "kMinimize";
- const char kMaximize[] = "kMaximize";
- const char kFullscreen[] = "kFullscreen";
- const char kShow[] = "kShow";
- const char kHide[] = "kHide";
- // Check for messages from the client renderer.
- std::string message_name = message->GetName();
- if (message_name == kFocusedNodeChangedMessage) {
- // A message is sent from ClientRenderDelegate to tell us whether the
- // currently focused DOM node is editable. Use of |focus_on_editable_field_|
- // is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent
- // but is useful for demonstration purposes.
- focus_on_editable_field_ = message->GetArgumentList()->GetBool(0);
- return true;
- } else if (message_name == kDrag) { // Window Manipulator
- RootWindow::GetWindow(browser)->Drag();
- return true;
- } else if (message_name == kRestore) {
- RootWindow::GetWindow(browser)->Restore();
- return true;
- } else if (message_name == kMinimize) {
- RootWindow::GetWindow(browser)->Minimize();
- return true;
- } else if (message_name == kMaximize) {
- RootWindow::GetWindow(browser)->Maximize();
- return true;
- }
- bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
- const CefString& message,
- const CefString& source,
- int line) {
cefclient\browser\main_context_impl.cc
修改首頁初始訪問的URL
- // The default URL to load in a browser window.
- const char kDefaultUrl[] = "http://happ/index.html"; // "http://www.google.com";
cefclient\browser\resource_util_win.cc
如果需要添加資源,比如圖標之類的才需要修改這里
cefclient\browser\root_window_win.cc
窗口的初始化,比如全屏,可縮放等窗口風格設置