【chromium】WIN10编译Chromiumbb 记录;windows10 Chromium.bb环境搭建、clone、编译、VS调试;

前言

  • 根据导师推荐,学习一下chromium,看书觉得有点枯燥,想搭个环境学习。
  • chromium.bb,是chromium专门的windows ports,关键是极大的简化了原版chromium的编译流程,以及针对chromium做了二进制的裁剪。
  • 注意:环境配置和编译过程出现的很多问题都是因为之前的vs之类的不在默认环境下,我又没找到在哪里改路径,所以最后一次把所有的重装在了默认路径下才通过。
  • 推荐一开始就将vs 与SDK装在默认路径下,不会出现很多我遇到的问题。

工具简介

对其中一些 Google 的工具进行简介。

  • Ninja https://ninja-build.org/
    Ninja is a small build system with a focus on speed. It differs from other build systems in two major respects: it is designed to have its input files generated by a higher-level build system, and it is designed to run builds as fast as possible.
  • GN https://gn.googlesource.com/gn
    GN is a meta-build system that generates build files for Ninja.
    GN is currently used as the build system for Chromium, Fuchsia, and related projects

环境要求

chromium.bb的官方文档,但是和chromium的一样,可能是版本问题。

  • A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly recommended.
  • At least 100GB of free disk space on an NTFS-formatted hard drive. FAT32 will not work, as some of the Git packfiles are larger than 4GB.
  • An appropriate version of Visual Studio, as described below.
  • Windows 7 or newer.
  • 具有至少8GB RAM的64位英特尔机器。强烈建议使用超过16GB。
  • 在NTFS格式的硬盘驱动器上至少有100GB的可用磁盘空间。FAT32将无法正常工作,因为一些Git Packfiles大于4GB。
  • 如下所述,适当版本的Visual Studio。
  • Windows 7或更新。

环境配置

安装 depot_tools

下载链接

  • 下载
  • 添加 depot_tools 安装路径的环境变量 path
  • 添加 DEPOT_TOOLS_WIN_TOOLCHAIN 系统变量,并设置为0
  • 按下面命令设置自己的VS路径
    • set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
gclient
  • From a cmd.exe shell, run the command gclient (without arguments). On first run, gclient will install all the Windows-specific bits needed to work with the code, including msysgit and python.
  • If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell), it may appear to run properly, but msysgit, python, and other tools may not get installed correctly.
  • If you see strange errors with the file system on the first run of gclient, you may want to disable Windows Indexing.
  • 一开始都是错误,显示无法连接到远程服务器。
  • 于是翻墙,复制对应域名试了一下可以了,再次gclient就好了。window下编译chromium
    在这里插入图片描述
    在这里插入图片描述
确定 python
After running gclient open a command prompt and type where python and confirm that the depot_tools python.bat comes ahead of any copies of python.exe. Failing to ensure this can lead to overbuilding when using gn - see crbug.com/611087.

在这里插入图片描述

拉Chromiumbb代码

git clone https://github.com/bloomberg/chromium.bb.git

  • clone 一直不行,换了各种方法。就是会断,一直断。
  • 最后使用改DNS,使用github desktop客户端clone下来了。
  • 光代码拉下来,就已经20G了。。。。好大啊
  • 在这里插入图片描述

编译Chromiumbb

生成makefile
  • 使用下面脚本,以产生ninja makefiles,以供后续编译。
      cd src
      build/runhooks.py
      build/blpwtk2.py

这里也卡住很久。

  • 首先是 error 2,查了很久是确实目录?

  • 在这里插入图片描述

  • 于是我顺着调用关系,也没找到怎么改。

  • 后来在 2020.8.7日报:编译通过chromium.bb - 龙泉寺扫地僧 的博客中看到他注释掉了verifyGN调用相关东西。

  • 应该是verifg 什么东西的时候调用出错,于是我也注释掉了,管他呢。

  • 在这里插入图片描述

  • 再跑的时候,出现了新的问题。

  • No supported Visual Studio can be found. Supported versions are: 16.0 (2019), 15.0 (2017),也就是没识别到我的VS 版本。

  • 查到有些人说是路径问题,我之前的VS不是按照默认路径来装的,于是我又开始看vs_toolchain.py

  • 最后将里面的路径都改成了绝对路径(包括VS、SDK的路径),并且手动修改了对应的的版本。

  • 在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  • 最后还经过了一两个缺失dll,自己下载了几个dll 来替换后。

  • 最终才勉强用脚本生成了makefile
    在这里插入图片描述

  • 最简单的方法是,重装VS+SDK,装在默认环境下,就不用手动去改这些。ps:因为我没找到怎么不手动一个一个改。

编译

ninja -C out\shared_debug blpwtk2_all

  • 20210102全是问题。。。决定先重装所有的到默认环境下吧。
  • 20210103 重装以后,用笔记本近四个小时的编译,终于有了结果。
  • 在这里插入图片描述
  • 接着打开src\out\shared_debug>content_shell.exe 即可。
  • 可以用命令:content_shell.exe https://www.baidu.com/
  • 在这里插入图片描述
  • 好的,编译完已经有这么大了,当然还有git。
  • 在这里插入图片描述

生成 Visual Studio 解决方案

  • gn gen --ide=vs out\Default 生成了 all.sln

  • 其中的 IDE options 可以根据自己的IDE来选择;--winsdk=<sdk_version> 选择自己的sdk版本

  • 但是用vs本地调试有问题。

  • 于是不加载.sln项目,根据下面的直接加载之前编译好的.exe。

  • 在这里插入图片描述

  • 在这里插入图片描述

  • 在这里插入图片描述

VS 加载.exe 单步调试

  1. 打开项目:content_shell.exe
  2. 直接可以点击启动直接运行。
  3. 在解决方案处右键 单步执行新实例,即可单步调试。

参考自:Debugging Chromium on Windows - The Chromium Projects
在这里插入图片描述

总结

  • 太菜了啊, 配环境就很就,又编译了很久。
  • 各种问题穷出,也有因为自己之前学习搞得乱七八糟的环境的因素,也有自己不会python 等问题,搞了很久。
  • 还有就是可能Chromiumbb不怎么更新了,文档很乱,readme 都不见了,很多都是Chromium的readme,和我看的博客里的readme都不一样。。。
  • 对于我来讲,要是所有环境都在默认路径,将会简便很多。

参考

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值