编译 Chromium Content Shell 工程

本文介绍了如何编译Chromium的contentshell_windows,适合初学者。首先,从官方源码开始,然后详细讲解了修改GN文件的步骤,包括复制文件、修改配置,并展示了新增代码。最后,指导执行编译命令并运行生成的exe文件。
摘要由CSDN通过智能技术生成

前言

重所周知,Chromium是一个非常复杂的开源项目,其复杂程度类似于一个操作系统。如果要学习Chromium的话,往往不知道从哪来入手。通过网上查询资料大家都推荐从 content shell 入手学习的是比较好的,因为 content shell 是基于 content api 构建的,相当于一个最精简的浏览器,十分适合新手学习。
接下来就介绍下如何编译 content shell


一、如何下载chromium源码

How to build Chromium

二、编译步骤

1.复制文件【content\shell\app\shell_main.cc】到【content\shell\app\shell_main_windows.cc】

2.修改GN文件【content\shell\BUILD.gn】

代码如下:

executable("content_shell") {
    testonly = true

    sources = [ "app/shell_main.cc" ]

    if (is_win) {
      sources += [ "app/shell.rc" ]
    }

    defines = []

    deps = [
      ":content_shell_app",
      ":pak",
      "//build/win:default_exe_manifest",
      "//content/public/app",
      "//sandbox",
    ]

    data_deps = [
      ":pak",
      "//tools/v8_context_snapshot:v8_context_snapshot",
    ]

    if (is_win) {
      deps += [
        "//base",
        "//sandbox",
      ]
      if (win_console_app) {
        defines += [ "WIN_CONSOLE_APP" ]
      } else {
        # Set /SUBSYSTEM:WINDOWS unless a console build has been requested.
        configs -= [ "//build/config/win:console" ]
        configs += [ "//build/config/win:windowed" ]
      }
    }

    if (is_win || is_linux || is_chromeos) {
      data_deps +=
          [ "//third_party/crashpad/crashpad/handler:crashpad_handler" ]
    }

    if ((is_linux || is_chromeos) && !is_component_build) {
      # Set rpath to find our own libfreetype even in a non-component build.
      configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
    }
  }
---------------------------------以下代码为新增代码---------------------------
  executable("content_shell_windows") {
    testonly = true

    sources = [ "app/shell_main_windows.cc" ]

    if (is_win) {
      sources += [ "app/shell.rc" ]
    }

    defines = []

    deps = [
      ":content_shell_app",
      ":pak",
      "//build/win:default_exe_manifest",
      "//content/public/app",
      "//sandbox",
    ]

    data_deps = [
      ":pak",
      "//tools/v8_context_snapshot:v8_context_snapshot",
    ]

    if (is_win) {
      deps += [
        "//base",
        "//sandbox",
      ]
      if (win_console_app) {
        defines += [ "WIN_CONSOLE_APP" ]
      } else {
        # Set /SUBSYSTEM:WINDOWS unless a console build has been requested.
        configs -= [ "//build/config/win:console" ]
        configs += [ "//build/config/win:windowed" ]
      }
    }

  }

3.执行编译【ninja -C out\Default content_shell_windows】

4.运行【out\Default\content_shell_windows.exe】


总结

搞不懂为啥直接【ninja -C out\Default\content_shell】没有生成content_shell.exe,只能先这么挫的办法先编译出来,哭~~~~。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值