gdextension_file.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 C++ (godot-cpp), take a look at the :ref:`GDExtension C++ Example <doc_godot_cpp_getting_started>`.
  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. ; A comment line starts with a semicolon. This line is ignored by the engine.
  44. [libraries]
  45. macos.debug = "./bin/libgdexample.macos.template_debug.dylib" ; Inline comments are also allowed.
  46. macos.release = "./bin/libgdexample.macos.template_release.dylib"
  47. windows.debug.x86_32 = "./bin/libgdexample.windows.template_debug.x86_32.dll"
  48. windows.release.x86_32 = "./bin/libgdexample.windows.template_release.x86_32.dll"
  49. windows.debug.x86_64 = "./bin/libgdexample.windows.template_debug.x86_64.dll"
  50. windows.release.x86_64 = "./bin/libgdexample.windows.template_release.x86_64.dll"
  51. linux.debug.x86_64 = "./bin/libgdexample.linux.template_debug.x86_64.so"
  52. linux.release.x86_64 = "./bin/libgdexample.linux.template_release.x86_64.so"
  53. linux.debug.arm64 = "./bin/libgdexample.linux.template_debug.arm64.so"
  54. linux.release.arm64 = "./bin/libgdexample.linux.template_release.arm64.so"
  55. linux.debug.rv64 = "./bin/libgdexample.linux.template_debug.rv64.so"
  56. linux.release.rv64 = "./bin/libgdexample.linux.template_release.rv64.so"
  57. Paths can be relative or absolute (starting with ``res://``). Relative paths are recommended,
  58. as they allow the extension to keep working if it's installed to a different folder than what's
  59. specified in the path.
  60. Entries are matched in order, so if two sets of feature tags could match
  61. the same system, be sure to put the more specific ones first:
  62. .. code-block:: none
  63. [libraries]
  64. linux.release.editor.x86_64 = "./bin/libgdexample.linux.template_release.x86_64.so"
  65. linux.release.x86_64 = "./bin/libgdexample.linux.noeditor.template_release.x86_64.so"
  66. Here are lists of some of the available built-in options (for more look at the :ref:`feature tags <doc_feature_tags>`):
  67. Running system
  68. ~~~~~~~~~~~~~~
  69. +-------------------------------+------------------------------------------------------------------------------------------------------+
  70. | Flag | Description |
  71. +===============================+======================================================================================================+
  72. | **windows** | Windows operating system |
  73. +-------------------------------+------------------------------------------------------------------------------------------------------+
  74. | **macos** | Mac operating system |
  75. +-------------------------------+------------------------------------------------------------------------------------------------------+
  76. | **linux** | Linux operating system |
  77. +-------------------------------+------------------------------------------------------------------------------------------------------+
  78. | **bsd** | BSD operating system |
  79. +-------------------------------+------------------------------------------------------------------------------------------------------+
  80. | **linuxbsd** | Linux or BSD operating system |
  81. +-------------------------------+------------------------------------------------------------------------------------------------------+
  82. | **android** | Android operating system |
  83. +-------------------------------+------------------------------------------------------------------------------------------------------+
  84. | **ios** | iOS operating system |
  85. +-------------------------------+------------------------------------------------------------------------------------------------------+
  86. | **web** | Web browser |
  87. +-------------------------------+------------------------------------------------------------------------------------------------------+
  88. Build
  89. ~~~~~
  90. +-------------------------------+------------------------------------------------------------------------------------------------------+
  91. | Flag | Description |
  92. +===============================+======================================================================================================+
  93. | **debug** | Build with debugging features (editor builds always have debugging features) |
  94. +-------------------------------+------------------------------------------------------------------------------------------------------+
  95. | **release** | Optimized build without debugging features |
  96. +-------------------------------+------------------------------------------------------------------------------------------------------+
  97. | **editor** | Editor build |
  98. +-------------------------------+------------------------------------------------------------------------------------------------------+
  99. Architecture
  100. ~~~~~~~~~~~~
  101. +-------------------------------+------------------------------------------------------------------------------------------------------+
  102. | Flag | Description |
  103. +===============================+======================================================================================================+
  104. | **double** | double-precision build |
  105. +-------------------------------+------------------------------------------------------------------------------------------------------+
  106. | **single** | single-precision build |
  107. +-------------------------------+------------------------------------------------------------------------------------------------------+
  108. | **x86_64** | 64-bit x86 build |
  109. +-------------------------------+------------------------------------------------------------------------------------------------------+
  110. | **arm64** | 64-bit ARM build |
  111. +-------------------------------+------------------------------------------------------------------------------------------------------+
  112. | **rv64** | 64-bit RISC-V build |
  113. +-------------------------------+------------------------------------------------------------------------------------------------------+
  114. | **riscv** | RISC-V build (any bitness) |
  115. +-------------------------------+------------------------------------------------------------------------------------------------------+
  116. | **wasm32** | 32-bit WebAssembly build |
  117. +-------------------------------+------------------------------------------------------------------------------------------------------+
  118. Icons section
  119. -------------
  120. By default, Godot uses the Node icon in the scene dock for GDExtension nodes.
  121. A custom icon can be set by reference to its name and resource path of an SVG file.
  122. For example:
  123. .. code-block:: none
  124. [icons]
  125. GDExample = "res://icons/gd_example.svg"
  126. The path should point to a 16×16 pixel SVG image, with two options enabled on the
  127. image in the Import dock:
  128. - **Editor > Scale with Editor Scale**.
  129. - **Editor > Convert Colors with Editor Theme**.
  130. Enabling both options ensures the icon behaves as closely as possible to
  131. the stock editor icons. Read the guide for :ref:`creating icons <doc_editor_icons>`
  132. for more information.
  133. Dependencies section
  134. --------------------
  135. In this section, you set the paths of the GDExtension dependencies. This is used internally to export the dependencies
  136. when exporting your game executable. You are able to set which dependency is loaded depending on the feature flags
  137. of the exported executable. In addition, you are able to set an optional subdirectory to move your dependencies into.
  138. If no path is supplied, Godot will move the libraries into the same directory as your game executable.
  139. .. warning::
  140. On macOS, it is necessary to have shared libraries inside a folder called ``Frameworks``
  141. with a directory structure like this: ``Game.app/Contents/Frameworks``.
  142. .. code-block:: none
  143. [dependencies]
  144. macos.debug = {
  145. "res://bin/libdependency.macos.template_debug.framework" : "Contents/Frameworks"
  146. }
  147. macos.release = {
  148. "res://bin/libdependency.macos.template_release.framework" : "Contents/Frameworks"
  149. }
  150. windows.debug = {
  151. "res://bin/libdependency.windows.template_debug.x86_64.dll" : "",
  152. "res://bin/libdependency.windows.template_debug.x86_32.dll" : ""
  153. }
  154. windows.release = {
  155. "res://bin/libdependency.windows.template_release.x86_64.dll" : "",
  156. "res://bin/libdependency.windows.template_release.x86_32.dll" : ""
  157. }
  158. linux.debug = {
  159. "res://bin/libdependency.linux.template_debug.x86_64.so" : "",
  160. "res://bin/libdependency.linux.template_debug.arm64.so" : "",
  161. "res://bin/libdependency.linux.template_debug.rv64.so" : ""
  162. }
  163. linux.release = {
  164. "res://bin/libdependency.linux.template_release.x86_64.so" : "",
  165. "res://bin/libdependency.linux.template_release.arm64.so" : "",
  166. "res://bin/libdependency.linux.template_release.rv64.so" : ""
  167. }