|
| 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 own build system <_doc_compiling_index>`, and some commands available there |
| 8 | +should be available in godot-cpp as well. |
| 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 find out 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>`__. |
| 28 | + |
| 29 | +Configuring an IDE |
| 30 | +------------------ |
| 31 | + |
| 32 | +Most IDEs can use a ``compile_commands.json`` file to understand a C++ project. You can generate it in godot-cpp with |
| 33 | +the following command: |
| 34 | + |
| 35 | +.. code-block:: shell |
| 36 | +
|
| 37 | + # Generate compile_commands.json while compiling |
| 38 | + scons compiledb=yes |
| 39 | +
|
| 40 | + # Generate compile_commands.json without compiling |
| 41 | + scons compiledb=yes compile_commands.json |
| 42 | +
|
| 43 | +For more information, please check out the :ref:`IDE configuration guides <doc_configuring_an_ide>`. |
| 44 | +Although written for Godot engine contributors, they are largely applicable to godot-cpp projects as well. |
| 45 | + |
| 46 | +Loading your GDExtension in Godot |
| 47 | +--------------------------------- |
| 48 | + |
| 49 | +Godot loads GDExtensions by finding :ref:`.gdextension <_doc_gdextension_file>` files in the project directory. |
| 50 | +``.gdextension`` files are used to find and load a binary compatible with the current computer / operating system. |
| 51 | + |
| 52 | +The `godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__, as well as the |
| 53 | +:ref:`Getting Started section <doc_godot_cpp_getting_started>`, provide example ``.gdextension`` files for GDExtensions |
| 54 | +that are widely compatible to many different systems. |
| 55 | + |
| 56 | +Building for multiple platforms |
| 57 | +------------------------------- |
| 58 | + |
| 59 | +GDExtensions are expected to run on many different systems. Generally, a single computer is only capable of building |
| 60 | +for a few different platforms. For example, Windows users will be able to build for Windows, Android and Web, |
| 61 | +but not for macOS or Linux. |
| 62 | + |
| 63 | +To make your GDExtension as widely compatible as possible, we recommend setting up Continuous Integration (CI) to build |
| 64 | +your GDExtension on many different platforms. The |
| 65 | +`godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__ contains an example setup for a GitHub based |
| 66 | +CI workflow. |
| 67 | + |
| 68 | +CMake |
| 69 | +----- |
| 70 | + |
| 71 | +godot-cpp comes with a `CMakeLists.txt <https://github.com/godotengine/godot-cpp/blob/master/CMakeLists.txt>`__ file, to |
| 72 | +support users that prefer using `CMake <https://cmake.org>`__ over `SCons <https://scons.org>`__ for their build system. |
| 73 | + |
| 74 | +While actively supported, it is considered secondary to the SCons build system. This means it may lack some features |
| 75 | +that are provided for users using SCons. It is documented in godot-cpp's |
| 76 | +`cmake.rst <https://github.com/godotengine/godot-cpp/blob/master/doc/cmake.rst>`__ file. |
0 commit comments