目录
What is V8?
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js, among others.
1. 源码仓库
V8’s Git repository is located at https://chromium.googlesource.com/v8/v8.git, with an official mirror on GitHub: https://github.com/v8/v8.
Don’t just git clone
either of these URLs! if you want to build V8 from your checkout, instead follow the instructions below to get everything set up correctly.
官方提示,如果你是想构建v8,不要只是从GitHub上git clone代码,需要按照下面的说明获取正确的依赖项。
2. depot_tools
depot_tools - A collection of tools for dealing with Chromium development.
安装说明:GET DEPOT TOOLS
根据文档中的说明,下载depot_tools bundle,然后添加环境变量,最后在cmd.exe中执行gclient命令,安装编译依赖项。注意:环境变量要添加在所有Python相关变量之前。
这里必须使用Windows的cmd.exe,而不是PowerShell。
3. 下载源码
mkdir v8
cd v8
fetch v8
这是一个漫长的等待……
4. 更新依赖项
git pull origin
gclient sync
这又是一个漫长的等待……
中间可能报错:
需要设置环境变量,设置完后继续刚才命令 :
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
总耗时1小时20分钟才下载完成~~~~~~
5. 编译
tools\dev\gm.py x64.release
报错了:
解决方法:指定Python解释器。虽然没有使用Python2,但是使用Python3页没有继续报错。
python3 tools\dev\gm.py x64.release
然后继续报错了:
因为os.uname()不支持Windows,所以需要修改代码,打开tools\dev\gm.py line 254,修改如下代码,并增加库导入。
import platform
编译完成会在out目录下生成d8.exe,如果想生成v8.dll,需要修改一下tools\dev\gm.py文件。
编译生成: