Rust bindings for v8 7.0, the JavaScript engine.
This is an attempt to rewrite the existing v8 crate to enable it to work with the latest version of V8. Hence, substantial portions of its code were used whenever possible.
Use cargo doc --open
. This is not on crates.io yet, since this is highly experimental, and an existing crate already exists with this name.
- Llatest nightly Rust.
- Static libraries for V8 built with snapshot support and without i18n support for now, see V8's official build instructions. V8-sys will look for the necessary .libs to link against in the
V8_LIBS
environment variable if defined, or v8-sys'sCARGO_MANIFEST_DIR/lib
folder otherwise. - Place
natives_blob.bin
andsnapshot_blob.bin
next to executables (currently onlymain.rs
) using this crate.
Clone from GitHub to obtain the latest development version, ensure you have V8 static libraries, then cargo build
.
Building on Windows is very frustrating due to some known bugs. Here's how to get a successful build.
-
Follow the steps in the official documentation to check out the V8 repository and set up depot tools and other dependencies. The latest version of VS2017 works as well.
-
Edit the
args.gn
file in theout.gn/x64-release
folder so it contains the following:
is_debug = false
target_cpu = "x64"
is_component_build = false
v8_static_library = true
v8_enable_i18n_support=false
is_clang=false
use_lld = false
- Build the libraries for embedding with the following command:
ninja -C out.gn/x64.release v8
The official documentation suggests using the ninja -C out.gn/x64.release
, which builds tests and fuzzers in addition to the libraries. Besides taking twice as long, the build fails due to unfixed bugs in the compilation of tests.
- You will need to place the following libraries from the build somewhere v8-sys can link against:
inspector.lib, v8_base_0.lib, v8_base_1.lib, v8_external_snapshot.lib, v8_init.lib, v8_initializers.lib, v8_libbase.lib, v8_libplatform.lib
andv8_libsampler.lib
.
Also see How to build V8 on Windows and not go mad.
The optional feature "use-bindgen" generates the low level bindings using the included V8 headers (version 7.0), which requires bindgen to be installed. Generating this shouldn't be necessary in most cases, as the bindings have already been bundled with this crate.