Compiling for the Web¶
To compile export templates for the Web, the following is required:
For a general overview of SCons usage for Godot, see Introduction to the buildsystem.
Building export templates¶
Before starting, confirm that the Emscripten configuration file exists and
specifies all settings correctly. This file is available as
on UNIX-like systems and
%USERPROFILE%\.emscripten on Windows. It's usually
written by the Emscripten SDK, e.g. when invoking
emsdk activate latest,
or by your package manager. It's also created when starting Emscripten's
emcc program if the file doesn't exist.
On Windows, make sure to escape backslashes of paths within the Emscripten
configuration file as double backslashes
\\ or use Unix-style paths with a
single forward slash
Open a terminal and navigate to the root directory of the engine source code.
release for a release build or
release_debug for a debug build:
eval() calls can be a security concern, the
The engine will now be compiled to WebAssembly by Emscripten. Once finished,
the resulting file will be placed in the
bin subdirectory. Its name is
Finally, rename the zip archive to
webassembly_release.zip for the
webassembly_debug.zip for the debug template:
Building per asm.js translation or LLVM backend¶
WebAssembly can be compiled in two ways: The default is to first compile to
fastcomp fork of LLVM. This code is then translated to WebAssembly using a
asm2wasm. Emscripten automatically takes care of both
processes, we simply run SCons.
The other method uses LLVM's WebAssembly backend. This backend is available starting with LLVM 8 or in development builds. Emscripten manages this process as well, so we just invoke SCons.
In order to choose one of the two methods, the
LLVM_ROOT variable in the
Emscripten configuration file is used. If it points to a directory containing
binaries of Emscripten's fastcomp fork of clang,
asm2wasm is used.
This is the default in a normal Emscripten installation. Otherwise,
LLVM binaries built with the WebAssembly backend will be expected and
the LLVM's WebAssembly backend is used.