exporting_projects.rst 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. :article_outdated: True
  2. .. _doc_exporting_projects:
  3. Exporting projects
  4. ==================
  5. .. highlight:: none
  6. Why export?
  7. -----------
  8. Originally, Godot did not have any means to export projects. The
  9. developers would compile the proper binaries and build the packages for
  10. each platform manually.
  11. When more developers (and even non-programmers) started using it, and
  12. when our company started taking more projects at the same time, it
  13. became evident that this was a bottleneck.
  14. On PC
  15. ~~~~~
  16. Distributing a game project on PC with Godot is rather easy. Drop
  17. the Godot binary in the same directory as the ``project.godot`` file,
  18. then compress the project directory and you are done.
  19. It sounds simple, but there are probably a few reasons why the developer
  20. may not want to do this. The first one is that it may not be desirable
  21. to distribute loads of files. Some developers may not like curious users
  22. peeking at how the game was made, others may find it inelegant, and so on.
  23. Another reason is that the developer might prefer a specially-compiled
  24. binary, which is smaller in size, more optimized and does not include
  25. tools like the editor and debugger.
  26. Finally, Godot has a simple but efficient system for
  27. :ref:`creating DLCs as extra package files <doc_exporting_pcks>`.
  28. On mobile
  29. ~~~~~~~~~
  30. The same scenario on mobile platforms is a little worse.
  31. To distribute a project on those devices, a binary for each of
  32. those platforms is built, then added to a native project together
  33. with the game data.
  34. This can be troublesome because it means that the developer must be
  35. familiarized with the SDK of each platform before even being able to
  36. export. While learning each SDK is always encouraged, it can be
  37. frustrating to be forced to do it at an undesired time.
  38. There is also another problem with this approach: different devices
  39. prefer some data in different formats to run. The main example of this
  40. is texture compression. All PC hardware uses S3TC (BC) compression and
  41. that has been standardized for more than a decade, but mobile devices
  42. use different formats for texture compression, such as ETC1 and ETC2.
  43. Export menu
  44. -----------
  45. After many attempts at different export workflows, the current one has
  46. proven to work the best. At the time of this writing, not all platforms are
  47. supported yet, but the supported platforms continue to grow.
  48. To open the export menu, click the **Export** button:
  49. .. image:: img/export.png
  50. The export menu will open. However, it will be completely empty.
  51. This is because we need to add an export preset.
  52. .. image:: img/export_dialog.png
  53. To create an export preset, click the **Add…** button at the top
  54. of the export menu. This will open a drop-down list of platforms
  55. to choose from for an export preset.
  56. .. image:: img/export_preset.png
  57. The default options are often enough to export, so tweaking them is
  58. usually not necessary. However, many platforms require additional
  59. tools (SDKs) to be installed to be able to export. Additionally, Godot
  60. needs export templates installed to create packages. The export menu
  61. will complain when something is missing and will not allow the user to
  62. export for that platform until they resolve it:
  63. .. image:: img/export_error.png
  64. At that time, the user is expected to come back to the documentation and follow
  65. instructions on how to properly set up that platform.
  66. The buttons at the bottom of the menu allow you to export the project in a few
  67. different ways:
  68. - Export All: Export the project as a playable build (Godot executable and project data)
  69. for all the presets defined. All presets must have an **Export Path** defined for this
  70. to work.
  71. - Export Project: Export the project as a playable build
  72. (Godot executable and project data) for the selected preset.
  73. - Export PCK/ZIP: Export the project resources as a PCK or ZIP package.
  74. This is not a playable build, it only exports the project data without a Godot executable.
  75. Export templates
  76. ~~~~~~~~~~~~~~~~
  77. Apart from setting up the platform, the export templates must be
  78. installed to be able to export projects. They can be obtained as a
  79. TPZ file (which is a renamed ZIP archive) from the
  80. `download page of the website <https://www.godotengine.org/download>`_.
  81. Once downloaded, they can be installed using the **Install Export Templates**
  82. option in the editor:
  83. .. image:: img/exptemp.png
  84. .. _doc_exporting_projects_export_mode:
  85. Resource options
  86. ~~~~~~~~~~~~~~~~
  87. When exporting, Godot makes a list of all the files to export and then
  88. creates the package. There are 3 different modes for exporting:
  89. - Export all resources in the project
  90. - Export selected scenes (and dependencies)
  91. - Export selected resources (and dependencies)
  92. .. image:: img/expres.png
  93. **Export all resources in the project** will export every resource in the
  94. project. **Export selected scenes** and **Export selected resources** gives
  95. you a list of the scenes or resources in the project, and you have to
  96. select every scene or resource you want to export.
  97. .. image:: img/expselected.png
  98. .. note::
  99. Files and folders whose name begin with a period will never be included in
  100. the exported project. This is done to prevent version control folders like
  101. ``.git`` from being included in the exported PCK file.
  102. Below the list of resources are two filters that can be setup. The first allows
  103. non-resource files such as ``.txt``, ``.json`` and ``.csv`` to be exported with
  104. the project. The second filter can be used to exclude every file of a certain
  105. type without manually deselecting every one. For example, ``.png`` files.
  106. Configuration files
  107. -------------------
  108. The export configuration is stored in two files that can both be found in the project
  109. directory:
  110. - ``export_presets.cfg``: This file contains the vast majority of the export
  111. configuration and can be safely committed to version control. There is nothing
  112. in here that you would normally have to keep secret.
  113. - ``.godot/export_credentials.cfg``: This file contains export options that are
  114. considered confidential, like passwords and encryption keys. It should generally
  115. **not** be committed to version control or shared with others unless you know
  116. exactly what you are doing.
  117. Since the credentials file is usually kept out of version control systems, some
  118. export options will be missing if you clone the project to a new machine. The easiest
  119. way to deal with this is to copy the file manually from the old location to the new one.
  120. Exporting from the command line
  121. -------------------------------
  122. In production, it is useful to automate builds, and Godot supports this
  123. with the ``--export-release`` and ``--export-debug`` command line parameters.
  124. Exporting from the command line still requires an export preset to define
  125. the export parameters. A basic invocation of the command would be:
  126. .. code-block:: shell
  127. godot --export-release "Windows Desktop" some_name.exe
  128. This will export to ``some_name.exe``, assuming there is a preset
  129. called "Windows Desktop" and the template can be found. (The export preset name
  130. must be written within quotes if it contains spaces or special characters.)
  131. The output path is *relative to the project path* or *absolute*;
  132. **it does not respect the directory the command was invoked from**.
  133. The output file extension should match the one used by the Godot export process:
  134. - Windows: ``.exe``
  135. - macOS: ``.zip`` (from all platforms) or ``.dmg`` (only when exporting *from* macOS).
  136. ``.app`` is not supported directly, although the generated ZIP archive contains an ``.app`` bundle.
  137. - Linux: Any extension (including none). ``.x86_64`` is typically used for 64-bit x86 binaries.
  138. - HTML5: ``.zip``
  139. - Android: ``.apk``
  140. - iOS: ``.zip``
  141. You can also configure it to export *only* the PCK or ZIP file, allowing
  142. a single exported main pack file to be used with multiple Godot executables.
  143. When doing so, the export preset name must still be specified on the command line:
  144. .. code-block:: shell
  145. godot --export-pack "Windows Desktop" some_name.pck
  146. It is often useful to combine the ``--export-release`` flag with the ``--path``
  147. flag, so that you do not need to ``cd`` to the project folder before running
  148. the command:
  149. .. code-block:: shell
  150. godot --path /path/to/project --export-release "Windows Desktop" some_name.exe
  151. .. seealso::
  152. See :ref:`doc_command_line_tutorial` for more information about using Godot
  153. from the command line.
  154. PCK versus ZIP pack file formats
  155. --------------------------------
  156. Each format has its upsides and downsides. PCK is the default and recommended
  157. format for most use cases, but you may want to use a ZIP archive instead
  158. depending on your needs.
  159. **PCK format:**
  160. - Uncompressed format. Larger file size, but faster to read/write.
  161. - Not readable and writable using tools normally present on the user's
  162. operating system, even though there are
  163. `third-party tools <https://github.com/hhyyrylainen/GodotPckTool>`__
  164. to extract and create PCK files.
  165. **ZIP format:**
  166. - Compressed format. Smaller file size, but slower to read/write.
  167. - Readable and writable using tools normally present on the user's operating system.
  168. This can be useful to make modding easier (see also :ref:`doc_exporting_pcks`).
  169. .. warning::
  170. Due to a `known bug <https://github.com/godotengine/godot/pull/42123>`__,
  171. when using a ZIP file as a pack file, the exported binary will not try to use
  172. it automatically. Therefore, you have to create a *launcher script* that
  173. the player can double-click or run from a terminal to launch the project::
  174. :: launch.bat (Windows)
  175. @echo off
  176. my_project.exe --main-pack my_project.zip
  177. # launch.sh (Linux)
  178. ./my_project.x86_64 --main-pack my_project.zip
  179. Save the launcher script and place it in the same folder as the exported binary.
  180. On Linux, make sure to give executable permissions to the launcher script using
  181. the command ``chmod +x launch.sh``.