An idiomatic Rust wrapper for the V8 Javascript engine
APACHE-2.0 License
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.
V8_LIBS
environment variable if defined, or v8-sys's CARGO_MANIFEST_DIR/lib
folder otherwise.natives_blob.bin
and snapshot_blob.bin
next to executables (currently only main.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 the out.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
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.
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
and v8_libsampler.lib
.Also see How to build V8 on Windows and not gomad.
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.