你如何用 Visual Studio 编译 V8?

How do you compile V8 with Visual Studio?

我一直在尝试编译 V8。我从 GitHub 获得了 v8-master 文件夹的副本,但我不知道如何编译它。我在网上找到的很多文档都是相互矛盾的。

从我收集到的信息来看,似乎我让它编译的最佳机会(在我发现的各种方法中,尽管我无法使它们中的任何一个起作用)是创建通过调用 gyp_v8 脚本(位于 v8-master 的构建文件夹中)的项目文件。但它只是给了我 File "gyp_v8", line 86 print 'Error running GYP' SyntaxError: Missing parentheses in call to 'print'。从那里,我尝试安装 Gyp(因为根据文档,我相信这就是导致错误的原因)。这需要我安装 depot_tools 并执行 gclient sync。失败并出现错误 Error: client not configured; see 'gclient config'gclient config 失败并出现错误 gclient.py: error: Inconsistency arguments. Use either --spec or one or 2 args.

老实说,我现在迷路了。有什么办法可以只使用 CMake 或其他东西吗?或者至少是一个不假设您有一堆 Google 特定构建工具的构建教程?

  1. 确认 Git 已安装。 git 2.2.1+ 推荐。
  2. 暂时禁用 Windows 索引。
  3. 安装"Microsoft Visual C++ 2008 Redistributable Package"
  4. 运行 管理员身份的bat文件

蝙蝠文件:

@echo on

CD /D %~dp0
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
SET DEPOT_TOOLS=%CD%/depot_tools
SET PYTHONHOME=%DEPOT_TOOLS%/python276_bin
SET PYTHONPATH=%CD%/v8/build/gyp
SET PATH=%DEPOT_TOOLS%;%PYTHONHOME%;%PATH%

SET GYP_DEFINES=target_arch=x64
REM SET GYP_DEFINES=target_arch=x64 component=shared_library v8_use_snapshot=false
REM About GYP_DEFINES: https://github.com/v8/v8/wiki/Building-with-Gyp

IF EXIST %DEPOT_TOOLS% (
  ECHO Updating depot_tools
  CD %DEPOT_TOOLS%
  CALL git pull
  CD ..
) ELSE (
  ECHO Getting depot_tools
  CALL git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
)

CALL gclient
CALL gclient config https://chromium.googlesource.com/v8/v8.git
CALL gclient sync

我之前为 Visual Studio 2010 年和 Visual Studio 2013 年从源代码构建了 V8。在这两种情况下都是非常耗时的任务。但是对于 Visual Studio 2017,我发现 headers 和预建库可从 NuGet 获得。我不再需要从源代码构建。