Skip to content

Commit 88604e5

Browse files
committed
Move godot-cpp custom bindings information to the 'build system' instructions from the intro doc, because most people won't need it for their first project.
1 parent 6ebd201 commit 88604e5

File tree

3 files changed

+36
-39
lines changed

3 files changed

+36
-39
lines changed

tutorials/scripting/cpp/about_godot_cpp.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,5 @@ for details.
8585

8686
Generally speaking, if you build a custom version of Godot, you should generate an
8787
``extension_api.json`` from it for your GDExtensions, because it may have some differences
88-
from official Godot builds.
88+
from official Godot builds. You can learn more about the process of using custom
89+
``extension_api.json`` files in the :ref:`build system section <doc_godot_cpp_build_system>`.

tutorials/scripting/cpp/build_system/scons.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,37 @@ There are two popular ways by which cross platform builds can be achieved:
7373
`godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__ contains an
7474
`example setup <https://github.com/godotengine/godot-cpp-template/tree/main/.github/workflows>`__
7575
for a GitHub based CI workflow.
76+
77+
Using a custom API file
78+
-----------------------
79+
80+
Every branch of godot-cpp comes with an API file (``extension_api.json``) appropriate for
81+
the respective Godot version (e.g. the ``4.3`` branch comes with the API file compatible
82+
with Godot version ``4.3`` and later).
83+
84+
However, you may want to use a custom ``extension_api.json``, for example:
85+
86+
* If you want to use the latest APIs from Godot ``master``.
87+
* If you :ref:`build Godot yourself <doc_compiling_index>` with different options than the official builds (e.g. ``disable_3d=yes`` or ``precision=double``).
88+
* If you want to use APIs exposed by custom modules.
89+
90+
To use a custom API file, you first have to generate it from the appropriate Godot
91+
executable:
92+
93+
.. code-block:: shell
94+
95+
godot --dump-extension-api
96+
97+
The resulting ``extension_api.json`` file will be created in the executable's
98+
directory. To use it, you can add ``custom_api_file`` to your build command:
99+
100+
.. code-block:: shell
101+
102+
scons platform=<platform> custom_api_file=<PATH_TO_FILE>
103+
104+
Alternatively, you can add it as the default API file to your project by adding
105+
the following line to your SConstruct file:
106+
107+
.. code-block:: python
108+
109+
localEnv["custom_api_file"] = "extension_api.json"

tutorials/scripting/cpp/gdextension_cpp_example.rst

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -97,44 +97,6 @@ following commands:
9797
9898
This will initialize the repository in your project folder.
9999

100-
Building the C++ bindings
101-
-------------------------
102-
103-
Now that we've downloaded our prerequisites, it is time to build the C++
104-
bindings.
105-
106-
The repository contains a copy of the metadata for the current Godot release,
107-
but if you need to build these bindings for a newer version of Godot, call
108-
the Godot executable:
109-
110-
.. code-block:: none
111-
112-
godot --dump-extension-api
113-
114-
The resulting ``extension_api.json`` file will be created in the executable's
115-
directory. Copy it to the project folder and add ``custom_api_file=<PATH_TO_FILE>``
116-
to the scons command below.
117-
118-
To generate and compile the bindings, use this command (replacing ``<platform>``
119-
with ``windows``, ``linux`` or ``macos`` depending on your OS):
120-
121-
The build process automatically detects the number of CPU threads to use for
122-
parallel builds. To specify a number of CPU threads to use, add ``-jN`` at the
123-
end of the SCons command line where ``N`` is the number of CPU threads to use.
124-
125-
.. code-block:: none
126-
127-
cd godot-cpp
128-
scons platform=<platform> custom_api_file=<PATH_TO_FILE>
129-
cd ..
130-
131-
This step will take a while. When it is completed, you should have static
132-
libraries that can be compiled into your project stored in ``godot-cpp/bin/``.
133-
134-
.. note::
135-
136-
You may need to add ``bits=64`` to the command on Windows or Linux.
137-
138100
Creating a simple plugin
139101
------------------------
140102

0 commit comments

Comments
 (0)