gdextension_file.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. .. _doc_gdextension_file:
  2. The .gdextension file
  3. =====================
  4. Introduction
  5. ------------
  6. The ``.gdextension`` file in your project contains the instructions for how to load
  7. the GDExtension. The instructions are separated into specific sections. This page
  8. should give you a quick overview of the different options available to you. For an introduction
  9. how to get started with GDExtensions take a look at the :ref:`GDExtension C++ Example <doc_gdextension_cpp_example>`.
  10. Configuration section
  11. ---------------------
  12. +-------------------------------+------------+------------------------------------------------------------------------------------------------------+
  13. | Property | Type | Description |
  14. +===============================+============+======================================================================================================+
  15. | **entry_symbol** | String | Name of the entry function for initializing the GDExtension. This function should be defined in |
  16. | | | the ``register_types.cpp`` file when using godot-cpp. Adding this is necessary for the extension to |
  17. | | | work. |
  18. +-------------------------------+------------+------------------------------------------------------------------------------------------------------+
  19. | **compatibility_minimum** | String | Minimum compatible version. This prevents older versions of Godot from loading extensions that |
  20. | | | depend on features from newer versions of Godot. **Only supported in Godot 4.1 or later** |
  21. +-------------------------------+------------+------------------------------------------------------------------------------------------------------+
  22. | **compatibility_maximum** | String | Maximum compatible version. This prevents newer versions of Godot from loading the extension. |
  23. | | | **Only supported in Godot 4.3 or later** |
  24. +-------------------------------+------------+------------------------------------------------------------------------------------------------------+
  25. | **reloadable** | Boolean | Reloads the extension upon recompilation. Reloading is supported for the godot-cpp binding in |
  26. | | | Godot 4.2 or later. Other language bindings may or may not support it as well. This flag should be |
  27. | | | mainly used for developing or debugging an extension. |
  28. +-------------------------------+------------+------------------------------------------------------------------------------------------------------+
  29. | **android_aar_plugin** | Boolean | The GDExtension is part of a :ref:`v2 Android plugin <doc_android_plugin>`. During export this flag |
  30. | | | will indicate to the editor that the GDExtension native shared libraries are exported by the Android |
  31. | | | plugin AAR binaries. |
  32. +-------------------------------+------------+------------------------------------------------------------------------------------------------------+
  33. Libraries section
  34. -----------------
  35. In this section you can set the paths to the compiled binaries of your GDExtension libraries.
  36. By specifying feature flags you can filter which version should be loaded and exported with your
  37. game depending on which feature flags are active. Every feature flag must match to Godot's
  38. feature flags or your custom export flags to be loaded in an exported game. For instance ``macos.debug``
  39. means that it will be loaded if Godot has both the ``macos`` and ``debug`` flag active. Each
  40. line of the section is evaluated from top to bottom.
  41. Here is an example of what that can look like:
  42. .. code-block:: none
  43. [libraries]
  44. macos.debug = "res://bin/libgdexample.macos.template_debug.framework"
  45. macos.release = "res://bin/libgdexample.macos.template_release.framework"
  46. windows.debug.x86_32 = "res://bin/libgdexample.windows.template_debug.x86_32.dll"
  47. windows.release.x86_32 = "res://bin/libgdexample.windows.template_release.x86_32.dll"
  48. windows.debug.x86_64 = "res://bin/libgdexample.windows.template_debug.x86_64.dll"
  49. windows.release.x86_64 = "res://bin/libgdexample.windows.template_release.x86_64.dll"
  50. linux.debug.x86_64 = "res://bin/libgdexample.linux.template_debug.x86_64.so"
  51. linux.release.x86_64 = "res://bin/libgdexample.linux.template_release.x86_64.so"
  52. linux.debug.arm64 = "res://bin/libgdexample.linux.template_debug.arm64.so"
  53. linux.release.arm64 = "res://bin/libgdexample.linux.template_release.arm64.so"
  54. linux.debug.rv64 = "res://bin/libgdexample.linux.template_debug.rv64.so"
  55. linux.release.rv64 = "res://bin/libgdexample.linux.template_release.rv64.so"
  56. Here are lists of some of the available built-in options (for more look at the :ref:`feature tags <doc_feature_tags>`):
  57. Running system
  58. ^^^^^^^^^^^^^^
  59. +-------------------------------+------------------------------------------------------------------------------------------------------+
  60. | Flag | Description |
  61. +===============================+======================================================================================================+
  62. | **windows** | Windows operating system |
  63. +-------------------------------+------------------------------------------------------------------------------------------------------+
  64. | **macos** | Mac operating system |
  65. +-------------------------------+------------------------------------------------------------------------------------------------------+
  66. | **linux** | Linux operating system |
  67. +-------------------------------+------------------------------------------------------------------------------------------------------+
  68. | **bsd** | BSD operating system |
  69. +-------------------------------+------------------------------------------------------------------------------------------------------+
  70. | **linuxbsd** | Linux or BSD operating system |
  71. +-------------------------------+------------------------------------------------------------------------------------------------------+
  72. | **android** | Android operating system |
  73. +-------------------------------+------------------------------------------------------------------------------------------------------+
  74. | **ios** | iOS operating system |
  75. +-------------------------------+------------------------------------------------------------------------------------------------------+
  76. | **web** | Web browser |
  77. +-------------------------------+------------------------------------------------------------------------------------------------------+
  78. Build
  79. ^^^^^
  80. +-------------------------------+------------------------------------------------------------------------------------------------------+
  81. | Flag | Description |
  82. +===============================+======================================================================================================+
  83. | **debug** | Build with debug symbols |
  84. +-------------------------------+------------------------------------------------------------------------------------------------------+
  85. | **release** | Optimized build without debug symbols |
  86. +-------------------------------+------------------------------------------------------------------------------------------------------+
  87. | **editor** | Editor build |
  88. +-------------------------------+------------------------------------------------------------------------------------------------------+
  89. Architecture
  90. ^^^^^^^^^^^^
  91. +-------------------------------+------------------------------------------------------------------------------------------------------+
  92. | Flag | Description |
  93. +===============================+======================================================================================================+
  94. | **double** | double-precision build |
  95. +-------------------------------+------------------------------------------------------------------------------------------------------+
  96. | **single** | single-precision build |
  97. +-------------------------------+------------------------------------------------------------------------------------------------------+
  98. | **x86_64** | 64-bit x86 build |
  99. +-------------------------------+------------------------------------------------------------------------------------------------------+
  100. | **arm64** | 64-bit ARM build |
  101. +-------------------------------+------------------------------------------------------------------------------------------------------+
  102. | **rv64** | 64-bit RISC-V build |
  103. +-------------------------------+------------------------------------------------------------------------------------------------------+
  104. | **riscv** | RISC-V build (any bitness) |
  105. +-------------------------------+------------------------------------------------------------------------------------------------------+
  106. | **wasm32** | 32-bit WebAssembly build |
  107. +-------------------------------+------------------------------------------------------------------------------------------------------+
  108. Icons section
  109. -------------
  110. By default, Godot uses the Node icon in the scene dock for GDExtension nodes. A custom icon can be
  111. set by reference to its name and resource path of an SVG file.
  112. For example:
  113. .. code-block:: none
  114. [icons]
  115. GDExample = "res://icons/gd_example.svg"
  116. The path should point to a 16 by 16 pixel SVG image. Read the guide for :ref:`creating icons <doc_editor_icons>`
  117. for more information.
  118. Dependencies section
  119. --------------------
  120. In this section you set the paths of the GDExtension dependencies. This is used internally to export the dependencies
  121. when exporting your game executable. You are able to set which dependency is loaded depending on the feature flags
  122. of the exported executable. In addition, you are able to set an optional subdirectory to move your dependencies into.
  123. If no path is supplied Godot will move the libraries into the same directory as your game executable.
  124. .. warning::
  125. In MacOS it is necessary to have shared libraries inside a folder called ``Frameworks`` with a directory structure
  126. like this: ``Game.app/Contents/Frameworks``.
  127. .. code-block:: none
  128. [dependencies]
  129. macos.debug = {
  130. "res://bin/libdependency.macos.template_debug.framework" : "Contents/Frameworks"
  131. }
  132. macos.release = {
  133. "res://bin/libdependency.macos.template_release.framework" : "Contents/Frameworks"
  134. }
  135. windows.debug = {
  136. "res://bin/libdependency.windows.template_debug.x86_64.dll" : "",
  137. "res://bin/libdependency.windows.template_debug.x86_32.dll" : ""
  138. }
  139. windows.release = {
  140. "res://bin/libdependency.windows.template_release.x86_64.dll" : "",
  141. "res://bin/libdependency.windows.template_release.x86_32.dll" : ""
  142. }
  143. linux.debug = {
  144. "res://bin/libdependency.linux.template_debug.x86_64.so" : "",
  145. "res://bin/libdependency.linux.template_debug.arm64.so" : "",
  146. "res://bin/libdependency.linux.template_debug.rv64.so" : ""
  147. }
  148. linux.release = {
  149. "res://bin/libdependency.linux.template_release.x86_64.so" : "",
  150. "res://bin/libdependency.linux.template_release.arm64.so" : "",
  151. "res://bin/libdependency.linux.template_release.rv64.so" : ""
  152. }