一、编译v8引擎

本文详细介绍了如何编译V8 JavaScript引擎,从了解V8、获取源码仓库、安装depot_tools、更新依赖项,到解决编译过程中遇到的问题,包括指定Python解释器和修改特定代码行以适应Windows环境。
摘要由CSDN通过智能技术生成

目录

What is V8?

1. 源码仓库

2. depot_tools

3. 下载源码

4. 更新依赖项 

5. 编译


官方网站

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文件。

        编译生成:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值