MakovWait / godots

🚀Ultimate go-to hub for managing your Godot versions and projects! 🚀
MIT License
350 stars 29 forks source link

[idea] Build and use a minimal template on export #50

Open DeeJayLSP opened 12 months ago

DeeJayLSP commented 12 months ago

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:

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.