Skip to content

Commit d703914

Browse files
committed
Add documentation on using the Engine compilation configuration editor
1 parent a1632ef commit d703914

File tree

6 files changed

+139
-1
lines changed

6 files changed

+139
-1
lines changed

about/list_of_features.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ XR support (AR and VR)
669669

670670
- Currently only exporting an application for use on a flat plane within the
671671
headset is supported. Immersive experiences are not supported.
672-
672+
673673
- Other devices supported through an XR plugin structure.
674674
- Various advanced toolkits are available that implement common features required by XR applications.
675675

@@ -776,8 +776,16 @@ Miscellaneous
776776
- Print colored text to standard output on all platforms using
777777
:ref:`print_rich <class_@GlobalScope_method_print_rich>`.
778778

779+
- The editor can
780+
:ref:`detect features used in a project and create a compilation profile <doc_engine_compilation_configuration_editor>`,
781+
which can be used to create smaller export template binaries
782+
with unneeded features disabled.
779783
- Support for :ref:`C++ modules <doc_custom_modules_in_cpp>` statically linked
780784
into the engine binary.
785+
786+
- Most built-in modules can be disabled at compile-time to reduce binary size
787+
in custom builds. See :ref:`doc_optimizing_for_size` for details.
788+
781789
- Engine and editor written in C++17.
782790

783791
- Can be :ref:`compiled <doc_introduction_to_the_buildsystem>` using GCC,

contributing/development/compiling/optimizing_for_size.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,29 @@ Godot 4.5 introduced the ``size_extra`` option, which can further reduce size.
9393

9494
scons target=template_release optimize=size_extra
9595

96+
Detecting used features from the current project and disabling unused features
97+
------------------------------------------------------------------------------
98+
99+
- **Space savings:** Moderate to high depending on project
100+
- **Difficulty:** Easy to medium depending on project
101+
- **Performed in official builds:** No
102+
103+
Godot features an :ref:`doc_engine_compilation_configuration_editor` tool that can detect
104+
the features used in the current project and create a build profile. Once saved,
105+
this build profile can then be passed to SCons when compiling custom export templates:
106+
107+
::
108+
109+
scons target=template_release build_profile=/path/to/build.gdbuild
110+
111+
Note that for certain projects, the feature detection may be too aggressive and disable features
112+
that are actually needed at runtime. This can occur if certain features are used in a way that
113+
their use cannot be detected statically (such as a script being procedurally created
114+
and run at runtime).
115+
116+
More specific features can be disabled by following the sections below, but remember
117+
that many of them are automatically detected by the engine compilation configuration detector.
118+
96119
Disabling advanced text server
97120
------------------------------
98121

14.2 KB
Loading
13.9 KB
Loading

tutorials/editor/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ like Visual Studio Code or Emacs.
8181

8282
command_line_tutorial
8383
external_editor
84+
using_engine_compilation_configuration_editor
8485

8586
Managing editor features
8687
------------------------
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
.. _doc_engine_compilation_configuration_editor:
2+
3+
Using the engine compilation configuration editor
4+
=================================================
5+
6+
Godot comes with a large set of built-in features. While this is convenient,
7+
this also means its binary size is larger than it could be, especially
8+
on projects that only use a small portion of its feature set.
9+
10+
To help reduce binary size, it is possible to compile custom export templates
11+
with certain features disabled. This is described in detail in :ref:`doc_optimizing_for_size`.
12+
However, determining which features need to be disabled can be a tedious task.
13+
The engine compilation configuration editor aims to address this
14+
by providing an interface to view and manage these features easily,
15+
while also being able to detect the features currently being used in the project.
16+
17+
The :menu:`Project > Tools > Engine Compilation Configuration Editor`
18+
allows you to create and manage build profiles for your Godot project.
19+
20+
From now on, you have two possibilities:
21+
22+
- View the list and manually uncheck features that you don't need.
23+
- Use the :button:`Detect from Project` button to automatically detect features
24+
currently used in the project and disable unused features. Note that this will
25+
override the existing list of features, so if you have manually unchecked some
26+
items, their state will be reset according to whether the project actually
27+
uses the feature.
28+
29+
.. figure:: img/engine_compilation_configuration_editor_detect.webp
30+
:align: center
31+
:alt: Opening the Engine Compilation Configuration Editor
32+
33+
Opening the Engine Compilation Configuration Editor
34+
35+
Once you click :button:`Detect from Project`
36+
The project detection step will run. This can take from a few seconds up to
37+
several minutes depending on the project size. Once detection is complete,
38+
you'll see an updated list of features with some features disabled:
39+
40+
.. figure:: img/engine_compilation_configuration_editor_detected.webp
41+
:align: center
42+
:alt: Updated features list after using feature detection (example from the 3D platformer demo)
43+
44+
Updated features list after using feature detection (example from the 3D platformer demo)
45+
46+
.. warning::
47+
48+
Unchecking features in this dialog will not reduce binary size directly on export.
49+
Since it is only possible to actually remove features from the binary at compile-time,
50+
you still need to compile custom export templates with the build profile specified
51+
to actually benefit from the engine compilation configuration editor.
52+
53+
You can now save the build profile by clicking **Save As** at the top.
54+
The build profile can be saved in any location, but it's a good idea to
55+
save it somewhere in your project folder and add it to version control to be able
56+
to go back to it later when needed. This also allows using version control
57+
to track changes to the build profile.
58+
59+
The build profile is a file in JSON format (and ``.gdbuild`` extension) that looks like this
60+
after detection in the above example:
61+
62+
::
63+
64+
{
65+
"disabled_build_options": {
66+
"disable_navigation_3d": true,
67+
"disable_xr": true,
68+
"module_godot_physics_3d_enabled": false,
69+
"module_msdfgen_enabled": false,
70+
"module_openxr_enabled": false
71+
},
72+
"disabled_classes": [
73+
"AESContext",
74+
...
75+
"ZIPReader"
76+
],
77+
"type": "build_profile"
78+
}
79+
80+
This file can be passed as a SCons option when :ref:`compiling <doc_compiling_index>`
81+
export templates:
82+
83+
::
84+
85+
scons target=template_release build_profile=/path/to/build.gdbuild
86+
87+
The buildsystem will use this to disable unused classes and reduce binary size as a result.
88+
89+
Limitations
90+
-----------
91+
92+
The :button:`Detect from Project` functionality relies on reading the project's scenes and scripts.
93+
It will not be able to detect used features in the following scenarios:
94+
95+
- Features that are used in GDScripts that are procedurally created then run at runtime.
96+
- Features that are used in :ref:`expressions <doc_evaluating_expressions>`.
97+
- Features that are used in :ref:`GDExtensions <doc_gdextension>`.
98+
- Features that are used in :ref:`external PCKs loaded at runtime <doc_exporting_pcks>`.
99+
- Certain edge cases may exist. If unsure, please
100+
`open an issue on GitHub <https://github.com/godotengine/godot/issues>`__
101+
with a minimal reproduction project attached.
102+
103+
.. seealso::
104+
105+
You can achieve further size reductions by passing other options that reduce binary size.
106+
See :ref:`doc_optimizing_for_size` for more information.

0 commit comments

Comments
 (0)