首页 > 其他分享 >搭建libcef开发环境

搭建libcef开发环境

时间:2023-09-18 11:22:44浏览次数:47  
标签:cef code git libcef 开发 GN build chromium 搭建

/home/hou/code/chromium_git/chromium/skia/config

Overview

This page provides a quick-start guide for setting up a minimal development environment and building the master branch of Chromium/CEF for development purposes. For a comprehensive discussion of the available tools and configurations visit the BranchesAndBuilding Wiki page.

This guide is NOT intended for:

  • Those seeking a prebuilt binary distribution for use in third-party apps. Go here instead.
  • Those seeking to build the binary distribution in a completely automated manner. Go here instead.

Development systems can be configured using dedicated hardware or a VMwareParallels or VirtualBox virtual machine.

The below steps can often be used to develop the most recent release branch of CEF/Chromium in addition to the master branch. Chromium build requirements change over time so review the build requirements listed on the BranchesAndBuilding Wiki page before attempting to build a release branch. Then just add --branch=XXXX to the automate-git.py command-line where "XXXX" is the branch number you wish to build.

File Structure

The same file structure will be used on all platforms. "~" can be any path that does not include spaces or special characters. We'll be building this directory structure for each platform in the following sections.

~/code/
  automate/
    automate-git.py   <-- CEF build script
  chromium_git/
    cef/              <-- CEF source checkout
    chromium/
      src/            <-- Chromium source checkout
    update.[bat|sh]   <-- Bootstrap script for automate-git.py
  depot_tools/        <-- Chromium build tools

With this file structure you can develop multiple CEF/Chromium branches side-by-side. For example, repeat the below instructions using "chromium_git1" as the directory name instead of "chromium_git".

Windows Setup

What's Required

  • Windows Build Requirements as listed on the BranchesAndBuilding Wiki page.
  • Install required Visual Studio sub-components as described here.
  • Install the exact Windows SDK version specified in the default location to avoid build issues.
  • At least 16GB of RAM (32GB+ recommended) and 150GB of free disk space (for a Debug build).
  • Approximately 4 hours with a fast internet connection (100Mbps) and fast build machine (2.4Ghz, 16 logical cores, SSD).

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:\code\automate
c:\code\chromium_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:\code\depot_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 and Git.

cd c:\code\depot_tools
update_depot_tools.bat

4. Add the "c:\code\depot_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:\code\automate\automate-git.py".

6. Create the "c:\code\chromium_git\update.bat" script with the following contents.

set GN_DEFINES=is_component_build=true
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
python3 ..\automate\automate-git.py --download-dir=c:\code\chromium_git --depot-tools-dir=c:\code\depot_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:\code\chromium_git\cef" and Chromium source code will be downloaded to "c:\code\chromium_git\chromium\src". After download completion the CEF source code will be copied to "c:\code\chromium_git\chromium\src\cef".

cd c:\code\chromium_git
update.bat

7. Create the "c:\code\chromium_git\chromium\src\cef\create.bat" script with the following contents.

set GN_DEFINES=is_component_build=true
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
call cef_create_projects.bat

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

cd c:\code\chromium_git\chromium\src\cef
create.bat

This will generate a "c:\code\chromium_git\chromium\src\out\Debug_GN_x86\cef.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. Create a Debug build of CEF/Chromium using Ninja. Edit the CEF source code at "c:\code\chromium_git\chromium\src\cef" and repeat this step multiple times to perform incremental builds while developing.

cd c:\code\chromium_git\chromium\src
ninja -C out\Debug_GN_x86 cef

Replace "Debug" with "Release" to generate a Release build instead of a Debug build. Replace “x86” with “x64” to generate a 64-bit build instead of a 32-bit build.

9. Run the resulting cefclient sample application.

cd c:\code\chromium_git\chromium\src
out\Debug_GN_x86\cefclient.exe

See the Windows debugging guide for detailed debugging instructions.

Mac OS X Setup

What's Required

  • macOS Build Requirements as listed on the BranchesAndBuilding Wiki page.
  • Building on an Intel Mac is supported with all versions. Building on an Apple Silicon (ARM64) Mac is supported starting with M93 (4577 branch).
  • At least 16GB of RAM (32GB+ recommended) and 150GB of free disk space (for a Debug build).
  • Approximately 4 hours with a fast internet connection (100Mbps) and fast build machine (2.4Ghz, 16 logical cores, SSD).

