macosgame-engineexecutablegodotbinaries

How can Godot add Code to Export Templates


One feature that I find impressive about the Godot Engine is how it is so lightweight and quick to compile. I realize that Godot exports using its precompiled export templates but I am confused about how it does so. I am working on macOS so that's mostly what I'm curious about. How is Godot able to add code to a precompiled executable. I've spent hours looking through the source code but can't figure it out.


Solution

  • Godot's export templates are compiled binaries that use a specific set of SCons options. They're always built using tools=no which disables editor functionality, and official export templates use either target=release_debug or target=release optimizations (for debug and release export templates respectively).

    Note that Godot doesn't compile native code when exporting a project -- it just bundles data, scripts and the export template together. Game data and scripts are packed into a PCK file, which is a custom archive format that can store arbitrary files (without compression). The export template then runs the main script contained in the PCK file.

    Scripts are compiled to bytecode when exporting a project in release mode, which speeds up loading times but otherwise doesn't affect the script execution speed.

    See this page on compiling binaries for macOS.