scons.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. .. _doc_godot_cpp_build_system:
  2. Main build system: Working with SCons
  3. =====================================
  4. .. seealso:: This page documents how to compile godot-cpp. If you're looking to compile Godot instead, see
  5. :ref:`doc_introduction_to_the_buildsystem`.
  6. `godot-cpp <https://github.com/godotengine/godot-cpp>`__ uses `SCons <https://scons.org>`__ as its main 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. Getting started
  10. ---------------
  11. To build a godot-cpp project, it is generally sufficient to install `SCons <https://scons.org>`__, and simply run it
  12. in the project directory:
  13. scons
  14. You may want to learn about available options:
  15. scons --help
  16. To cleanly re-build your project, add ``--clean`` to your build command:
  17. scons --clean
  18. You can find more information about common SCons arguments and build patterns in the
  19. `SCons User Guide <https://scons.org/doc/latest/HTML/scons-user/index.html>`__. Additional commands may be added by
  20. individual godot-cpp projects, so consult their specific documentation for more information on those.
  21. Configuring an IDE
  22. ------------------
  23. Most IDEs can use a ``compile_commands.json`` file to understand a C++ project. You can generate it with godot-cpp using
  24. the following command:
  25. .. code-block:: shell
  26. # Generate compile_commands.json while compiling.
  27. scons compiledb=yes
  28. # Generate compile_commands.json without compiling.
  29. scons compiledb=yes compile_commands.json
  30. For more information, please check out the :ref:`IDE configuration guides <doc_configuring_an_ide>`.
  31. Although written for Godot engine contributors, they are largely applicable to godot-cpp projects as well.
  32. Loading your GDExtension in Godot
  33. ---------------------------------
  34. Godot loads GDExtensions by finding :ref:`.gdextension <doc_gdextension_file>` files in the project directory.
  35. ``.gdextension`` files are used to select and load a binary compatible with the current computer / operating system.
  36. The `godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__, as well as the
  37. :ref:`Getting Started section <doc_godot_cpp_getting_started>`, provide example ``.gdextension`` files for GDExtensions
  38. that are widely compatible to many different systems.
  39. Building for multiple platforms
  40. -------------------------------
  41. GDExtensions are expected to run on many different systems, each with separate binaries and build configurations.
  42. If you are planning to publish your GDExtension, we recommend you provide binaries for all configurations that are
  43. mentioned in the `godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__
  44. `.gdextension file <https://github.com/godotengine/godot-cpp-template/blob/main/demo/bin/example.gdextension>`__.
  45. There are two popular ways by which cross platform builds can be achieved:
  46. - Cross-platform build tools
  47. - Continuous Integration (CI)
  48. `godot-cpp-template <https://github.com/godotengine/godot-cpp-template>`__ contains an
  49. `example setup <https://github.com/godotengine/godot-cpp-template/tree/main/.github/workflows>`__
  50. for a GitHub based CI workflow.