Step-by-step Guide

In this example "~" is "/Users/marshall". Note that in some cases the absolute path must be used. Environment variables described in this section can be added to your "~/.bash_profile" file to persist them across sessions.

1. Create the following directories.

mkdir ~/code
mkdir ~/code/automate
mkdir ~/code/chromium_git

2. Download "~/code/depot_tools" using Git.

cd ~/code
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

3. Add the "~/code/depot_tools" directory to your PATH. Note the use of an absolute path here.

export PATH=/Users/marshall/code/depot_tools:$PATH

4. Download the automate-git.py script to "~/code/automate/automate-git.py".

5. Create the "~/code/chromium_git/update.sh" script with the following contents.

#!/bin/bash
python3 ../automate/automate-git.py --download-dir=/Users/marshall/code/chromium_git --depot-tools-dir=/Users/marshall/code/depot_tools --no-distrib --no-build --x64-build

 Replace --x64-build with --arm64-build if using an Apple Silicon Mac instead of an Intel Mac.

Give it executable permissions.

cd ~/code/chromium_git
chmod 755 update.sh

Run the "update.sh" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "~/code/chromium_git/cef" and Chromium source code will be downloaded to "~/code/chromium_git/chromium/src". After download completion the CEF source code will be copied to "~/code/chromium_git/chromium/src/cef".

cd ~/code/chromium_git
./update.sh

6. Run the "~/code/chromium_git/chromium/src/cef/cef_create_projects.sh" script to create Ninja project files. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).

cd ~/code/chromium_git/chromium/src/cef
./cef_create_projects.sh

 Add export GN_DEFINES=is_component_build=true before running cef_create_projects.sh if using an Apple Silicon Mac instead of an Intel Mac.

7. Create a Debug build of CEF/Chromium using Ninja. Edit the CEF source code at "~/code/chromium_git/chromium/src/cef" and repeat this step multiple times to perform incremental builds while developing.

cd ~/code/chromium_git/chromium/src
ninja -C out/Debug_GN_x64 cef

 Replace "x64" with "arm64" if using an Apple Silicon Mac instead of an Intel Mac. Replace "Debug" with "Release" to generate a Release build instead of a Debug build.

8. Run the resulting cefclient, cefsimple and/or ceftests sample applications.

cd ~/code/chromium_git/chromium/src
open out/Debug_GN_x64/cefclient.app
# Or run directly in the console to see log output:
./out/Debug_GN_x64/cefclient.app/Contents/MacOS/cefclient

See the Mac OS X debugging guide for detailed debugging instructions.

Linux Setup

What's Required

  • Linux Build Requirements as listed on the BranchesAndBuilding Wiki page.
  • Building with other versions or distros has not been tested and may experience issues.
  • At least 16GB of RAM (32GB+ recommended) and 120GB of free disk space (for a Debug build).
  • Approximately 4 hours with a fast internet connection (100Mbps) and fast build machine (2.4Ghz, 16 logical cores, SSD).

Step-by-step Guide

In this example "~" is "/home/marshall". Note that in some cases the absolute path must be used. Environment variables described in this section can be added to your "~/.profile" or "~/.bashrc" file to persist them across sessions.

1. Create the following directories.

mkdir ~/code
mkdir ~/code/automate
mkdir ~/code/chromium_git

2. Download and run "~/code/install-build-deps.sh" to install build dependencies. Answer Y (yes) to all of the questions.

cd ~/code
sudo apt-get install curl
curl 'https://chromium.googlesource.com/chromium/src/+/master/build/install-build-deps.sh?format=TEXT' | base64 -d > install-build-deps.sh
chmod 755 install-build-deps.sh
sudo ./install-build-deps.sh --no-arm --no-chromeos-fonts --no-nacl

3. Download "~/code/depot_tools" using Git.

cd ~/code
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

4. Add the "~/code/depot_tools" directory to your PATH. Note the use of an absolute path here.

export PATH=/home/marshall/code/depot_tools:$PATH

5. Download the "~/automate/automate-git.py" script.

cd ~/code/automate
wget https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py

6. Create the "~/code/chromium_git/update.sh" script with the following contents.

