chromium 48 ubuntu16.04 编译 chromum57

参考资料: https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md

01 更新系统

sudo apt update
sudo apt upgrade
sudo apt install -y git vim curl wget

02 下载并更新 depot_tools

# 后面在 $HOME/git/chromium57 目录下下载代码
mkdir -p $HOME/git/chromium57 && cd $HOME/git/chromium57

# 下载 depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

# 在当前终端窗口 导出PATH,把 $HOME/git/chromium57/depot_tools 放在前面
# 官网有一条要求:You must have Git and Python v3.6+ installed already (and python3 must point to a Python v3.6+ binary).
# 在 PATH 中加入 depot_tools/python-bin 在最前面,使用depot_tools下面到pthon3,
# ubuntu16.04 系统默认python3 是 python3.5.2,编译时,会有format相关错误
export PATH="$HOME/git/chromium57/depot_tools/python-bin:$HOME/git/chromium57/depot_tools:.:$PATH"

# 更新 depot_tools
gclient --version

03 下载 chromium57 版本代码

# 在 chromium57 目录
cd $HOME/git/chromium57/

# 下载无历史记录代码,不runhooks
fetch --nohooks --no-history chromium

# 进入代码目录
cd src

# 切出主分支记录(也可不操作)
git checkout main

# 拉取指定tag(57.0.2987.98),(不带历史记录 --depth 1)
git fetch https://chromium.googlesource.com/chromium/src.git +refs/tags/57.0.2987.98:b57.0.2987.98 --depth 1

# 切换到想要的分支或者tag
git checkout b57.0.2987.98

# gclient sync 使第三方库和主库同步(注意 -D 删除前面下载main的时候的多余第三方库)
# 如果同步代码出错,多运行几次下面到语句即可
gclient sync -D --nohooks --with_branch_heads --with_tags --force


# chromum57 版本比较老,需要把depot_tools切换到对应的版本,再运行后续操作
# 打开新的终端运行
export PATH="$HOME/git/chromium57/depot_tools:.:$PATH"
# 切换 depot_tools 到 57版本附近
#比如: 要查找 chromium57 版本,可以从 https://www.chromium.org/developers/calendar/ 
# 查到 chromium 57 版本的发布时间是 57 Jan 19th, 2017,
# 则在 depto_tools 中用 git map 命令查找过滤,如下查找出3条记录,
# 当然,也可以能查不到当天的,可以用更早一些的日志来查找。

cd "$HOME/git/chromium57/depot_tools"
#git map | grep "2017-01-31"
# -----------------------------------------------------------------------------------------
# ~/git/chromium57/depot_tools$ git map | grep "2017-01-31"
# * 6db8ac71b3	2017-01-31 ~ Roll recipe dependencies (trivial).
# * 71b8e66f89	2017-01-31 ~ Register v8/v8 in gclient for trying Gerrit v8 patches on chromium trybots.
# -----------------------------------------------------------------------------------------
git checkout 6db8ac7 -b 20170131


# 运行./build/install-build-deps.sh前
# 如果python默认不是2.7,需要链接到2.7
sudo ln -sf /usr/bin/python2.7 /usr/bin/python

# 代码同步后,更新依赖
./build/install-build-deps.sh

# 下载编译工具链
gclient runhooks

# 下载指定系统到编译工具链,具体 [--arch] 参数内容,可以查看该文件(install-sysroot.py)
# [amd64] 是 x64 版本, [arm64] 是车机用的arm64版本(aarch64)
./build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
./build/linux/sysroot_scripts/install-sysroot.py --arch=arm64

编译代码

# 生成DebugX64工程
gn gen out/DebugX64 --ide=vs2015 --args="target_os=\"linux\" target_cpu=\"x64\" is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true remove_webcore_debug_symbols=false symbol_level=2"
# 编译DebugX64版本
ninja -C out/DebugX64 content_shell

# 生成 ReleaseX64 工程,cpu=x64有问题
gn gen out/ReleaseX64 --ide=vs2015 --args="target_os=\"linux\" target_cpu=\"x64\" is_component_build=false is_debug=false is_official_build=true google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true remove_webcore_debug_symbols=true symbol_level=0"
# 编译ReleaseX64版本
ninja -C out/ReleaseX64 content_shell

# cpu=x64, 不带参数可以编译过
gn gen out/ReleaseX64 --ide=vs2015 --args="target_os=\"linux\" target_cpu=\"x64\""
ninja -C out/ReleaseX64 content_shell

# 生成 DebugArm64 工程
gn gen out/DebugArm64 --ide=vs2015 --args="target_os=\"linux\" target_cpu=\"arm64\" is_component_build=true is_debug=true is_official_build=false google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true remove_webcore_debug_symbols=false symbol_level=2"
# 编译DebugArm64版本
ninja -C out/DebugArm64 content_shell

# 生成 ReleaseArm64 工程
gn gen out/ReleaseArm64 --ide=vs2015 --args="target_os=\"linux\" target_cpu=\"arm64\" is_component_build=false is_debug=false is_official_build=true google_api_key=false google_default_client_id=false google_default_client_secret=false proprietary_codecs=true media_use_ffmpeg=true ffmpeg_branding=\"Chrome\" enable_nacl=false enable_mse_mpeg2ts_stream_parser=true enable_hls_sample_aes=true enable_ac3_eac3_audio_demuxing=true remove_webcore_debug_symbols=true symbol_level=0"
# 编译ReleaseX64版本
ninja -C out/ReleaseArm64 content_shell


# target_os="mac" 不行,mac不支持交叉编译
gn gen out/ReleaseArm64 --ide=vs2015 --args="target_os=\"mac\" target_cpu=\"arm64\""
#-----------------------------------------------------------------
#ERROR at //build/config/BUILDCONFIG.gn:235:3: Assertion failed.
#  assert(host_os == "mac", "Mac cross-compiles are unsupported.")
#-----------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值