ubuntu16.04编译CEF的arm版

CEF介绍

Chromium Embedded Framework (CEF)是个基于Google Chromium项目的开源Web browser控件,支持Windows, Linux, Mac平台。除了提供C/C++接口外,也有其他语言的移植版。来自百度百科

各代码官网源码URL(需要梯子):
cef: https://bitbucket.org/chromiumembedded/cef/src/master/
chromium: https://chromium.googlesource.com/chromium/src
https://github.com/otcshare/chromium-src(与官网不完全相同,patch有些打不上)
depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git
install-build-deps.sh: https://chromium.googlesource.com/chromium/src/+/master/build/install-build-deps.sh
automate-git.py: https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py

整体步骤:

  1. 下载源码depot_tools cef chromium
    #1
    mkdir ~/cef/automate
    mkdir ~/cef/chromium_git
  2. 下载安装依赖
    #2
    cd ~/cef
    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 --arm
    #3
    sudo apt-get install libgtkglext1-dev
    #4
    cd ~/cef
    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    export PATH=~/cef/depot_tools:$PATH
    #6
    cd ~/cef/automate
    wget https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py
  3. 配置环境变量
  4. 执行 automate.py
    #7.1
    #创建~/cef/chromium_git/update.sh脚本,将下面的内容写入update.sh脚本中
    #!/bin/bash
    export CEF_USE_GN=1
    export GYP_DEFINES=target_arch=arm
    export GN_DEFINES=“is_official_build=true use_sysroot=true use_allocator=none symbol_level=0 arm_float_abi=hard enable_vr=false”
    python …/automate/automate-git.py --download-dir=~/cef/chromium_git --depot-tools-dir=~/cef/depot_tools --arm-build --no-distrib
    #7.2
    chmod +x update.sh
    sudo ./update.sh

关于编译步骤:
以上步骤来源于 https://blog.csdn.net/u011803182/article/details/80283163
官网 https://bitbucket.org/chromiumembedded/cef/issues/1990/linux-add-arm-build-support

新的automate集成了整体编译,安装依赖后,配置opts,直接执行automate.py可以直接生成libcef.so在对应的out路径下。

tips:
update.sh
#!/bin/bash
export CEF_USE_GN=1
export GYP_DEFINES=target_arch=arm
export GN_DEFINES=“is_official_build=true use_sysroot=true use_allocator=none symbol_level=1 arm_float_abi=hard”
python …/automate/automate-git.py --chromium-url=https://github.com/otcshare/chromium-src.git --download-dir=/home/xxx/cef/chromium_git --depot-tools-dir=/home/xxx/cef/depot_tools --arm-build --no-distrib --no-update --build-target=cefsimple --no-release-build --build-failure-limit=3
上述opts配置省去cef及chromium的源码更新,另外配置chromium源码url为https://github.com/otcshare/chromium-src.git,此代码库源码有问题,建议使用官网地址(fanqiang): https://chromium.googlesource.com/chromium/src

automate.py中集成了编译ninja

如果编译半截出现问题,重新执行automate.py会需要rm -r /home/xxx/cef/chromium_git/chromium/src/out重新编译。
如果不想重新编译,可以:
cd /home/xxx/cef/chromium_git/chromium/src
./third_party/depot_tools/ninja -C out/Debug_GN_arm cefsimple chrome_sandbox
继续编译,即断点编译,不是重新执行编译。
完整编译大约需要7~8个小时以上。

编译中遇到的问题:

./install-build-deps.sh --arm遇到的问题如下:
Q:
已下载 323 kB,耗时 2分 8秒 (2 519 B/s)
正在读取软件包列表… 完成
W: 仓库 “http://ppa.launchpad.net/u-szeged/sedkit/ubuntu xenial Release” 没有 Release 文件。
N: 无法认证来自该源的数据,所以使用它会带来潜在风险。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
W: 无法下载 http://ppa.launchpad.net/u-szeged/sedkit/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found
W: 无法下载 http://ppa.launchpad.net/u-szeged/sedkit/ubuntu/dists/xenial/main/binary-i386/Packages 404 Not Found
W: 无法下载 http://ppa.launchpad.net/u-szeged/sedkit/ubuntu/dists/xenial/main/i18n/Translation-en 404 Not Found
W: 无法下载 http://ppa.launchpad.net/u-szeged/sedkit/ubuntu/dists/xenial/main/dep11/Components-amd64.yml 404 Not Found
W: 无法下载 http://ppa.launchpad.net/u-szeged/sedkit/ubuntu/dists/xenial/main/dep11/icons-64x64.tar 404 Not Found
W: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。
E:。。。。。。(这个地方没记录下来,出现Error之后就不会再往下面继续执行了)。
R:
后来按照网上的方法,更改了下载源/etc/apt/sources.list之后,过一段时间之后执行./install-build-deps.sh --arm,就出现了后续的下载依赖软件包的过程,然后再往下执行,基本没什么问题了。
将报错的/etc/apt/sources.list源及ppa在/etc/apt/sources.list.d对应源文件删除。

执行automate.py遇到的问题
Q1: 执行automate.py 下拉不下chromium的代码,
R(1): 可在http://opensource.spotify.com/cefbuilds/index.html, 下在chromium包,解压到对应的位置,在
automate.py的opts中加入–no-update
R(2): 在github上找到chromium的源码库,在automate.py的opts加上–chromium-url=https://github.com/otcshare/chromium-src.git (此源代码与官网最新版本不一致,不建议使用)。

Q2:
AttributeError: ‘module’ object has no attribute ‘CheckCallAndFilterAndHeader’
R2:
cd depot_tools
git reset --hard 447b45d42307

