php网站数据库修改,变装chinacd wordpress,只用jsp做网站,网站开发公司人员配备CEF编译打包(支持MP4播放,x64版本)
标签#xff08;空格分隔#xff09;#xff1a; CEF C Windows vs2022 文章目录 CEF编译打包(支持MP4播放,x64版本)背景一、准备工作二、编译环境准备三、具体编译流程大概流程创建工作目录init.batdown_cef.batdown_chromium.batdown_d…CEF编译打包(支持MP4播放,x64版本)
标签空格分隔 CEF C Windows vs2022 文章目录 CEF编译打包(支持MP4播放,x64版本)背景一、准备工作二、编译环境准备三、具体编译流程大概流程创建工作目录init.batdown_cef.batdown_chromium.batdown_depot_tools.batcef,chromium和depot_tools对应关系myclient.batmyclient-s2.batmyclient-s3.batgenerate.bat编译CEF编译cef_sandbox.lib 四、打包CEFpack.bat 引用博客地址:https://www.cnblogs.com/zgliubo/p/16423247.html 背景
之前项目cef是32位渲染网页3d模型内存被限制内存在1G多一直上不去使用官方的64位cef编译QCefView后可以播放3D内存也突破了1G多到了3~4G但是mp4播放不了原因是cef官方默认编译好的cef二进制不支持mp4播放需要自己下载源码编译支持.
一、准备工作 因为需要下载cef和depot_tools等源码,源码网站又被墙,所以需要科学上网 这里推荐使用cloudflare和ZeroTrust的组合,这样不用设置代理,方便很多,也不用担心把网络环境搞乱了 二、编译环境准备
较新的版本CEF建议使用vs2022编译,安装时注意安装windows kits,我这里win10就选择windows10版本cef的编译脚本还需要ninja过程中需要执行python脚本,我安装的python3, 有些地方如果提示python.bat找不到,可以改成python3.bat试试git,这个应该都有吧,版本尽量高一些cmake,这个也需要,版本也尽量高一些
三、具体编译流程
大概流程
步骤
1、init.bat
2、down_cef.bat
3、down_chromium.bat
4、down_depot_tools.bat
5、mygclient.bat
6、mygclient-s2.bat
7、mygclient-s3.bat
8、generate.bat创建工作目录
md C:\Code\cef\
md C:\Code\chromium\src\
md C:\Code\depot_tools\init.bat
执行以下init.bat脚本初始化:
:: 禁止depot_tools自动更新
setx DEPOT_TOOLS_UPDATE 0:: 使用本地安装的 Visual Studio 版本
setx DEPOT_TOOLS_WIN_TOOLCHAIN 0:: 如果前面已经设置了这些环境变量则可以跳过这3条命令
:: GN 构建工具
set CEF_USE_GN1
:: 使用 VS2022 创建项目
set GN_ARGUMENTS--idevs2022 --slncef --filters//cef/*
:: 使用官方构建并添加ffmpeg音视频解码
set GN_DEFINESis_official_buildtrue proprietary_codecstrue ffmpeg_brandingChrome chrome_pgo_phase0
set GYP_DEFINESbuildtypeOfficialset GYP_GENERATORSninja,msvs-ninja
set GYP_MSVS_VERSION2022
set CEF_ARCHIVE_FORMATtar.bz2
set VS_CRT_ROOTE:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\crt
set WIN_CUSTOM_TOOLCHAIN1
:: 设置为none可能最后打包会有问题,先设置为none,生成工程后,打包前再设置也可以
set CEF_VCVARSnone
set GYP_MSVS_OVERRIDE_PATHE:\Program Files\Microsoft Visual Studio\2022\Community
set MSVC_VERSION14.39.33519
set SDK_ROOTE:\Windows Kits\10
set WINDOWSSDKDIRE:\Windows Kits\10
set SDK_VERSION10.0.19041.0:: 将depot_tools路径(D:\cef\depot_tools\)添加到用户环境变量Path
for /f tokens3,* %i in (reg query HKCU\Environment /v Path) do setx Path d:\cef\depot_tools\;%i%j:: 谨记:打包需要编译cef_sandbox.lib --client参数不需要,但是没有camke文件 标准版还需要编译Debug 这里我编译的--minimal版本down_cef.bat
down_cef.bat(下载CEF)
cd D:\cef:: clone源码并切换至5672分支
git clone https://bitbucket.org/chromiumembedded/cef.git -b 5672down_chromium.bat
下载chromium:
cd D:\cef\chromium:: clone指定tag(113.0.5672.129)的源码, (cef 5672分支 对应chromiun tag: 113.0.5672.129)
:: --depth 1: 只下载当前版本不需要历史提交记录, 否则耗时严重且浪费储存空间或者意外中断
git clone https://chromium.googlesource.com/chromium/src.git -b 113.0.5672.129 --depth 1down_depot_tools.bat
下载depot_tools:
cd D:\cef:: clone depot_tools工具
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.gitcd D:\cef\depot_tools:: 临时允许更新
set DEPOT_TOOLS_UPDATE1
:: 执行update_depot_tools.bat下载内部工具
update_depot_tools.bat
:: 禁止更新
set DEPOT_TOOLS_UPDATE0:: checkout, (cef 5672分支 对应depot_tools commit id: 2075f733e8)
checkout 2075f733e8cef,chromium和depot_tools对应关系
cef与chromium和depot_tools对应版本关系在 cef\CHROMIUM_BUILD_COMPATIBILITY.txtmyclient.bat
cd D:\cef\chromium:: 通过命令创建.gclient文件
:: echo gclient config
:: gclient config https://chromium.googlesource.com/chromium/src.git --unmanagedecho gclient sync
gclient sync --nohooks --no-history: 如果前面已经设置了此环境变量, 可以不用执行
set DEPOT_TOOLS_WIN_TOOLCHAIN0echo gclient runhooks
gclient runhooks
myclient-s2.bat
cd D:\cef\chromiumecho gclient sync
gclient sync --nohooks --no-historymyclient-s3.bat
cd D:\cef\chromiumecho gclient sync
gclient sync --nohooks --no-history:: 注意:最好不要使用这种方式拷贝文件夹,可能会忽略掉.git文件夹,后面会导致代码分支版本等信息找不到,诸如check git failed之类的问题
:: xcopy D:\cef\cef D:\cef\chromium\src\cef\ /egenerate.bat
cd D:\cef\chromium\src\cef:: 如果前面已经设置了这些环境变量则可以跳过这3条命令
set CEF_USE_GN1
set GN_ARGUMENTS--idevs2022 --slncef --filters//cef/*
set GN_DEFINESis_official_buildtrue proprietary_codecstrue ffmpeg_brandingChrome chrome_pgo_phase0
set GYP_DEFINESbuildtypeOfficialset GYP_GENERATORSninja,msvs-ninja
set GYP_MSVS_VERSION2022
set CEF_ARCHIVE_FORMATtar.bz2
set VS_CRT_ROOTE:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\crt
set WIN_CUSTOM_TOOLCHAIN1
:: 设置为none可能最后打包会有问题
::set CEF_VCVARSnone
set GYP_MSVS_OVERRIDE_PATHE:\Program Files\Microsoft Visual Studio\2022\Community
set MSVC_VERSION14.39.33519
set SDK_ROOTE:\Windows Kits\10
set WINDOWSSDKDIRE:\Windows Kits\10
set SDK_VERSION10.0.19041.0REM 编译64位调用VS的脚本有问题环境变量还是去找的32位路径下面改手动设置路径
REM call E:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat x64set INCLUDE%SDK_ROOT%\Include\%SDK_VERSION%\um;%SDK_ROOT%\Include\%SDK_VERSION%\ucrt;%SDK_ROOT%\Include\%SDK_VERSION%\shared;%GYP_MSVS_OVERRIDE_PATH%\VC\Tools\MSVC\%MSVC_VERSION%\include;%GYP_MSVS_OVERRIDE_PATH%\VC\Tools\MSVC\%MSVC_VERSION%\atlmfc\include;%INCLUDE%
set LIB%SDK_ROOT%\Lib\%SDK_VERSION%\um\x64;%SDK_ROOT%\10\Lib\%SDK_VERSION%\ucrt\x64;%GYP_MSVS_OVERRIDE_PATH%\VC\Tools\MSVC\%MSVC_VERSION%\lib\x64;%GYP_MSVS_OVERRIDE_PATH%\VC\Tools\MSVC\%MSVC_VERSION%\atlmfc\lib\x64;%LIB%
set PATH%SDK_ROOT%\bin\%SDK_VERSION%\x64;%GYP_MSVS_OVERRIDE_PATH%\VC\Tools\MSVC\%MSVC_VERSION%\bin\HostX64\x64;%GYP_MSVS_OVERRIDE_PATH%\VC\Tools\MSVC\%MSVC_VERSION%\bin\HostX64\x64;%GYP_MSVS_OVERRIDE_PATH%\VC\Redist\MSVC\14.38.33135\x64\Microsoft.VC143.CRT;%PATH%:: 构建项目
call cef_create_projects.bat编译CEF
cd chromium_git/chromium/src
ninja -C out/Release_GN_x64 cefCEF编译报错: ValueError: path is on mount ‘\\tab_group_types.mojom-webui.js’, start on mount F: 解决方案: 修改F:\code\chromium_git\chromium\src\mojo\public\tools\bindings\generators\mojom_ts_generator.py
def _GetWebUiModulePath(module):path. Otherwise, returned paths always end in a / and begin with eitherchrome://resources/ or a /.path module.metadata.get(webui_module_path)if path :path /if path is None or path /:return pathif _IsAbsoluteChromeResourcesPath(path):编译cef_sandbox.lib
原以为这个可以不编译,但是这个不编译打包会出问题: ninja -C out\Release_GN_x86_sandbox cef_sandbox四、打包CEF
pack.bat
cd D:\cef\chromium\src\cef\tools
set CEF_VCVARSnone
set CEF_ARCHIVE_FORMATtar.bz2
:: --minimal
:: 这里编译minimal版本,因为标准版本需要Debug,我这里没有编译
:: --no-docs不需要文档,安装了Doxygen也报错找不到,直接就去掉吧
:: --x64-build 打包X64版本
:: --client 有些文章使用的这个参数,这个打包参数只会打包Release文件夹,很多库和目录都没有,其他库联合cef编译有可能会报错
make_distrib.bat --ninja-build --no-docs --x64-build --no-symbols --minimal打包可能的报错:
msvs_en.bat执行失败:
VC路径没有设置好,修改如下:
echo off
:: Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
:: reserved. Use of this source code is governed by a BSD-style license
:: that can be found in the LICENSE file.:: Set up the environment for use with MSVS tools and then execute whatever
:: was specified on the command-line.set RC:: Support !! syntax for delayed variable expansion.
setlocal enabledelayedexpansion:: Require that platform is passed as the first argument.
if %1 win32 (set vcvarsbatvcvars32.bat
) else if %1 win64 (set vcvarsbatvcvars64.bat
) else if %1 winarm64 (set vcvarsbatvcvarsamd64_arm64.bat
) else (echo ERROR: Please specify a target platform: win32, win64 or winarm64set ERRORLEVEL1goto end
):: Check if vcvars is already provided via the environment.:: 在这里添加CEF_VCVARS变量设置vs路径
set CEF_VCVARSE:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
set vcvars%CEF_VCVARS%
if %vcvars% none goto found_vcvars
if exist %vcvars% goto found_vcvars:: Search for the default VS installation path.
for %%x in (2022) do (for %%y in (%PROGRAMFILES% %PROGRAMFILES(X86)%) do (for %%z in (Professional Enterprise Community BuildTools) do (::set vcvars%%~y\Microsoft Visual Studio\%%x\%%z\VC\Auxiliary\Build\%vcvarsbat%set vcvars%CEF_VCVARS%if exist !vcvars! goto found_vcvars))
)echo ERROR: Failed to find vcvars
set ERRORLEVEL1
goto end:found_vcvars
echo vcvars:
echo %vcvars%if not %vcvars% none (:: Set this variable to keep VS2017 15.5 from changing the current working directory.set VSCMD_START_DIR%CD%call %vcvars%
)echo PATH:
echo %PATH%:: Remove the first argument and execute the command.
for /f tokens1,* delims %%a in (%*) do set ALL_BUT_FIRST%%b
echo command:
echo %ALL_BUT_FIRST%
%ALL_BUT_FIRST%:end
endlocal set RC%ERRORLEVEL%
goto omega:returncode
exit /B %RC%:omega
call :returncode %RC%
如果还报错msvs_env.bat执行失败,可能是cef_sandbox.lib没有编译参考前面的步骤编译后再打包即可,在目录chromium_git\chromium\src\cef\binary_distrib下就可以找到.tar.bz2的包了