zoukankan      html  css  js  c++  java
  • CEF / Chromium 重新编译2018 官网地址 一路是坑 千万别跟着官方step by step走一定多思考多查资料 因为改动地方太多了编译都每个版本都不一样

    CEF/ chromium重新编译2018 官网地址 一路是坑 千万别跟着官方step by step走一定多思考多查资料 因为改动地方太多了编译都每个版本都不一样
     
    参考文章:
    Windows下从源码编译CEF  
    https://blog.csdn.net/foruok/article/details/50498740
     
     带你玩转Visual Studio——带你跳出坑爹的Runtime Library坑 
    https://blog.csdn.net/luoweifu/article/details/49055933
     
    我记录有点乱直接看下面这个文章好了,其他信息作为参考. 
     
    直接看下面这个文章即可图文说明我自己的就不写了基本一致.
    https://www.cnblogs.com/Forever-Kenlen-Ja/p/7653144.html
     
    Windows上使用GN&Ninja编译Chromium通用参数配置
    https://blog.csdn.net/Vincent95/article/details/78477822
    http://magpcss.org/ceforum/viewtopic.php?f=6&t=15687
     
    编译CEF(2171分支) https://blog.csdn.net/sunve_163/article/details/49735895
     
    我尝试编译当前版本:Current Release Branches (Supported)
    https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md#markdown-header-release-branches

    NowVer[windows]:
    Release Branch:3359
    Chromium Version:66
    Windows Build Requirements:Win 7+, VS2017 15.3.2+, Win10.0.15063.468 SDK, Ninja
     
    用到的SDK下载地址
    Windows SDK and emulator archive
    https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
     
    编译步骤地址:
    https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart#markdown-header-windows-setup
     
     
     
     
    配置Git
    git config --global user.name "My Name"
    git config --global user.email "my-name@chromium.org"
    git config --global core.autocrlf false
    git config --global core.filemode false
    git config --global branch.autosetuprebase always


    gn gen outDebug_GN_x86

    配置:
    chromiumsrcuildconfigwinvisual_studio_version.gni

    修改:
    GYP_MSVS_VERSION=2013
    修改为:
    GYP_MSVS_VERSION=2017
     
    Check out your branch
    This branch does not contain any changes — check it out on your local machine to do some work.
    
    Check out in Sourcetree
    
    You can also use this command to check out your branch:
    
    git fetch && git checkout 3282
     
    set CEF_USE_GN=1
    set GN_DEFINES=use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    python ..automateautomate-git.py --download-dir=c:codechromium_git --depot-tools-dir=c:codedepot_tools --no-distrib --no-build
    Run the "update.bat" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "c:codechromium_gitcef" and Chromium source code will be downloaded to "c:codechromium_gitchromiumsrc". After download completion the CEF source code will be copied to "c:codechromium_gitchromiumsrccef".
    
    cd c:codechromium_git
    update.bat
    本机代码:
    cmd.bat
    cmd.exe
    
    
    set CEF_USE_GN=1
    set GN_DEFINES=use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    python ..automateautomate-git.py --download-dir=D:wschromium_git --depot-tools-dir=D:wsdepot_tools --no-distrib --no-build 
    
    改为:
    
    set CEF_USE_GN=1
    set GN_DEFINES=use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    python ..automateautomate-git.py --download-dir=D:wschromium_git --depot-tools-dir=D:wsdepot_tools --no-distrib --no-build --branch=3359
    
    
    后面改成,--branch=3359 --minimal-distrib --client-distrib --force-clean 
    会开始编译,并且开始runhook
    
    
    set CEF_USE_GN=1
    set GN_DEFINES=use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    python ..automateautomate-git.py --download-dir=c:codechromium_git --depot-tools-dir=c:codedepot_tools --branch=3359 --minimal-distrib --client-distrib --force-clean
    
    set CEF_USE_GN=1
    set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome enable_precompiled_headers=false use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    python ..automateautomate-git.py --download-dir=c:codechromium_git --depot-tools-dir=C:codedepot_tools --branch=3359 --no-distrib
    
    
    set CEF_USE_GN=1
    set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome enable_precompiled_headers=false use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    python ..automateautomate-git.py --download-dir=c:codechromium_git --depot-tools-dir=c:codedepot_tools --branch=3359 --minimal-distrib --client-distrib --force-clean
     

    gclient can't find visual studio? 

    Following the instructions on https://bitbucket.org/chromiumembedded/ ... dows-setup, after installing MSVS 2015 community edition, as well as the Win 10 SDK, and I'm stuck with an error that seems to indicate that gclient can't find Visual Studio ...

    Exception: Visual Studio Version 2015 (from GYP_MSVS_VERSION) not found.
     
    请参考:http://magpcss.org/ceforum/viewtopic.php?f=6&t=14292
     
     
     
     
    下面是Google自带翻译的安装文 仅供参考
     

    检出并构建Windows的Chromium

    获取代码链接到其他平台的说明

    Google员工指南

    你是Google员工吗?请参阅go / building-chrome-win

    系统要求

    • 具有至少8GB内存的64位英特尔机器。强烈建议超过16GB。
    • NTFS格式的硬盘上至少有100GB的可用磁盘空间。由于一些Git包文件大于4GB,FAT32将无法工作。
    • 一个合适的Visual Studio版本,如下所述。
    • Windows 7或更新版本。

    设置Windows

    视觉工作室

    截至2017年9月(R503915)Chromium需要Visual Studio 2017更新3.x才能构建。使用clang-cl编译器,但Visual Studio的头文件,库和一些工具是必需的。如果许可证适合您,Visual Studio Community Edition应该可以正常工作。您必须安装“使用C ++进行桌面开发”组件以及“MFC和ATL支持”子组件。这可以通过将这些参数传递给您下载的Visual Studio安装程序从命令行完成:

    - 添加微软VisualStudio 工作量NativeDesktop - 添加Microsoft VisualStudio 组件VC ATLMFC - includeRecommended
    

    您必须安装10.0.15063版本的Windows 10 SDK。这可以单独安装或通过选中Visual Studio安装程序中的相应框来安装。

    SDK调试工具也必须安装。如果Windows 10 SDK是通过Visual Studio安装程序安装的,则可以通过以下方式安装它们:控制面板→程序→程序和功能→选择“Windows软件开发工具包”→更改→更改→选中“Windows调试工具“→更改。或者,您可以下载独立的SDK安装程序并使用它来安装调试工具。

    安装 depot_tools

    下载depot_tools包并将其解压到某处。

    警告: 请勿使用资源管理器中的拖放或复制粘贴提取,它不会提取depot_tools自动更新自身所需的隐藏“.git”文件夹。不过,您可以使用上下文菜单中的“全部提取...”。

    将depot_tools添加到PATH的开始处(必须在Python的任何安装之前)。假设您将软件包解压缩到C: src depot_tools,请打开:

    控制面板→系统和安全→系统→高级系统设置

    如果您具有管理员访问权限,请修改PATH系统变量并放在C:srcdepot_tools前面(或者至少在任何可能已经有Python或Git副本的目录的前面)。

    如果您没有管理员访问权限,则可以添加用户级别的PATH环境变量并将其置于C:srcdepot_tools前端,但如果您的系统PATH中包含Python,那么您将不会运气。

    此外,以相同的方式添加DEPOT_TOOLS_WIN_TOOLCHAIN系统变量,并将其设置为0.这将告诉depot_tools使用您本地安装的Visual Studio版本(默认情况下,depot_tools将尝试使用谷歌内部版本)。

    从cmd.exe shell中运行命令gclient(不带参数)。第一次运行时,gclient将安装所有需要使用代码的Windows特定位,包括msysgit和python。

    • 如果您从非cmd shell(例如,cygwin,PowerShell)运行gclient,它可能会正常运行,但msysgit,python和其他工具可能无法正确安装。
    • 如果您在第一次运行gclient时发现文件系统出现奇怪的错误,则可能需要禁用Windows索引

    运行gclient后,打开命令提示符并键入where python并确认depot_tools超出python.batpython.exe的任何副本。如果使用gn时未能确保这会导致过度构建 - 请参阅crbug.com/611087

    获取代码

    首先,配置Git:

    $ git config - 全局用户名称“我的名字” 
    $ git config - 全局用户电子邮件“my-name@chromium.org” 
    $ git config - 全局核心autocrlf false 
    $ git config - 全局核心filemode false 
    $ git config - 全局分支始终autosetuprebase
    

    chromium为结账创建一个目录并更改为它(只要完整路径没有空格,您可以随意调用此目录并将其放在任何位置):

    $ mkdir铬&& cd铬
    

    运行该fetch工具depot_tools检查代码及其依赖关系。

    $取铬
    

    如果您不想要完整的回购历史记录,则可以通过添加--no-history标志来节省大量时间fetch

    即使是快速连接,预计该命令也需要30分钟,在较慢的连接上需要几个小时。

    fetch完成时,它会创建一个隐藏的.gclient文件和一个名为目录src在工作目录。其余说明假定您已切换到src目录:

    $ cd src
    

    可选如果您希望构建与某些Google服务对话,则还可以安装API密钥,但对于大多数开发和测试目的而言,这不是必需的。

    设置构建

    Chromium使用忍者作为它的主要构建工具以及称为GN的工具来生成.ninja文件。您可以创建具有不同配置的任意数量的构建目录要创建一个构建目录:

    $ gn gen out / 默认
    • 你只需要为每个新建立目录运行一次,Ninja会根据需要更新构建文件。
    • 你可以Default用另一个名字替换,但它应该是一个子目录out
    • 有关其他构建参数(包括发布设置),请参阅GN构建配置缺省值将是一个与当前主机操作系统和CPU相匹配的调试组件。
    • 有关GN的更多信息,请gn help在命令行上运行或阅读快速入门指南

    使用Visual Studio IDE

    如果您想使用Visual Studio IDE,请在生成输出目录时使用--ide命令行参数gn gen(如获取代码页所述):

    $ gn gen - ide = vs out  Default
    $ devenv out  Default  all SLN
    

    GN将all.sln在您的build目录中生成一个文件它将在内部使用Ninja进行编译,同时仍然允许大多数IDE功能工作(没有本机Visual Studio编译模式)。如果您再次手动运行“gen”,则需要重新提供此参数,但通常GN会在构建时自动保持构建和IDE文件的最新状态。

    生成的解决方案将包含数千个项目,加载速度非常慢。使用--filters参数限制仅为您感兴趣的代码生成项目文件。虽然这也会限制项目资源管理器中显示的文件,但调试仍然有效,并且可以在手动打开的文件中设置断点。一个可让您在IDE中编译和运行Chrome的最小解决方案,但不会显示任何源文件:

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

    您可以选择性地将其他目录关注到过滤器中,如下所示:--filters=//chrome;//third_party/WebKit/*;//gpu/*

    还有其他选项用于控制如何生成解决方案,并运行gn help gen当前文档。

    默认情况下,当您在Visual Studio中开始调试时,调试器将只附加到主浏览器进程。要调试所有Chrome,请安装Microsoft的子进程调试强大工具您还需要以管理员身份运行Visual Studio,否则它将默默无法附加到某些Chrome的子进程。

    无需解决方案文件,也可以在Visual Studio中调试和开发Chrome。只需File->Open->Project/Solution使用Visual Studio命令提示符“打开”您的chrome.exe二进制文件,如下所示:devenv /debugexe outDebugchrome.exe <your arguments>许多Visual Studio的代码编辑功能在此配置中不起作用,但通过安装VsChromium Visual Studio Extension,您可以将源代码与其他有用的功能(如代码搜索)一起显示在解决方案资源管理器窗口中。

    建造速度更快

    • 通过从防病毒和索引软件中排除构建目录来减少文件系统开销。
    • 将构建树存储在快速磁盘(最好是SSD)上。
    • 内核越多越好(20+不会过多),需要大量内存(64 GB不会过多)。

    有一些gn标志可以提高构建速度。您可以在创建输出目录(gn args out/Default)或gn gen命令行(gn gen out/Default --args="is_component_build = true is_debug = true"时出现的编辑器中指定它们需要考虑的一些有用的设置包括:

    • use_jumbo_build = true实验 巨无霸/团结建立。
    • is_component_build = true - 这使用更多,更小的DLL和增量链接。
    • enable_nacl = false - 这会禁用本地构建通常不需要的Native Client。
    • target_cpu = "x86" - x86构建比x64构建稍快,并支持更多目标的增量链接。请注意,如果你设置了这个,但不要'设置enable_nacl = false,那么构建时间可能会变得更糟。
    • remove_webcore_debug_symbols = true - 关闭对blink的源代码级调试以减少构建时间,如果您不打算调试blink,则适当。

    为了确保链接足够快,我们建议您使用以下设置之一 - 它们都有权衡:

    • use_lld = true - 此链接器在完整链接上速度非常快,但不支持增量链接。
    • is_win_fastlink = true - 此选项使Visual Studio链接器运行得更快,并支持增量链接,但它可能导致调试器速度变慢或内存不足崩溃。
    • symbol_level = 1 - 这个选项减少了链接器必须做的工作,但是当这个选项被设置时,你不能进行源码级的调试。

    另外,Google员工应该使用分布式编译系统goma。详细信息在内部可用,但相关的gn arg是:

    • use_goma = true

    为了从goma中获得任何好处,将一个很大的-j值传给忍者很重要。一个很好的默认值是10 * numCores到20 * numCores。如果你运行autoninja,那么它会自动将一个合适的-j值传递给忍者,用于goma或不。

    $ autoninja - C out  Default chrome
    

    当调用忍者时,指定'chrome'作为目标,以避免构建所有的测试二进制文件。

    尽管如此,构建将会在很多机器上花费很多时间。

    为什么我的构建变慢?

    许多事情可以让构建变得缓慢,而Windows Defender减缓流程初创公司是一个常见的罪魁祸首。您是否确保将整个Chromium src目录从防病毒扫描中排除(在Google计算机上,这意味着将其放入src驱动器根目录中)?你是否尝试了上面列出的不同设置,包括不同的链接设置和-j值?您是否在铬-dev邮件列表上询问了您的机器规格是否比预期慢?

    下一步是收集一些数据。有几个选项。通过设置NINJA_STATUS,您可以配置Ninja的输出,例如,您可以看到在任何给定时间有多少个进程正在运行,构建已经运行了多长时间等等,如下所示:

    $ set NINJA_STATUS = [%r processes f /%t @ o / s es ]  
    $ autoninja - C out  Default base 
    ninja 进入目录`out  Default'    
    [1进程,86/86 @ 2.7 / s:31.785s] LINK(DLL)base.dll base.dll.lib base.dll.pdb
    

    另外,如果将NINJA_SUMMARIZE_BUILD环境变量设置为1,那么autoninja将在构建完成时打印构建性能汇总,显示最慢的构建步骤和构建步骤类型,如下所示:

    $ set NINJA_SUMMARIZE_BUILD = 1 
    $ autoninja - C out  Default base 最长构建步骤... 1.2 加权s构建基础DLL 基地DLL lib base DLL pdb 1.2 s CPU时间8.5 加权s来构建obj / base / base / base_jumbo_38 obj 30.1
        
    
                 
               的CPU时间时间通过构建- 步骤类型... 1.2 小号加权时间,以产生1 PEFile 链接的文件1.2 的CPU时间30.3 小号加权时间,以产生45 OBJ文件688.8 的CPU时间31.8 小号加权时间693.8 的CPU时间21.8x 并行86 构建步骤完成平均的2.71 /
         
    
                 
               
         
        小号
    

    您还可以通过在构建后手动运行脚本来生成这些报告:

    $ python depot_tools  post_build_ninja_summary py - C out  Default
    

    您还可以通过ninjatracing获得构建性能的可视化报告这将.ninja_log文件转换成可加载到chrome中的.json文件:// tracing

    $ python ninjatracing out  Default  .ninja_log > build JSON
    

    最后,忍者可以报告自己的开销,这可能会有所帮助,例如,如果进程创建使构建变慢,可能是由于叮当声不在排除目录中导致的防病毒干扰:

    $ autoninja - d stats - C out 默认基本
    度量计数avg us         total ms 忍者解析             3555 1539.4 5472.6 
    canonicalize str         1383032 0.0 12.7 
    规范化路径        1402349 0.0 11.2 
    查找节点              1398245 0.0 8.1 ninja_log load          2 118.0 0.2 ninja_deps加载         2
                                                            
                      
           67.5 0.1 
    节点stat                2516 29.6 74.4 
    depfile加载             2 1132.0 2.3 StartEdge 88 3508.1 308.7 FinishCommand 87 1670.9 145.4 CLParser :: Parse 45 1889.1 85.0

    建立铬

    使用以下命令与Ninja(或autoninja)构建Chromium(“chrome”目标):

    $忍者- C 默认铬
    

    您可以gn ls out/Default从命令行运行从GN获得所有其他构建目标的列表要编译一个,传给忍者GN标签没有前面的“//”(所以//chrome/test:unit_tests使用ninja -C out /默认chrome / test:unit_tests)。

    运行铬

    一旦建成,你可以简单地运行浏览器:

    $ out  Default  chrome 可执行程序
    

    (命令中的“.exe”后缀实际上是可选的)。

    运行测试目标

    您可以用相同的方式运行测试。您还可以限制使用--gtest_filterarg 运行哪些测试,例如:

    $ out  Default  unit_tests exe - gtest_filter = “PushClientTest。*”

    你可以在它的GitHub页面找到更多关于GoogleTest的信息

    更新结帐

    要更新现有结帐,您可以运行

    $ git rebase - 更新
    $ gclient同步
    

    第一个命令更新主要的Chromium源代码库,并在树的顶端(即Git分支origin/master之上重新绑定任何本地分支如果你不想使用这个脚本,你也可以使用git pull其他常用的Git命令来更新回购。

    第二个命令将子库与适当的版本同步,并根据需要重新运行钩子。

     
     
     
     
     
     
    编译过程遇到问题零碎笔记:
     
    在window编译步骤中的第八步之前加入一个步骤
    gn args out/Default

    然后在 args.gn文件最下面加入

    ffmpeg_branding = "Chrome"
    proprietary_codecs = true
    GN工具:
    
    https://chromium.googlesource.com/chromium/src/tools/gn/

    C:codechromium_gitchromiumsrcuildtoolswin 找个可用的GN工具丢这里去

    以下是编译时候遇到问题咨询大牛的网友的一些零碎知识点笔记下(仅供参考): 

    在chromium_grit目录下的src目录下用cmd执行这个命令就好

    现在chromium的src目录下执行git stash
    然后在chromium执行gclient sync --with_branch_heads
    最后执行 gclient runhooks

    gclient sync是重新拉取依赖的第三方库

    runhooks是要切换指定的分支

     

    Windows Setup

    What's Required

    • Windows 7 or newer, 64-bit OS.
    • Visual Studio VS2017 15.3.2+ installed in the default location.
    • Windows 10.0.15063.468 SDK installed in the default location. You must install this exact SDK version to avoid build issues.
    • At least 8GB of RAM and 40GB of free disk space.
    • Approximately 2 hours with a fast internet connection (25Mbps) and fast build machine (2.6Ghz+, 4+ logical cores).

    WARNING: If you are using VS2017 15.5.* to build 3282 branch then you must add enable_precompiled_headers=false to GN_DEFINES in steps 6 and 7 to avoid a known issue with clang.

    Step-by-step Guide

    All of the below commands should be run using the system "cmd.exe" and not a Cygwin shell.

    1. Create the following directories.

    c:codeautomate
    c:codechromium_git
    

    WARNING: If you change the above directory names/locations make sure to (a) use only ASCII characters and (b) choose a short file path (less than 35 characters total). Otherwise, some tooling may fail later in the build process due to invalid or overly long file paths.

    2. Download depot_tools.zip and extract to "c:codedepot_tools". Do not use drag-n-drop or copy-n-paste extract from Explorer, this will not extract the hidden ".git" folder which is necessary for depot_tools to auto-update itself. You can use "Extract all..." from the context menu though. 7-zip is also a good tool for this.

    3. Run "update_depot_tools.bat" to install Python, Git and SVN.

    cd c:codedepot_tools
    update_depot_tools.bat
    

    4. Add the "c:codedepot_tools" folder to your system PATH. For example, on Windows 10:

    • Run the "SystemPropertiesAdvanced" command.
    • Click the "Environment Variables..." button.
    • Double-click on "Path" under "System variables" to edit the value.

    5. Download the automate-git.py script to "c:codeautomateautomate-git.py".

    6. Create the "c:codechromium_gitupdate.bat" script with the following contents.

    set CEF_USE_GN=1
    set GN_DEFINES=use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    python ..automateautomate-git.py --download-dir=c:codechromium_git --depot-tools-dir=c:codedepot_tools --no-distrib --no-build
    

    Run the "update.bat" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "c:codechromium_gitcef" and Chromium source code will be downloaded to "c:codechromium_gitchromiumsrc". After download completion the CEF source code will be copied to "c:codechromium_gitchromiumsrccef".

    cd c:codechromium_git
    update.bat
    

    7. Create the "c:codechromium_gitchromiumsrccefcreate.bat" script with the following contents.

    set CEF_USE_GN=1
    set GN_DEFINES=use_jumbo_build=true
    set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
    call cef_create_projects.bat
    

    这里没有cef拷贝一个cef过来

    Run the "create.bat" script to generate Ninja and Visual Studio project files.

    cd c:codechromium_gitchromiumsrccef
    create.bat
    

    This will generate a "c:codechromium_gitchromiumsrcoutDebug_GN_x86cef.sln" file that can be loaded in Visual Studio for debugging and compiling individual files. Replace “x86” with “x64” in this path to work with the 64-bit build instead of the 32-bit build. Always use Ninja to build the complete project. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).

    第8步这里执行前加一步 弄个GN工具
    
    gn args out/Default
    (gn args outDebug_GN_x86)
     

    8. Create a Debug build of CEF/Chromium using Ninja. Replace “x86” with “x64” in the below example to generate a 64-bit build instead of a 32-bit build. Edit the CEF source code at "c:codechromium_gitchromiumsrccef" and repeat this step multiple times to perform incremental builds while developing.

    cd c:codechromium_gitchromiumsrc
    ninja -C outDebug_GN_x86 cef
    

    9. Run the resulting cefclient sample application.

    cd c:codechromium_gitchromiumsrc
    outDebug_GN_x86cefclient.exe
    

    Developers on Windows may wish to use component builds, which are supported in 3202 branch and newer, for faster link times. See issue #1617 for details.

    See the Windows debugging guide for detailed debugging instructions.

     
     
  • 相关阅读:
    Node.js运行Vue项目
    DotNetCore知识栈
    Building gRPC Client iOS Swift Note Taking App
    React Native
    Node.js 教程
    SQL 在线教程&在线练习平台
    RxSwift + Moya + ObjectMapper
    浅谈常用的几种web攻击方式
    让MyEclipse支持mac的Retina屏解决字体模糊的问题
    Java设计模式中的单例模式
  • 原文地址:https://www.cnblogs.com/bycnboy/p/8962616.html
Copyright © 2011-2022 走看看