天天看點

Linux平台下cef&chromium編譯--加入對h264的支援Linux Setup

背景:

    在cef上進行二次開發,發現預設不隻支援h264解碼。需要重新編譯chromium解決。

步驟:

    https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart.md#markdown-header-linux-setup 為官方編譯指導。主要步驟已經十分詳細。下面紅字部分補充一些實際編譯遇到的問題。

前提:

需要fq

需要fq

需要fq!!

需要好用的vpn,或者ssr 加 proxifier 實作全局代理。具體教程網上很多。

Linux Setup

What's Required

  • Ubuntu 16.04 LTS 64-bit is recommended. Building with other versions or distros has not been tested and may experience issues.
  • At least 6GB of RAM and 40GB of free disk space.(記憶體實在不夠,可以用swap湊,4g還是起碼要的,否則極度影響編譯速度。 硬碟空間最好60g以上,40g可能不夠)
  • Approximately 2 hours with a fast internet connection (25Mbps) and fast build machine (2.6Ghz+, 4+ logical cores).(虛拟機,單核也沒問題,就是耗時巨長。。)

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.

整體主要是使用者和權限問題,需要非root使用者執行

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. Install the "libgtkglext1-dev" package required by the cefclient sample application.

sudo apt-get install libgtkglext1-dev
      

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

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

5. 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
      

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

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

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

(環境變量主要是為了加入對h264解碼的支援,chromium預設是不支援h264的)

#!/bin/bash
export DEPOT_TOOLS_UPDATE=0
export CEF_USE_GN=1
export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome"
export GYP_DEFINES=buildtype=Official

python ../automate/automate-git.py --download-dir=/home/marshall/code/chromium_git --depot-tools-dir=/home/marshall/code/depot_tools --no-distrib --no-build
      

(--branch=3683  指定對應要下載下傳的分支版本  --force-clean 最好加上,可以去除殘留)

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
      

8. Create the "~/code/chromium_git/chromium/src/cef/create.sh" script with the following contents.】

(環境變量主要是為了加入對h264解碼的支援,chromium預設是不支援h264的)

#!/bin/bash
export DEPOT_TOOLS_UPDATE=0
export CEF_USE_GN=1
export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome use_jumbo_build=true"
export GYP_DEFINES=buildtype=Official
export GN_DEFINES=use_jumbo_build=true
./cef_create_projects.sh
      

Give it executable permissions.

cd ~/code/chromium_git/chromium/src/cef
chmod 755 create.sh
      

Run the "create.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
./create.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 required by step 10.

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

10. Set up the Linux SUID sandbox.

# 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 sample application.

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

相關問題:
1、________ running 'cipd ensure -log-level error -root /home/z/code/chromium_git/chromium -ensure-file /tmp/tmpkunrfR.ensure' in '.'
CIPD selfupdate failed. Trying to bootstrap the CIPD client from scratch...
[P21376 19:08:21.295 client.go:309 W] RPC failed transiently. Will retry in 1s    {"error":"failed to send request: Post https://chrome-infra-packages.appspot.com/prpc/cipd.Repository/ResolveVersion: proxyconnect tcp: net/http: TLS handshake timeout", "host":"chrome-infra-packages.appspot.com", "method":"ResolveVersion", "service":"cipd.Repository", "sleepTime":"1s"
解決:檢視代理設定 預設https是優先選擇的,如果https不可用,直接設定為export https_proxy=http://

2、FAILED: gen/mojo/public/js/mojo_bindings_lite.js
解決:安裝jdk

3、clang++: error: unable to execute command: Killed
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 9.0.0 (trunk 351477)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: ../../third_party/llvm-build/Release+Asserts/bin
clang++: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang++: note: diagnostic msg: 
解決:記憶體不夠,增加swap空間
sudo fallocate -l 6G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
開機自動挂載swap:
使用 vi 或 nano 在 /etc/fstab 檔案底部添加如下内容:
/swapfile none swap sw 0 0

4、WARNING: subprocess '"git" "-c" "core.deltaBaseCacheLimit=2g" "fetch" "origin"' in   
解決:
 在對應目錄執行 git remote prune origin(同步遠端倉庫)

      

繼續閱讀