当前位置:   article > 正文

【项目实战】Chrome 浏览器编译_chrome编译

chrome编译

【项目实战】Chrome 浏览器编译

【1】depot_tools 下载与配置

git clone https://chromium.googlesource.com/chromium/tools/depot_tools

配置 depot_tools 解压路径到 path 环境变量中,确保在首位

配置环境变量 DEPOT_TOOLS_WIN_TOOLCHAIN 其值为 0,DEPOT_TOOLS_UPDATE 其值为 0

【2】window 编译环境构建

Visual Studio 2019 安装与配置

安装 Visual Studio 2019 时,勾选 使用 C++ 的桌面开发,勾选 C++ ATL 生成工具,其他项默认即可

配置环境变量 vs2019_install,其值为 Visual Studio 2019 安装路径,如 D:\Program Files (x86)\Microsoft Visual Studio\2019\Professional

Windows 10 SDK 安装与配置

SDK 下载地址,https://developer.microsoft.com/zh-cn/windows/downloads/sdk-archive/

安装时确保勾选 “Debugging Tools For Windows” 其他的选项默认

配置环境变量 WINDOWSSDKDIR 其值为 SDK 安装路径,如 D:\Windows Kits\10

【3】chrome 源码获取与编译

访问如下网址可以获取对应版本的 chrome 源码

https://chromium.googlesource.com/chromium/src.git/+/refs/tags/103.0.5060.66

访问如下网址可以获取对应版本的 chrome 源码编译指南

https://chromium.googlesource.com/chromium/src.git/+/refs/tags/103.0.5060.66/docs/windows_build_instructions.md

  • 获取 chrome 源码
  1. github 仓库
  2. git clone --depth 100 -b 103.0.5060.66 https://chromium.googlesource.com/chromium/src.git src
  3. gitee 仓库
  4. git clone --depth 100 -b 103.0.5060.66 https://gitee.com/mirrors/chromium.git src
  5. 还原git仓库地址
  6. cd src
  7. git remote set-url origin https://chromium.googlesource.com/chromium/src.git
  8. cd ..
  • 同步第三方库
  1. 生成 .gclient 文件
  2. gclient config --unmanaged https://chromium.googlesource.com/chromium/src.git
  3. gclient sync
  4. 等同于
  5. gclient sync --nohooks
  6. gclient runhooks
  • 编译 chrome
  1. cd src
  2. 配置参数
  3. gn args out\Default --ide=vs2019
  4. 自动打开 out\Default\args.gn 并编辑文件为如下内容
  5. is_component_build = true
  6. is_debug = false
  7. symbol_level = 0
  8. enable_nacl = false
  9. #ffmpeg setting Support H264
  10. ffmpeg_branding = "Chrome"
  11. proprietary_codecs = true
  12. 生成方案
  13. gn gen out\Default --ide=vs2019
  14. 编译
  15. autoninja -C out\Default chrome

问题与解决方案

【1】UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 249: illegal multibyte sequence

  1. 问题 :
  2. UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf
  3. in position 249: illegal multibyte sequence
  4. 解决方案 :
  5. 在 gn args out/Default --ide=vs2019 生成 args.gen 配置文件时内部不要包含中文字符

要点说明

chrome 的编译需要确保网络环境稳定,可以正常访问 google 对应的仓库,建议可以在云服务器上进行构建,然后再将编译结果打包下载下来。

参考致谢

本博客为博主的学习实践总结,并参考了众多博主的博文,在此表示感谢,博主若有不足之处,请批评指正。

【1】win10 下载 Chromium 源码并编译(版本 103.0.5060.66)

【2】基于VS2019的Chrome(2021年版本)浏览器编译实践

【3】Chrome源码chromium下载编译详细步骤

【4】github 本地 fatal: couldn‘t find remote ref master错误解决方案

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/882194
推荐阅读
  

闽ICP备14008679号