【问题标题】:Easy building of Chromium base (libchrome) library轻松构建 Chromium 基础 (libchrome) 库
【发布时间】:2015-01-09 16:11:36
【问题描述】:

我使用 Chromium 代码库已经有一段时间了,并且习惯了它出色的 base library (aka libchrome)。问题是,虽然这个库功能强大且用途广泛,但并不打算在 Chromium 之外使用,因此将其用作独立库确实存在问题。

Library's page 表示,对于其他 Google 的项目,他们要么发布了一些内部包,要么使用了可用于构建库的 scons build script。不幸的是,这个脚本和它的more recent version 都不允许我编译它。我有一些关于错误标志或丢失输入文件的错误。可能将一些补丁放在与脚本相同的目录中可能会有所帮助,但没有说明要使用哪些以及以什么顺序使用。

some blog 上,我发现有人建议可以取而代之的是获取整个 Chromium 及其工具链,并将其配置为仅构建一个库。但这真的很慢,而且不是很便携。如果有一天我要开发一些严肃的东西,它会迫使人们下载很多不必要的东西。

你们中的任何人都知道构建该库的快速可靠的方法吗?它可能会更复杂,只要它可以通过脚本自动化并且不进行一个设置 PATH 变量并下载几 GB 的开销数据。

【问题讨论】:

    标签: c++ build chromium


    【解决方案1】:

    也许你可以看看我的端口:https://github.com/zhchbin/chromium-base 基于 mini_chromium。除了 mini_chromium,我将大部分 chromium/src/base 代码移到了这个独立的存储库中。它现在可以在 windows 和 linux 上运行。

    【讨论】:

      【解决方案2】:

      mini_chromium 提供基础库的独立构建,但不提供 Windows 构建。如果您需要这些,您必须自己添加。

      【讨论】:

      • 谢谢!我从svn checkout http://gyp.googlecode.com/svn/trunk/ gyp-read-only 下载了 GYP,然后从 gyp 检查输入旁边的mini_chromium dir 运行命令../gyp-read-only/gyp --depth=. mini_chromium.gyp。然后我就可以在 Visual Studio 中构建 Windows 版本了。
      • mini_chromium 支持安卓吗?
      【解决方案3】:

      我想详细说明@krishna 的回答。

      构建 mini_Chromium

      要安装mini_chromium,您可以执行以下步骤:

      git clone https://chromium.googlesource.com/chromium/mini_chromium
      cd mini_chromium
      
      # On POSIX
      export GYP_GENERATORS=ninja
      gyp --depth=. mini_chromium.gyp
      # On Windows
      set GYP_GENERATORS=ninja
      gyp.bat --depth=. mini_chromium.gyp
      
      ninja -C out/Release base
      ninja -C out/Debug   base
      

      只需要安装 GYP 和 ninja。

      构建 libchrome

      通过一些额外的努力,我能够构建完整的 libchrome(在 Windows 上),但是它需要大量的黑客攻击,并且如果 Chromium 开发人员更改某些内容很容易崩溃:

      # First checkout and initialize shallow Chromium SVN repository
      svn checkout --depth empty http://src.chromium.org/chrome/trunk/src/ libchrome
      cd libchrome
      svn update --set-depth empty chrome/
      svn update --set-depth empty third_party/
      # Now fill it with only dependencies required to build target 'base'
      svn update --set-depth infinity base/
      svn update --set-depth infinity build/
      svn update --set-depth empty    chrome/VERSION
      svn update --set-depth infinity testing/
      svn update --set-depth infinity third_party/android_crazy_linker/
      svn update --set-depth infinity third_party/ashmem/
      svn update --set-depth infinity third_party/libevent/
      svn update --set-depth infinity third_party/libxml/
      svn update --set-depth infinity third_party/modp_b64/
      svn update --set-depth infinity third_party/zlib/
      # Now checkout dependencies from outside of main Chromium repository
      git clone https://chromium.googlesource.com/chromium/buildtools buildtools
      git clone https://chromium.googlesource.com/chromium/testing/gtest testing/gtest
      git clone https://chromium.googlesource.com/chromium/deps/icu52.git third_party/icu
      git clone https://chromium.googlesource.com/chromium/deps/psyco_win32 third_party/psycho
      git clone https://chromium.googlesource.com/external/gyp tools/gyp
      

      此时所有依赖项都已获取,但仍无法构建代码。我们需要修改两个文件以使 thinks 起作用:

      • build/gyp_chromium - 在第 30 行附近,有一些路径需要在脚本启动时检查。只留下:

        # Add paths so that pymod_do_main(...) can import files.
        sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp'))
        sys.path.insert(1, os.path.join(chrome_src, 'tools'))
        
      • build/all.gyp - 删除与base 无关的依赖项。结果应该类似于this GIST

      准备就绪,现在我们可以构建目标base(假设安装了depot tools):

      build/gyp_chromium --depth=. --root-target=base
      ninja -C out/Release base
      ninja -C out/Debug base
      

      我必须提醒一下,我是在 Windows 上构建的。整个 hacky 解决方法让我下载 500MB 的代码而不是 2.7GB,但它不受支持,它可以随时停止工作。但可能当它崩溃时,它应该仍然相对容易修复,因为它可能是添加一个或两个依赖项的问题。

      【讨论】:

      • stackoverflow.com/a/30913546/285594 - 你看起来像我的那种更详细的作家。你能检查一下为什么这个答案无法构建,我尝试了所有但它未能构建。
      猜你喜欢
      • 2011-12-24
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-20
      • 1970-01-01
      • 1970-01-01
      • 2013-06-11
      • 1970-01-01
      相关资源
      最近更新 更多