欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

编译 Chromium Content Shell 工程

程序员文章站 2022-03-20 19:03:11
前言重所周知,Chromium是一个非常复杂的开源项目,其复杂程度类似于一个操作系统。如果要学习Chromium的话,往往不知道从哪来入手。通过网上查询资料大家都推荐从 content shell 入手学习的是比较好的,因为 content shell 是基于 content api 构建的,相当于一个最精简的浏览器,十分适合新手学习。接下来就介绍下如何编译 content shell一、如何下载chromium源码How to build Chromium 二、编译步骤1.复制文件【con...

前言

重所周知,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,只能先这么挫的办法先编译出来,哭~~~~。

本文地址:https://blog.csdn.net/IdeasPad/article/details/109249508