如何编译 google chrome v8 引擎

谷歌 chrome v8 引擎可以嵌入到自己的 c++ 程序中. 一般可以把 v8 编译成 dll, 然后调用.
还可以把 v8 编译成静态库, 静态链接到自己的程序中. 要编译v8的源代码可不是件容易的事.
这里记录下步骤:

  1. Pure Windows 7 x64
  2. Install python 2.7
  3. Install git https://git-scm.com/, v8 needs git bash to compile. Then edit the C:\Users\neil\.bashrc file:
export DEPOT_TOOLS_WIN_TOOLCHAIN=0
  1. Install VS2013, Express edition is ok. Edit Windows Registry:
    HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\12.0.
    Crate a String value: InstallDir, value is: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\
    If you already have the value there, just ignore this step.
  2. If you don't have this file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat, copy one.
  3. Install VS2015, Express edition is ok.
  4. Install Windows 10 sdk: https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
  5. Install google depot_tools https://www.chromium.org/developers/how-tos/install-depot-tools
  6. Open git-bash, get v8 source code:
fetch v8
  1. Generate vs 2015 project, static lib without snapshot, release edition:
cd v8
gn gen out-release/Default --args="v8_static_library=true is_component_build=false v8_use_external_startup_data=false v8_use_snapshot=false is_debug=false" --ide=vs2015

注意:
1. 第 4 步, 可能是因为 VS2013 express 版有点残, 如果你是pro 或者 ultimate版 可能不需要.
2. 第 8 步, 需要从 google 同步很多工具, 在中国, 你懂得.
3. 第 10 步, 个的参数是生成静态库. 不加,就是动态库. 要查看所有可用参数: "gn args --list" for available build arguments.

refs:
1. https://www.chromium.org/developers/how-tos/install-depot-tools
2. https://v8project.blogspot.com/2015/09/custom-startup-snapshots.html
3. https://chromium.googlesource.com/chromium/src/tools/gn/+/HEAD/docs/reference.md
4. https://stackoverflow.com/questions/38674676/building-and-linking-v8-in-visual-studio
byNeil
byNeil.com

原文来自 Blog by Neil, post 如何编译 google chrome v8 引擎 转载请注明出处。本站保留一切权力

发表评论