-
Notifications
You must be signed in to change notification settings - Fork 12
Development
These instructions describe the process of building the Godot Wasm GDExtension/GDNative addon. For building the Godot engine with Godot Wasm as a module, see Installation.
This is intended to aid in developing the Godot Wasm project; not simply using it in a Godot project.
These instructions are tailored to UNIX machines.
- Clone repo and submodules via
git clone --recurse-submodules https://github.com/ashtonmeuser/godot-wasm.git
. - Ensure the correct Godot submodule commit is checked out. Refer to relevant branch of the godot-cpp project e.g.
3.x
to verify submodule hash. At the time of this writing, the hash for the godot-cpp submodule was1049927a596402cd2e8215cd6624868929f5f18d
. - Install SConstruct via
pip install SCons
. SConstruct is what Godot uses to build Godot and generate C++ bindings. For convenience, we'll use the same tool to build the Godot Wasm addon. - Compile the Godot C++ bindings. From within the godot-cpp directory, run
scons target=template_release generate_bindings=yes platform=PLATFORM
replacingPLATFORM
with your relevant platform type e.g.macos
,linux
,windows
, etc. - Compile the Godot Wasm addon. From the repository root directory, run
scons target=template_release platform=PLATFORM
once again replacingPLATFORM
with your platform. This will create the addons/godot-wasm/bin/PLATFORM directory wherePLATFORM
is your platform. You should see a dynamic library (.dylib, .so, .dll, etc.) created within this directory. Note that this step will automatically download Wasmer libraries from the Wasmer releases page if a wasmer directory is not found. If you'd prefer to do this manually, download the Wasmer artifact and extract it to into a wasmer directory at the root of the Godot Wasm project. Verify that the wasmer directory contains include and lib subdirectories. This step can optionally include the argumentsdownload_runtime=yes
andruntime_version=vX.Y.Z
(replacingX
,Y
,Z
with major, minor, patch versions) to force a (re)download of Wasmer and override the default Wasmer download version, respectively. - Compress the addons directory via
zip -FSr addons.zip addons
. This allows the addon to be conveniently distributed and imported into Godot. This ZIP file can be imported directly into Godot (see Installation).
Note When building for Godot 3.x, use
target=release
instead oftarget=template_release
in the instructions above. Additionally, useplatform=osx
instead ofplatform=macos
when building for macOS.
If frequently iterating on the addon using a Godot project, it may help to create a symlink from the Godot project to the compiled addon via ln -s RELATIVE_PATH_TO_ADDONS addons
from the root directory of your Godot project.
Note
Godot Wasm must be build from source to change the Wasm runtime. If using a prepackaged release of Godot Wasm e.g. from the Godot Asset Library, you're restricted to using the default runtime.
Godot Wasm can be configured to use either the Wasmer or Wasmtime WebAssembly runtimes. By default, Wasmer is used. When building as either a Godot addon or module, Godot Wasm can accept the following options to configure the runtime.
Argument | Description |
---|---|
wasm_runtime |
Either "wasmer" or "wasmtime". Defaults to "wasmer". Determines the WebAssembly runtime used. |
dowload_runtime |
Boolean option accepting either "yes" or "no" (default). Forces (re)downloading of the runtime library. By default, the library is only downloaded when the wasmer or wasmtime directory is not found. |
runtime_version |
The version of the selected WebAssembly runtime used. Must be valid semver. |
For example, the following command will build Godot with Godot Wasm as a module using version 12.0.1 of the Wasmtime runtime and forcing a (re)download of the Wasmtime library scons platform=macos arch=x86_64 target=editor wasm_runtime=wasmtime runtime_version=v12.0.1 download_runtime=yes
.