Skip to content

Commit d3f25b9

Browse files
authored
Merge pull request #11762 from Calinou/creating-applications-single-exe-portable
Document creating single-executable/portable apps in Creating applications
2 parents 0415192 + c4d52be commit d3f25b9

2 files changed

Lines changed: 60 additions & 12 deletions

File tree

tutorials/export/exporting_for_windows.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ The default is x86_64, this is the most common architecture of PC processors
3232
today. All modern Intel and AMD processors as of writing this are x86_64.
3333

3434
x86_32 will give you a 32bit executable that can run on 32bit-only versions of
35-
Windows as well as modern versions which are 64bit. It is NOT recommended to use
35+
Windows as well as modern versions which are 64bit. It is **not** recommended to use
3636
this option unless you are trying to get your project to run on an old 32bit version
3737
of Windows. And it should be noted that no 32bit versions of Windows receive
3838
Microsoft support anymore.
3939

4040
arm64 processors are modern but less common than x86_64, and run Windows on ARM.
4141
Snapdragon X Elite is an example of a modern Windows ARM processor. Using this
4242
export option will allow your project to run natively on arm processors without
43-
Microsoft's Prism emulator. Executables made using this option will NOT run on
43+
Microsoft's Prism emulator. Executables made using this option will **not** run on
4444
regular Windows with an x86_64 processor. If you're uploading your project to a
4545
platform that allows multiple executables, such as itch.io, and are confident a
4646
Snapdragon X Elite processor is powerful enough to run it, we would recommend
@@ -55,6 +55,14 @@ settings, and convert it to an ICO file for the exported project. If you want to
5555
manually create an ICO file for greater control over how the icon looks at different
5656
resolutions then see the :ref:`doc_changing_application_icon_for_windows` page.
5757

58+
PCK embedding
59+
-------------
60+
61+
PCK embedding is only supported on executables up to ~3.89 GB in size. This
62+
metric includes both the executable and embedded PCK size, so in practice,
63+
the PCK file may only weigh up to ~3.75 GB. This can also vary depending on
64+
build options when using a custom export template.
65+
5866
.. _doc_exporting_for_windows_code_signing:
5967

6068
Code signing
@@ -65,16 +73,6 @@ Godot is capable of automatic code signing on export. To do this you must have t
6573
(on any other OS) installed. You will also need a package signing certificate,
6674
information on creating one can be found `here <https://learn.microsoft.com/en-us/windows/msix/package/create-certificate-package-signing>`__.
6775

68-
.. warning::
69-
70-
If you export for Windows with embedded PCK files, you will not be able to
71-
sign the program as it will break.
72-
73-
On Windows, PCK embedding is also known to cause false positives in
74-
antivirus programs. Therefore, it's recommended to avoid using it unless
75-
you're distributing your project via Steam as it bypasses code signing and
76-
antivirus checks.
77-
7876
Setup
7977
~~~~~
8078

tutorials/ui/creating_applications.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,56 @@ The size reduction is often significant (relative to the project's size),
796796
since applications contain fewer large assets compared to games.
797797
See :ref:`doc_optimizing_for_size` for more information on how to do this.
798798

799+
Creating a single-executable distribution
800+
-----------------------------------------
801+
802+
By default, Godot creates a PCK file containing the project data next to the
803+
executable. This means that if the executable is moved without moving the PCK
804+
file at the same time, the application will not run. This is not ideal for
805+
applications, which are increasingly being distributed as a single executable
806+
file.
807+
808+
To make the application entirely self-contained to a single executable, you can
809+
enable **Embed PCK** in the export preset options. This will embed the PCK data
810+
within the executable, so that the application can be moved around without
811+
breaking. This also makes it possible to run the application directly from a ZIP
812+
archive without having to extract it first.
813+
814+
.. note::
815+
816+
PCK embedding has a size limitation depending on the platform. Very large
817+
applications (several GBs) may not be able to use this feature on all platforms.
818+
Check the export documentation for the target platform for more details.
819+
820+
Creating portable applications
821+
------------------------------
822+
823+
An application is called *portable* when it can be run without installation, and
824+
when its configuration is entirely self-contained to the folder it was extracted
825+
to. This allows placing the application files on an USB drive or similar, and
826+
running it on different machines without having to go through an installation
827+
process.
828+
829+
The Godot editor's own :ref:`self-contained mode <doc_data_paths_self_contained_mode>`
830+
currently can't be used within projects. However, you can still choose to save
831+
your own configuration files to the folder containing the executable as follows:
832+
833+
::
834+
835+
var config_path = OS.get_executable_path().get_base_dir().path_join("config.ini")
836+
# Then use `config_path` to save/load configuration files using ConfigFile or similar.
837+
838+
You may want to make portable mode optional as it's not always desired.
839+
Typically, this is performed by detecting the presence of a specific file in the
840+
executable's folder (e.g. a file named ``portable.txt``), and only using the
841+
executable's folder for configuration if that file is present.
842+
843+
.. warning::
844+
845+
Remember that this will only work if the application is extracted to a
846+
writable location. This will result in permission errors if the executable
847+
is run from a read-only location, such as ``C:\Program Files`` on Windows.
848+
799849
Creating installers
800850
-------------------
801851

0 commit comments

Comments
 (0)