#!/bin/bash
python3 ../automate/automate-git.py --download-dir=/home/marshall/code/chromium_git --depot-tools-dir=/home/marshall/code/depot_tools --no-distrib --no-build

Give it executable permissions.

cd ~/code/chromium_git
chmod 755 update.sh

Run the "update.sh" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "~/code/chromium_git/cef" and Chromium source code will be downloaded to "~/code/chromium_git/chromium/src". After download completion the CEF source code will be copied to "~/code/chromium_git/chromium/src/cef".

cd ~/code/chromium_git
./update.sh

7. Configure GN_DEFINES for your desired build environment.

Chromium provides sysroot images for consistent builds across Linux distros. The necessary files will have downloaded automatically as part of step 6 above. Usage of Chromium's sysroot is recommended if you don't want to deal with potential build breakages due to incompatibilities with the package or kernel versions that you've installed locally. To use the sysroot image configure the following GN_DEFINES:

export GN_DEFINES="use_sysroot=true use_allocator=none symbol_level=1 is_cfi=false use_thin_lto=false"

It is also possible to build using locally installed packages instead of the provided sysroot. Choosing this option may require additional debugging effort on your part to work through any build errors that result. On Ubuntu 18.04 the following GN_DEFINES have been tested to work reliably:

export GN_DEFINES="use_sysroot=false use_allocator=none symbol_level=1 is_cfi=false use_thin_lto=false use_vaapi=false"

Note that the "cefclient" target cannot be built directly when using the sysroot image. You can work around this limitation by creating a binary distribution after completing step 9 below, and then building the cefclient target using that binary distribution.

You can also create an AddressSanitizer build for enhanced debugging capabilities. Just add is_asan=true dcheck_always_on=true to the GN_DEFINES listed above and build the out/Release_GN_x64 directory in step 9 below. Run with the asan_symbolize.py script as described in the AddressSanitizer link to get symbolized output.

The various other listed GN arguments are based on recommendations from the AutomateBuildSetup Wiki page. You can search for them by name in the Chromium source code to find more details.

8. Run the "~/code/chromium_git/chromium/src/cef/cef_create_projects.sh" script to create Ninja project files. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).

cd ~/code/chromium_git/chromium/src/cef
./cef_create_projects.sh

9. Create a Debug build of CEF/Chromium using Ninja. Edit the CEF source code at "~/code/chromium_git/chromium/src/cef" and repeat this step multiple times to perform incremental builds while developing. Note the additional "chrome_sandbox" target may be required by step 10. The "cefclient" target will only build successfully if you set use_sysroot=false in step 7, so remove that target if necessary.

cd ~/code/chromium_git/chromium/src
ninja -C out/Debug_GN_x64 cefclient cefsimple ceftests chrome_sandbox
注意:编译这一步时报错,unkndow type SK_API,后来发现在其实新生成的里面已经有了SK_API的定义,但是旧的里面没有,考过去覆盖就行了。~/code/chromium_git/chromium/src/skia/config$ cp * ~/code/chromium_git/chromium/skia/config

Replace "Debug" with "Release" to generate a Release build instead of a Debug build.

10. Set up the Linux SUID sandbox if you are using an older kernel (< 3.8). See here for more background on Linux sandboxing technology.

# This environment variable should be set at all times.
export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox

# This command only needs to be run a single time.
cd ~/code/chromium_git/chromium/src
sudo BUILDTYPE=Debug_GN_x64 ./build/update-linux-sandbox.sh

11. Run the cefclient, cefsimple and/or ceftests sample applications. Note that the cefclient application will only have built successfully if you set use_sysroot=false in step 7.

cd ~/code/chromium_git/chromium/src
./out/Debug_GN_x64/cefclient

See the Linux debugging guide for detailed debugging instructions.

Next Steps

  • If you're seeking a good code editor on Linux check out the Eclipse and Emacs tutorials.
  • Review the Tutorial and GeneralUsage Wiki pages for details on CEF implementation and usage.
  • Review the Chromium debugging guide for WindowsMac OS X or Linux.
  • When you’re ready to contribute your changes back to the CEF project see the ContributingWithGit Wiki page for instructions on creating a pull request.

