Skip to content

Commit a05d8c3

Browse files
committed
Add "Build System" section to godot-cpp docs.
1 parent 8db2f3e commit a05d8c3

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.. _doc_godot_cpp_build_system:
2+
3+
Build System
4+
============
5+
6+
`godot-cpp <https://github.com/godotengine/godot-cpp>`__ uses `SCons <https://scons.org>`__ as its build system.
7+
It is modeled after :ref:`Godot's build system <doc_compiling_index>`, and some commands available there are also
8+
available in godot-cpp projects.
9+
10+
Getting Started
11+
---------------
12+
13+
To build a godot-cpp project, it is generally sufficient to install `SCons <https://scons.org>`__, and simply run it
14+
in the project directory:
15+
16+
scons
17+
18+
You may want to learn about available options:
19+
20+
scons --help
21+
22+
To cleanly re-build your project, add ``--clean`` to your build command:
23+
24+
scons --clean
25+
26+
You can find more information about common SCons arguments and build patterns in the
27+
`SCons User Guide <https://scons.org/doc/latest/HTML/scons-user/index.html>`__. Additional commands may be added by
28+
individual godot-cpp projects, so consult their individual documentations for more information on those.
29+
30+
Configuring an IDE
31+
------------------
32+
33+
Most IDEs can use a ``compile_commands.json`` file to understand a C++ project. You can generate it in godot-cpp with
34+
the following command:
35+
36+
.. code-block:: shell
37+
38+
# Generate compile_commands.json while compiling
39+
scons compiledb=yes
40+
41+
# Generate compile_commands.json without compiling
42+
scons compiledb=yes compile_commands.json
43+
44+
For more information, please check out the :ref:`IDE configuration guides <doc_configuring_an_ide>`.
45+
Although written for Godot engine contributors, they are largely applicable to godot-cpp projects as well.
46+
47+
Loading your GDExtension in Godot
48+
---------------------------------
49+
50+
Godot loads GDExtensions by finding :ref:`.gdextension <doc_gdextension_file>` files in the project directory.
51+
``.gdextension`` files are used to select and load a binary compatible with the current computer / operating system.
52+
53+
The `godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__, as well as the
54+
:ref:`Getting Started section <doc_godot_cpp_getting_started>`, provide example ``.gdextension`` files for GDExtensions
55+
that are widely compatible to many different systems.
56+
57+
Building for multiple platforms
58+
-------------------------------
59+
60+
GDExtensions are expected to run on many different systems. Generally, a single computer is only capable of building
61+
for a few different platforms. For example, Windows users will be able to build for Windows, Android and Web,
62+
but not for macOS or Linux.
63+
64+
To make your GDExtension as widely compatible as possible, we recommend setting up Continuous Integration (CI) to build
65+
your GDExtension on many different platforms. The
66+
`godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__ contains an example setup for a GitHub based
67+
CI workflow.
68+
69+
CMake
70+
-----
71+
72+
godot-cpp comes with a `CMakeLists.txt <https://github.com/godotengine/godot-cpp/blob/master/CMakeLists.txt>`__ file, to
73+
support users that prefer using `CMake <https://cmake.org>`__ over `SCons <https://scons.org>`__ for their build system.
74+
75+
While actively supported, it is considered secondary to the SCons build system. This means it may lack some features
76+
that are provided for users using SCons. It is documented in godot-cpp's
77+
`cmake.rst <https://github.com/godotengine/godot-cpp/blob/master/doc/cmake.rst>`__ file.

tutorials/scripting/cpp/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ the official C++ GDExtension bindings maintained as part of the Godot project.
1414

1515
about_godot_cpp
1616
gdextension_cpp_example
17+
build_system
1718
gdextension_docs_system

0 commit comments

Comments
 (0)