exporting_projects.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. .. _doc_exporting_projects:
  2. Exporting projects
  3. ==================
  4. .. highlight:: none
  5. Why export?
  6. -----------
  7. Originally, Godot did not have any means to export projects. The
  8. developers would compile the proper binaries and build the packages for
  9. each platform manually.
  10. When more developers (and even non-programmers) started using it, and
  11. when our company started taking more projects at the same time, it
  12. became evident that this was a bottleneck.
  13. On PC
  14. ~~~~~
  15. Distributing a game project on PC with Godot is rather easy. Drop
  16. the Godot binary in the same directory as the ``project.godot`` file,
  17. then compress the project directory and you are done.
  18. It sounds simple, but there are probably a few reasons why the developer
  19. may not want to do this. The first one is that it may not be desirable
  20. to distribute loads of files. Some developers may not like curious users
  21. peeking at how the game was made, others may find it inelegant, and so on.
  22. Another reason is that the developer might prefer a specially-compiled
  23. binary, which is smaller in size, more optimized and does not include
  24. tools like the editor and debugger.
  25. Finally, Godot has a simple but efficient system for creating DLCs as
  26. extra package files.
  27. On mobile
  28. ~~~~~~~~~
  29. The same scenario on mobile platforms is a little worse.
  30. To distribute a project on those devices, a binary for each of
  31. those platforms is built, then added to a native project together
  32. with the game data.
  33. This can be troublesome because it means that the developer must be
  34. familiarized with the SDK of each platform before even being able to
  35. export. While learning each SDK is always encouraged, it can be
  36. frustrating to be forced to do it at an undesired time.
  37. There is also another problem with this approach: different devices
  38. prefer some data in different formats to run. The main example of this
  39. is texture compression. All PC hardware uses S3TC (BC) compression and
  40. that has been standardized for more than a decade, but mobile devices
  41. use different formats for texture compression, such as PVRTC (iOS) or
  42. ETC (Android).
  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. Export templates
  67. ~~~~~~~~~~~~~~~~
  68. Apart from setting up the platform, the export templates must be
  69. installed to be able to export projects. They can be obtained as a
  70. TPZ file (which is a renamed ZIP archive) from the
  71. `download page of the website <https://www.godotengine.org/download>`_.
  72. Once downloaded, they can be installed using the **Install Export Templates**
  73. option in the editor:
  74. .. image:: img/exptemp.png
  75. Export mode
  76. ~~~~~~~~~~~
  77. When exporting, Godot makes a list of all the files to export and then
  78. creates the package. There are 3 different modes for exporting:
  79. - Export every single file in the project
  80. - Export only resources (+ custom filter), this is the default.
  81. - Export only selected resources (+ custom filter)
  82. .. image:: img/expres.png
  83. - **Export every single file** - This mode exports every single file in
  84. the project. This is good to test if something is being forgotten,
  85. but developers often have a lot of unrelated stuff around in the project
  86. directory, which makes it a bad idea.
  87. - **Export only resources** - Only resources are exported. For most
  88. projects, this is enough. However many developers like to use custom
  89. datafiles in their games. To compensate for this, filters can be
  90. added for extra extensions (for instance, ``*.txt,*.csv``).
  91. - **Export only selected resources** - Only select resources from a
  92. list are exported. This is probably overkill for most projects, but
  93. in some cases it is justified (usually huge projects). This mode
  94. offers total control of what is exported. Individual resources can be
  95. selected and dependency detection is performed to ensure that
  96. everything needed is added.
  97. .. image:: img/expselected.png
  98. Exporting from the command line
  99. -------------------------------
  100. In production, it is useful to automate builds, and Godot supports this
  101. with the ``--export`` and ``--export-debug`` command line parameters.
  102. Exporting from the command line still requires an export preset to define
  103. the export parameters. A basic invocation of the command would be:
  104. ::
  105. godot --export "Windows Desktop" some_name
  106. This will export to ``some_name.exe``, assuming there is a preset
  107. called "Windows Desktop" and the template can be found.
  108. The output path is relative to the project path or absolute;
  109. it does not respect the directory the command was invoked from.
  110. You can also configure it to export only the PCK or ZIP file (allowing
  111. a single export to be used with multiple Godot executables). This
  112. takes place if:
  113. - the export preset is not marked as runnable,
  114. - the target name ends with ``.pck`` or ``.zip``.
  115. It is often useful to combine the ``--export`` flag with the ``--path``
  116. flag, and to create a dedicated export preset for automated export:
  117. ::
  118. godot --path path/to/project --export "pck" game_name.pck