-
-
Notifications
You must be signed in to change notification settings - Fork 16
Building from Source
v8
is used as the default JavaScript runtime.
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:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
STEP 2
Add the depot_tools
path into the environment variable PATH
.
On windows
:
set PATH=Your\Path\To\depot_tools;%PATH%
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
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
:
export PATH=Your/Path/To/depot_tools:$PATH
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:
gn gen ./out.gn/x64.release
Modify the options in out.gn/x64.release/args.gn
. See Options
STEP 5
Build:
ninja -C ./out.gn/x64.release v8_monolith
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
Follow the instructions below to set it up:
STEP 1: Download or clone the repo into the modules
directory of your Godot engine source:
cd YourGodotEngineSource/modules
git clone https://github.com/ialex32x/GodotJS.git
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 prebuilt v8
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:
Note
Since the prebuilt v8
library is built with the windows-latest
github runner which uses VS2022, encountering Unresolved external symbol
errors during linkage with v8_monolith.lib
or libucrt.lib
may be addressed by updating to the latest version of the MSVC v143
toolchain, Windows Universal CRT SDK
and Visual 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
.
To enable JavaScriptCore
, please run scons with the parameter use_jsc=yes
.
Note
JavaScriptCore
is only available on macOS/iOS since the system bundled JavaScriptCore.framework
is used.
# An example on macOS:
scons compiledb=yes dev_build=yes use_jsc=yes
To enable QuickJS
, please run scons with the parameter use_quickjs=yes
, or use_quickjs_ng=yes
if quickjs-ng is preferred.
Note
QuickJS
is also available for WebBuild.
If you choose quickjs-ng, please clone the source with submodules:
# If it's a fresh clone
git clone --recurse-submodules https://github.com/godotjs/GodotJS.git
# If you've already cloned it prior
git submodule update --init --recursive
Then, build Godot from source:
# An example on Windows:
scons vsproj=yes dev_build=yes p=windows use_quickjs_ng=yes
It's enabled by default for WebBuild.
Note
Be cautious about the JS compatibility issues between different web browsers.
-
Scripting
-
Utilities
-
Experimental Features
-
Advanced
-
Misc