V8
v8
is used as the default JavaScript runtime.
Build V8 from Source (Optional)
NOTE: See Setup V8 in GodotJS if a prebuilt version of v8 from GodotJS-Dependencies is used.
Building V8 from source is needed if you do not want to use the prebuilt version from GodotJS-Dependencies. Follow the steps below:
STEP 1
Download depot_tools
from https://storage.googleapis.com/chrome-infra/depot_tools.zip if using Windows
, and extract it to a path you want.
Otherwise, get depot_tools
from the git repository:
STEP 2
Add the depot_tools
path into the environment variable PATH
.
On windows
:
NOTE: If
DEPOT_TOOLS_WIN_TOOLCHAIN
is not set,depot_tools
will fail to build because it will try to use the google internal toolchain instead of the locally installed Visual Studio.
On linux
, macos
:
STEP 3
Sync and fetch v8:
cd Your/Path/To/depot_tools
gclient
mkdir -p Your/Path/To/v8
cd Your/Path/To/v8
fetch v8
cd v8
git checkout refs/tags/12.4.254.20
gclient sync
STEP 4
Generate build configurations:
Modify the options in out.gn/x64.release/args.gn
. See Options
STEP 5
Build:
Options Currently Used for Building V8
Windows x64
is_component_build = false
is_debug = false
target_cpu = "x64"
target_os = "win"
v8_enable_i18n_support = false
v8_monolithic = true
v8_use_external_startup_data = false
v8_enable_pointer_compression = true
v8_jitless = false # jit enabled
use_custom_libcxx = false # false will produce warnings
treat_warnings_as_errors = false #
v8_symbol_level = 0 # smaller lib
v8_enable_sandbox = false
Macos arm64
# v8_enable_backtrace = true
# v8_enable_disassembler = true
# v8_enable_object_print = true
# v8_enable_verify_heap = true
dcheck_always_on = false
is_component_build = false
is_debug = false
target_cpu = "arm64"
v8_target_cpu = "arm64"
target_os = "mac"
v8_enable_i18n_support = false
v8_monolithic = true
v8_use_external_startup_data = false
v8_enable_pointer_compression = true
v8_jitless = false # jit enabled
v8_enable_webassembly = false
use_custom_libcxx = false # false will produce warnings
treat_warnings_as_errors = false #
v8_symbol_level = 0 # smaller lib
v8_enable_sandbox = false
use_rtti = true
Setup V8 in GodotJS
Follow the instructions below to set it up:
STEP 1: Download or clone the repo into the modules
directory of your Godot engine source:
STEP 2: Put v8
headers and libraries into GodotJS
, or directly download the prebuilt v8
from GodotJS-Dependencies:
# download the archive of prebuilt v8
curl https://github.com/ialex32x/GodotJS-Dependencies/releases/download/v8_12.4.254.21_r13/v8_12.4.254.21_r13.zip --output your/download/path/v8.zip
# extract the zip file into your `GodotJS` directory,
# NOTE: no white space after the switch `-o`
7z x -o"YourGodotEngineSource/modules/GodotJS" your/download/path/v8.zip
NOTE: Don't forget to put the headers/libraries of
v8
into the same directory structure used in prebuiltv8
if you decide to compile it by yourself.
The module directroy structure looks like this:
┗━ godot
┗━ modules
┣━ ...
┣━ gltf
┣━ GodotJS
┃ ┣━ bridge-quickjs
┃ ┣━ bridge-v8
┃ ┣━ ...
┃ ┣━ lws
┃ ┗━ v8
┃ ┣━ include
┃ ┣━ linux.x86_64.release
┃ ┣━ macos.arm64.release
┃ ┣━ windows_x86_64_release
┃ ┗━ ...
┣━ gridmap
┣━ ...
The currently used version of v8
is 12.4.254.21
.
STEP 3: Compile and launch Godot Editor
. Then, you can create a Godot project in TypeScript/JavaScript:
* Create-a-TypeScript-Project-from-Scratch
* Create-a-JavaScript-Project-from-Scratch
NOTE: Since the prebuilt
v8
library is built with thewindows-latest
github runner which uses VS2022, encounteringUnresolved external symbol
errors during linkage withv8_monolith.lib
orlibucrt.lib
may be addressed by updating to the latest version of theMSVC v143
toolchain,Windows Universal CRT SDK
andVisual Studio 2022
itself. See GodotJS-Dependencies README for the version of MSVC C++ Compiler used in different prebuilt library packages.
A prebuilt version of Godot Editor
can be downloaded from GodotJS-Build.
Because the GodotJS-Build workflow is currently run manually, it may not be built from the latest commit of GodotJS
.