MakovWait/godots

[idea] Build and use a minimal template on export

Opened this issue · 0 comments

Godot's default export templates come with a lot of features that are not needed in Godots, like the whole 3D engine, and can significantly decrease the manager's size if removed.

From my tests, I'm going to list a few options for building the template that are necessary:

Production settings (production=yes)

All Godot official builds use this by default. This enables some settings that are ideal for use in production like link time optimization.

Optimize for size (optimize=size)

This isn't a game that needs ultimate performance, therefore optimizing for size may not affect as much as optimizing for speed (Godot's default).

Disable 3D and deprecated features (disable_3d=yes deprecated=no)

It's mostly UI based, therefore no 3D is needed. Also almost nobody uses deprecated features, not even this project 😃.

Edit: disable Vulkan and OpenXR (vulkan=no openxr=no)

Vulkan isn't needed because the project uses the Compatibility renderer, which uses OpenGL3. OpenXR isn't used.

Linux only: disable some extra components (alsa=no pulseaudio=no fontconfig=no udev=no)

Godots plays no sounds, doesn't use system fonts and doesn't use gamepad. Those can be safely removed.

Modules

If we considering this begins with modules_enabled_by_default=no, here's how each module is necessary in Godots:

  • FreeType: Used to render fonts;
  • GDScript: Obvious;
  • mbedTLS: HTTP requests, exploring and downloading from asset library, remote editors, and new versions of Godots;
  • RegEx: Used to read version numbers;
  • Text Server Fallback: There will be no text if there's no text server. Use Text Server Advanced instead if you intend to localize Godots to other languages that aren't written in left-to right like Arabic;
  • ZIP/minizip: Needed to unpack downloads;
  • Image formats (JPG, WebP): Mainly for project icons (including asset library). I had no issues with SVG not built-in but maybe it's needed for projects without an SVG icon unimported. PNG support is core.

The build options would include the following after specifying the platform and target: production=yes optimize=size disable_3d=yes deprecated=no vulkan=no openxr=no modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_jpg_enabled=yes module_mbedtls_enabled=yes module_regex_enabled=yes module_text_server_fb_enabled=yes module_webp_enabled=yes module_zip_enabled=yes

Remember to put alsa=no pulseaudio=no fontconfig=no udev=no if it's a Linux build

Exporting Godots with a template built with that, I got Linux a binary with 36.7 MiB compared to the usual 72 MiB. Edit: by also removing Vulkan, OpenXR and others, I managed to reduce the exported binary to 33.8 MiB.