2023-01-12 20:49:14 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
# Compiling for the Web
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
This page describes how to compile HTML5 editor and export template binaries from source. If you're looking
|
|
|
|
to export your project to HTML5 instead, read `doc_exporting_for_web`.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 20:55:57 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
## Requirements
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
To compile export templates for the Web, the following is required:
|
|
|
|
|
2023-01-12 20:39:50 +01:00
|
|
|
- `Emscripten 1.39.9+ ( https://emscripten.org )`.
|
|
|
|
- `Python 3.5+ ( https://www.python.org/ )`.
|
|
|
|
- `SCons 3.0+ ( https://www.scons.org )` build system.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2022-09-10 12:15:58 +02:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
To get the Godot source code for compiling, see `doc_getting_source`.
|
|
|
|
For a general overview of SCons usage for Godot, see `doc_introduction_to_the_buildsystem`.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
## Building export templates
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 19:43:03 +01:00
|
|
|
Before starting, confirm that `emcc` is available in your PATH. This is
|
|
|
|
usually configured by the Emscripten SDK, e.g. when invoking `emsdk activate`
|
|
|
|
and `source ./emsdk_env.sh`/`emsdk_env.bat`.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
Open a terminal and navigate to the root directory of the engine source code.
|
2023-01-12 19:43:03 +01:00
|
|
|
Then instruct SCons to build the JavaScript platform. Specify `target` as
|
2023-01-12 22:00:14 +01:00
|
|
|
either `release` for a release build or `release_debug` for a debug build:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
scons platform=javascript tools=no target=release
|
|
|
|
scons platform=javascript tools=no target=release_debug
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 20:47:54 +01:00
|
|
|
By default, the `JavaScript singleton ( doc_javascript_eval )` will be built
|
2022-03-18 17:46:08 +01:00
|
|
|
into the engine. Official export templates also have the JavaScript singleton
|
2023-01-12 19:43:03 +01:00
|
|
|
enabled. Since `eval()` calls can be a security concern, the
|
2023-01-12 22:00:14 +01:00
|
|
|
`javascript_eval` option can be used to build without the singleton:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
scons platform=javascript tools=no target=release javascript_eval=no
|
|
|
|
scons platform=javascript tools=no target=release_debug javascript_eval=no
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
The engine will now be compiled to WebAssembly by Emscripten. Once finished,
|
2023-01-12 19:43:03 +01:00
|
|
|
the resulting file will be placed in the `bin` subdirectory. Its name is
|
|
|
|
`godot.javascript.opt.zip` for release or `godot.javascript.opt.debug.zip`
|
2022-03-18 17:46:08 +01:00
|
|
|
for debug.
|
|
|
|
|
2023-01-12 19:43:03 +01:00
|
|
|
Finally, rename the zip archive to `webassembly_release.zip` for the
|
2023-01-12 22:00:14 +01:00
|
|
|
release template:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
mv bin/godot.javascript.opt.zip bin/webassembly_release.zip
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
And `webassembly_debug.zip` for the debug template:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
mv bin/godot.javascript.opt.debug.zip bin/webassembly_debug.zip
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
## Threads
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
The default export templates do not include threads support for
|
2022-03-18 17:46:08 +01:00
|
|
|
performance and compatibility reasons. See the
|
2023-01-12 20:47:54 +01:00
|
|
|
`export page ( doc_javascript_export_options )` for more info.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
You can build the export templates using the option `threads_enabled=yes` to enable threads support:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
scons platform=javascript tools=no threads_enabled=yes target=release
|
|
|
|
scons platform=javascript tools=no threads_enabled=yes target=release_debug
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 19:43:03 +01:00
|
|
|
Once finished, the resulting file will be placed in the `bin` subdirectory.
|
2023-04-06 23:35:49 +02:00
|
|
|
Its name will have the `.threads` suffix.
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
Finally, rename the zip archives to `webassembly_release_threads.zip` for the release template:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
mv bin/godot.javascript.opt.threads.zip bin/webassembly_threads_release.zip
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
And `webassembly_debug_threads.zip` for the debug template:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
mv bin/godot.javascript.opt.debug.threads.zip bin/webassembly_threads_debug.zip
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-04-06 23:35:49 +02:00
|
|
|
## Building the Editor
|
|
|
|
|
2022-03-18 17:46:08 +01:00
|
|
|
|
|
|
|
It is also possible to build a version of the Godot editor that can run in the
|
|
|
|
browser. The editor version requires threads support and is not recommended
|
2023-01-12 22:00:14 +01:00
|
|
|
over the native build. You can build the editor with:
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
scons platform=javascript tools=yes threads_enabled=yes target=release_debug
|
2023-01-12 22:00:14 +01:00
|
|
|
```
|
2022-03-18 17:46:08 +01:00
|
|
|
|
2023-01-12 19:43:03 +01:00
|
|
|
Once finished, the resulting file will be placed in the `bin` subdirectory.
|
|
|
|
Its name will be `godot.javascript.opt.tools.threads.zip`. You can upload the
|
2022-03-18 17:46:08 +01:00
|
|
|
zip content to your web server and visit it with your browser to use the editor.
|
|
|
|
|
2023-01-12 20:47:54 +01:00
|
|
|
Refer to the `export page ( doc_javascript_export_options )` for the web
|
2022-03-18 17:46:08 +01:00
|
|
|
server requirements.
|