Skip to content

SCons: Refactor module defines into a generated header, cleanup

Created by: akien-mga

This supersedes #32453, which aimed at having all MODULE_*_ENABLED defines in a header to be able to do proper checks that modules are enabled before using them in other folders (especially in RichTextLabel which uses RegEx).

It also supersedes #32781 and fixes #31011 (closed), allowing to compile with GDScript disabled again.

Those two could have been solved with less work via more custom defines, but the new approach was discussed as cleaner and overall more resilient with @punto- and @Faless. Having all the defines in a header allow us to only include this header where needed instead of passing hacks like SVG_ENABLED and FREETYPE_ENABLED to the main environment.

In the process of fixing this, we found that the removal of env_modules.Append(CPPDEFINES=["MODULE_" + x.upper() + "_ENABLED"]) actually triggers linking order issues. I'm not sure why these defines prevented the issue, but after debugging with @Faless we found that the best is likely to ensure that libmodules.a comes last on the linker command.

There was then still one issue with script_encryption_key which is defined in a .gen.cpp in core, and was thus part of libcore.a, triggering another linking issue. I made it a .gen.h to solve it -- was there any reason for it to be a .cpp and not a .h in the first place?

In a follow-up PR, I might add a few changes to split libmodules.a into multiple libmodule_$name.a, which should also remove the need for the split_libmodules hack on Windows (#34227).

Merge request reports

Loading