Q3:
Apply pdfium_print_549365.patch in /…/chromium/src/third_party/pdfium
… patch directory is not a repository root.
-------------------------------------------------------------------------------
!!! ERROR: This patch failed to apply. Your build will not be correct.
R3:
cd /…/chromium/src/third_party/pdfium
git init

Q4:
Generating CEF project files…
NOTE: Not generating x86 configuration due to missing sysroot directory
NOTE: Not generating x64 configuration due to missing sysroot directory
NOTE: Not generating arm configuration due to missing sysroot directory
NOTE: Not generating arm64 configuration due to missing sysroot directory
R4:
#~/cef/chromium_git/chromium/src
export CEF_USE_GN=1
export GYP_DEFINES=target_arch=arm
export GN_DEFINES=“is_official_build=true use_sysroot=true use_allocator=none symbol_level=1 arm_float_abi=hard enable_vr=false”
./build/linux/sysroot_scripts/install-sysroot.py --arch=arm
./build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
./build/linux/sysroot_scripts/install-sysroot.py --arch=i386
./build/linux/sysroot_scripts/install-sysroot.py --arch=arm
安装不同架构的sysroot
然后在重新执行 automate.py [opts]

如果遇到下载不下来的问题,就复制log中的网址链接到浏览器,手动下载到对应的位置,然后解压缩。就手动注释掉install-sysroot.py中的下载部分在重新执行。

Q5:
/bin/sh: 1: …/…/third_party/llvm-build/Release+Asserts/bin/clang++: not found
R5:
cd /home/xxx/cef/chromium_git/chromium/src/tools/clang/scripts
./update.py
如遇下载不下的问题,同上解决方法。

Q6:
/bin/sh: 1: …/…/third_party/node/linux/node-linux-x64/bin/node: not found
R6:
cd /home/xxx/cef/chromium_git/chromium/src/third_party/node
./update_node_binaries

Q7:
SOLINK ./libVkICD_mock_icd.so
FAILED: libVkICD_mock_icd.so libVkICD_mock_icd.so.TOC
python “…/…/build/toolchain/gcc_solink_wrapper.py” --readelf=“arm-linux-gnueabihf-readelf” --nm=“arm-linux-gnueabihf-nm” --sofile="./libVkICD_mock_icd.so" --tocfile="./libVkICD_mock_icd.so.TOC" --output="./libVkICD_mock_icd.so" – …/…/third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname=“libVkICD_mock_icd.so” -Wl,–build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,–as-needed -fuse-ld=lld -Wl,–icf=all -Wl,–color-diagnostics --target=arm-linux-gnueabihf -Wl,-O2 -Wl,–gc-sections -rdynamic -nostdlib++ --sysroot=…/…/build/linux/debian_sid_arm-sysroot -L…/…/build/linux/debian_sid_arm-sysroot/usr/local/lib/arm-linux-gnueabihf -L…/…/build/linux/debian_sid_arm-sysroot/lib/arm-linux-gnueabihf -L…/…/build/linux/debian_sid_arm-sysroot/usr/lib/arm-linux-gnueabihf -Werror -o “./libVkICD_mock_icd.so” @"./libVkICD_mock_icd.so.rsp"
OSError: [Errno 2] No such file or directory
R7:
sudo apt install gcc-arm-linux-gnueabihf

Q8:
ACTION //tools/v8_context_snapshot:generate_v8_context_snapshot(//build/toolchain/linux:clang_arm)
FAILED: v8_context_snapshot.bin
python …/…/build/gn_run_binary.py ./clang_x86_v8_arm/v8_context_snapshot_generator --output_file=v8_context_snapshot.bin
././clang_x86_v8_arm/v8_context_snapshot_generator: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory
./clang_x86_v8_arm/v8_context_snapshot_generator failed with exit code 127
ninja: build stopped: subcommand failed.
R8:
#INFO ./third_party/depot_tools/ninja -d stats 可以列出debug模式,可以使用查看更多的信息
find -name libglib-2.0.so.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/xxx/cef/chromium_git/chromium/src/build/linux/debian_sid_i386-sysroot/usr/lib/i386-linux-gnu/

Q9:[1/378] ACTION //tools/v8_context_snapshot:generate_v8_context_snapshot(//build/toolchain/linux:clang_arm)
FAILED: v8_context_snapshot.bin
python …/…/build/gn_run_binary.py ./clang_x86_v8_arm/v8_context_snapshot_generator --output_file=v8_context_snapshot.bin
././clang_x86_v8_arm/v8_context_snapshot_generator: error while loading shared libraries: libpcre.so.3: cannot open shared object file: No such file or directory
./clang_x86_v8_arm/v8_context_snapshot_generator failed with exit code 127
ninja: build stopped: subcommand failed.
R9:
find -name libpcre.so.3
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/xxx/cef/chromium_git/chromium/src/build/linux/debian_sid_i386-sysroot/lib/i386-linux-gnu/
Q10:
在出现Q8Q9的问题手动添加$LD_LIBRARY_PATH的环境变量后,报:
ACTION //tools/v8_context_snapshot:generate_v8_context_snapshot(//build/toolchain/linux:clang_arm)
FAILED: v8_context_snapshot.bin
./clang_x86_v8_arm/v8_context_snapshot_generator failed with exit code 11(SIGSEGV)段错误的问题。
是因为R8R9加载的库不匹配导致重新安装对应的依赖包。见下:
R8R9R10:重新执行install-build-deps.sh --arm 安装交叉编译依赖包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值