2
0

gdextension_file.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. [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. Entries are matched in order, so if two sets of feature tags could match
  57. the same system, be sure to put the more specific ones first:
  58. .. code-block:: none
  59. [libraries]
  60. linux.release.editor.x86_64 = "res://bin/libgdexample.linux.template_release.x86_64.so"
  61. linux.release.x86_64 = "res://bin/libgdexample.linux.noeditor.template_release.x86_64.so"
  62. Here are lists of some of the available built-in options (for more look at the :ref:`feature tags <doc_feature_tags>`):
  63. Running system
  64. ~~~~~~~~~~~~~~
  65. +-------------------------------+------------------------------------------------------------------------------------------------------+
  66. | Flag | Description |
  67. +===============================+======================================================================================================+
  68. | **windows** | Windows operating system |
  69. +-------------------------------+------------------------------------------------------------------------------------------------------+
  70. | **macos** | Mac operating system |
  71. +-------------------------------+------------------------------------------------------------------------------------------------------+
  72. | **linux** | Linux operating system |
  73. +-------------------------------+------------------------------------------------------------------------------------------------------+
  74. | **bsd** | BSD operating system |
  75. +-------------------------------+------------------------------------------------------------------------------------------------------+
  76. | **linuxbsd** | Linux or BSD operating system |
  77. +-------------------------------+------------------------------------------------------------------------------------------------------+
  78. | **android** | Android operating system |
  79. +-------------------------------+------------------------------------------------------------------------------------------------------+
  80. | **ios** | iOS operating system |
  81. +-------------------------------+------------------------------------------------------------------------------------------------------+
  82. | **web** | Web browser |
  83. +-------------------------------+------------------------------------------------------------------------------------------------------+
  84. Build
  85. ~~~~~
  86. +-------------------------------+------------------------------------------------------------------------------------------------------+
  87. | Flag | Description |
  88. +===============================+======================================================================================================+
  89. | **debug** | Build with debug symbols |
  90. +-------------------------------+------------------------------------------------------------------------------------------------------+
  91. | **release** | Optimized build without debug symbols |
  92. +-------------------------------+------------------------------------------------------------------------------------------------------+
  93. | **editor** | Editor build |
  94. +-------------------------------+------------------------------------------------------------------------------------------------------+
  95. Architecture
  96. ~~~~~~~~~~~~
  97. +-------------------------------+------------------------------------------------------------------------------------------------------+
  98. | Flag | Description |
  99. +===============================+======================================================================================================+
  100. | **double** | double-precision build |
  101. +-------------------------------+------------------------------------------------------------------------------------------------------+
  102. | **single** | single-precision build |
  103. +-------------------------------+------------------------------------------------------------------------------------------------------+
  104. | **x86_64** | 64-bit x86 build |
  105. +-------------------------------+------------------------------------------------------------------------------------------------------+
  106. | **arm64** | 64-bit ARM build |
  107. +-------------------------------+------------------------------------------------------------------------------------------------------+
  108. | **rv64** | 64-bit RISC-V build |
  109. +-------------------------------+------------------------------------------------------------------------------------------------------+
  110. | **riscv** | RISC-V build (any bitness) |
  111. +-------------------------------+------------------------------------------------------------------------------------------------------+
  112. | **wasm32** | 32-bit WebAssembly build |
  113. +-------------------------------+------------------------------------------------------------------------------------------------------+
  114. Icons section
  115. -------------
  116. By default, Godot uses the Node icon in the scene dock for GDExtension nodes. A custom icon can be
  117. set by reference to its name and resource path of an SVG file.
  118. For example:
  119. .. code-block:: none
  120. [icons]
  121. GDExample = "res://icons/gd_example.svg"
  122. The path should point to a 16 by 16 pixel SVG image. Read the guide for :ref:`creating icons <doc_editor_icons>`
  123. for more information.
  124. Dependencies section
  125. --------------------
  126. In this section you set the paths of the GDExtension dependencies. This is used internally to export the dependencies
  127. when exporting your game executable. You are able to set which dependency is loaded depending on the feature flags
  128. of the exported executable. In addition, you are able to set an optional subdirectory to move your dependencies into.
  129. If no path is supplied Godot will move the libraries into the same directory as your game executable.
  130. .. warning::
  131. In MacOS it is necessary to have shared libraries inside a folder called ``Frameworks`` with a directory structure
  132. like this: ``Game.app/Contents/Frameworks``.
  133. .. code-block:: none
  134. [dependencies]
  135. macos.debug = {
  136. "res://bin/libdependency.macos.template_debug.framework" : "Contents/Frameworks"
  137. }
  138. macos.release = {
  139. "res://bin/libdependency.macos.template_release.framework" : "Contents/Frameworks"
  140. }
  141. windows.debug = {
  142. "res://bin/libdependency.windows.template_debug.x86_64.dll" : "",
  143. "res://bin/libdependency.windows.template_debug.x86_32.dll" : ""
  144. }
  145. windows.release = {
  146. "res://bin/libdependency.windows.template_release.x86_64.dll" : "",
  147. "res://bin/libdependency.windows.template_release.x86_32.dll" : ""
  148. }
  149. linux.debug = {
  150. "res://bin/libdependency.linux.template_debug.x86_64.so" : "",
  151. "res://bin/libdependency.linux.template_debug.arm64.so" : "",
  152. "res://bin/libdependency.linux.template_debug.rv64.so" : ""
  153. }
  154. linux.release = {
  155. "res://bin/libdependency.linux.template_release.x86_64.so" : "",
  156. "res://bin/libdependency.linux.template_release.arm64.so" : "",
  157. "res://bin/libdependency.linux.template_release.rv64.so" : ""
  158. }