标签:cef,code,git,libcef,开发,GN,build,chromium,搭建
From: https://www.cnblogs.com/tju1895/p/17711393.html

相关文章

  • 搭建CUDA、CUDNN、Pytorch环境(Windows10/11)
    摘要:搭建Windows系统下Cuda+CUDNN环境,注意C盘一定要大,建议1T+SSD参考:  https://blog.csdn.net/weixin_61164016/article/details/127564466  https://blog.csdn.net/qq_43308156/article/details/127479544  https://blog.csdn.net/weixin_45068330/article/details/121......
  • SK 简化流行编程语言对 生成式AI 应用开发的支持
    SemanticKernel[1]是一个将大型语言模型(LLM)与流行的编程语言相结合的SDK。Microsoft将SemanticKernel(简称SK)称为轻量级SDK,支持AILLM的集成。Microsoft今年3月份时候首次开源了SK,SK不仅支持C#、还支持Java和Python编程语言。生成式AI应用开发所带来新的语义编程,国际组织世......
  • TienChin 渠道管理-更新渠道接口开发
    ChannelController/***修改渠道*/@PreAuthorize("hasPermission('tienchin:channel:edit')")@Log(title="渠道管理",businessType=BusinessType.UPDATE)@PutMappingAjaxResultedit(@Validated@RequestBodyChannelVOchannelVO){......
  • Postman测试金蝶云星空Webapi【协同开发云下的本地环境】
    业务背景:基于金蝶云星空提供的接口测试,交付之前或者联调之前开发者先自测,即使纠错,提高效率。  大致流程:先请求登录接口,获得token后再请求标准webapi或者自定义接口,这样上下文才不会空。 说明: 金蝶的接口格式一般为:http://ServerIp/K3Cloud/接口命名空间.接口实现类名......
  • 在 Windows 系统下安装和使用 PyCharm:Python 开发的得力助手
    PyCharm是一款强大的Python集成开发环境(IDE),它提供了丰富的功能和工具,可帮助开发人员更轻松地编写、调试和管理Python项目。本博客将介绍如何在Windows系统下安装和使用PyCharm,以及一些基本的使用技巧。步骤1:下载PyCharm首先,让我们从JetBrains官网下载PyCharm的最新......
  • Xines广州星嵌全新FPGA开发板—OMAPL138/C6748 DSP+ARM+FPGA
    1  开发板简介    XQ138F-EVM是一款基于广州星嵌TIOMAP-L138(浮点DSPC6748+ARM9)+XilinxSpartan-6FPGA核心板SOM-XQ138F设计的开发板,它为用户提供了SOM-XQ138F核心板的测试平台,用于快速评估SOM-XQ138F核心板的整体性能。 XQ138F-EVM底板采用沉金无铅工艺的四层板设计......
  • golang项目搭建笔记-cobra
    cobra介绍GitHub地址cobra中,一个命令主要概念为command,arguement,flag,可以理解为谓语、宾语、状语格式为APPNAMECOMMANDARG--FLAG,例如:gitcloneURL--bare项目搭建cobra提供了非常方便的工具cobra-cli,可以快速添加命令,参考官方文档新建项目#进入项目目录gomodin......
  • 2020-12-17-xtx的日常开发日记
    layout:posttitle:xtx第15周日常开发日记categories:日志tags:-日志-2020日志BGImage:'https://cdn.jsdelivr.net/gh/xutongxin1/xutongxin1.github.io@bebc52fb1b67a08f8db0026051b9716a88a37900/asset/%E6%97%A5%E5%BF%97/75065066_p0.jpg'jekyll-theme-W......
  • 2020-12-17-xtx第15周工程开发日志
    layout:posttitle:xtx第15周工程开发日志categories:日志tags:-日志-2020日志BGImage:'https://github.xutongxin.me/https://raw.githubusercontent.com/xutongxin1/PictureBed/master/img0/20201220234325.png'jekyll-theme-WuK:musicid:'744590'xtx......
  • 2020-12-17-mc模组开发笔记
    idea乱码在help里进VM参数设置https://www.huaweicloud.com/articles/9096546b90dc8c52d52138d01875b8ed.html->与Lambda表达式tileEntityType->https://www.runoob.com/java/java8-lambda-expressions.html简单说就是return后面一坨给前面,后面一坨可以是函数表达式方块......