下载源码准备编译环境

git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

gclient
fetch v8
cd v8
git pull origin
gclient sync

在执行gclient sync的时候,可能会提示这个

NOTICE: You have PROXY values set in your environment, but gsutilin depot_tools does not (yet) obey them. Also, –no_auth prevents the normal BOTO_CONFIG environmentvariable from being used. To use a proxy in this situation, please supply those settingsin a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environmentvariable.

下载的东西要翻墙。就要新建一个.boto的文件,比方说放到/home/[user]/.boto(当然,user改成你的用户名),里面写

[Boto]
debug = 0
num_retries = 10

proxy = 127.0.0.1
proxy_port = 1080

配置环境变量 NO_AUTH_BOTO_CONFIG=/home/[user]/.boto

编译命令

cd v8

python tools/dev/v8gen.py x64.debug
ninja -C out.gn/x64.debug

python tools/dev/v8gen.py x64.release
ninja -C out.gn/x64.release

可能要下载 debugging tools for windows
https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/

out.gn的输出目录下有这些文件

v8.dll.lib
v8.dll
icui18n.dll.lib
icui18n.dll
icuuc.dll.lib
icuuc.dll
v8_libplatform.dll.lib
v8_libplatform.dll
v8_libbase.dll.lib
v8_libbase.dll

out.gn目录下怎么会没有我们想要的v8.lib和v8.dll,d8.exe到是正确生成了,且obj文件一个也没少,估计Release模式采用的是静态编译吧。我们打开out.gn\x64.release\args.gn这个文件,把里面的is_component_build = false改成is_component_build = true

在VS的IDE里编译

cd v8
gn gen --ide=vs out.gn\x64_solution

然后就会发现在out.gn有一个all.sln,然后打开就行了

V8版本

Node.js 14.3.0                  2020-05-19    8.1.307.31
Node.js 12.17.0     Erbium      2020-05-26    7.8.279.23
Node.js 10.20.1     Dubnium     2020-04-10    6.8.275.32
文档更新时间: 2020-05-29 09:37   作者:lizw