Skip to content

Commit 00e4ed8

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

File tree

6 files changed

+138
-1
lines changed

6 files changed

+138
-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

Binary file not shown.
Binary file not shown.

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: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
for 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 based on 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`, the project detection step will run.
36+
This can take from a few seconds up to several minutes depending on the project size.
37+
Once detection is complete, you'll see an updated list of features with some features disabled:
38+
39+
.. figure:: img/engine_compilation_configuration_editor_detected.webp
40+
:align: center
41+
:alt: Updated features list after using feature detection (example from the 3D platformer demo)
42+
43+
Updated features list after using feature detection (example from the 3D platformer demo)
44+
45+
.. warning::
46+
47+
Unchecking features in this dialog will not reduce binary size directly on export.
48+
Since it is only possible to actually remove features from the binary at compile-time,
49+
you still need to compile custom export templates with the build profile specified
50+
to actually benefit from the engine compilation configuration editor.
51+
52+
You can now save the build profile by clicking **Save As** at the top.
53+
The build profile can be saved in any location, but it's a good idea to
54+
save it somewhere in your project folder and add it to version control to be able
55+
to go back to it later when needed. This also allows using version control
56+
to track changes to the build profile.
57+
58+
The build profile is a JSON file (and ``.gdbuild`` extension) that looks like this
59+
after detection in the above example:
60+
61+
::
62+
63+
{
64+
"disabled_build_options": {
65+
"disable_navigation_3d": true,
66+
"disable_xr": true,
67+
"module_godot_physics_3d_enabled": false,
68+
"module_msdfgen_enabled": false,
69+
"module_openxr_enabled": false
70+
},
71+
"disabled_classes": [
72+
"AESContext",
73+
...
74+
"ZIPReader"
75+
],
76+
"type": "build_profile"
77+
}
78+
79+
This file can be passed as a SCons option when :ref:`compiling <doc_compiling_index>`
80+
export templates:
81+
82+
::
83+
84+
scons target=template_release build_profile=/path/to/build.gdbuild
85+
86+
The buildsystem will use this to disable unused classes and reduce binary size as a result.
87+
88+
Limitations
89+
-----------
90+
91+
The :button:`Detect from Project` functionality relies on reading the project's scenes and scripts.
92+
It will not be able to detect used features in the following scenarios:
93+
94+
- Features that are used in GDScripts that are procedurally created then run at runtime.
95+
- Features that are used in :ref:`expressions <doc_evaluating_expressions>`.
96+
- Features that are used in :ref:`GDExtensions <doc_gdextension>`.
97+
- Features that are used in :ref:`external PCKs loaded at runtime <doc_exporting_pcks>`.
98+
- Certain edge cases may exist. If unsure, please
99+
`open an issue on GitHub <https://github.com/godotengine/godot/issues>`__
100+
with a minimal reproduction project attached.
101+
102+
.. seealso::
103+
104+
You can achieve further size reductions by passing other options that reduce binary size.
105+
See :ref:`doc_optimizing_for_size` for more information.

0 commit comments

Comments
 (0)