Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons: Refactor module defines into a generated header, cleanup #35963

Merged

Conversation

akien-mga
Copy link
Member

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, 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).

@akien-mga
Copy link
Member Author

While it compiles fine, it seems not to work as expected currently. Module-specific features seem disable in an editor build with all modules theoretically enabled. No GDScript support, no TLS support, no GridMap, etc.

@akien-mga akien-mga changed the title SCons: Refactor module defines into a generated header, cleanup [WIP] SCons: Refactor module defines into a generated header, cleanup Feb 7, 2020
@akien-mga
Copy link
Member Author

While it compiles fine, it seems not to work as expected currently. Module-specific features seem disable in an editor build with all modules theoretically enabled. No GDScript support, no TLS support, no GridMap, etc.

Ah lol, I found out why. I forgot that all modules are registered in register_module_types.gen.cpp and this is done checking for MODULE_*_ENABLED defines, so I need the include there. It might actually explain the other linking issue I had which forced me to make the hack in 0c6b7134e99.

We already had `MODULE_*_ENABLED` defines but only in the modules
environment, and a few custom `*_ENABLED` defines in the main env
when we needed the information in core.

Now this is defined in a single header which can be included in the
files that need this information.
- Fix build with gdscript module disabled. Fixes godotengine#31011.
- Remove unused `gdscript` compile option.
- Fix build with regex module disabled.
- Fix ImageLoaderSVG to forward declare thirdparty structs.
@akien-mga akien-mga changed the title [WIP] SCons: Refactor module defines into a generated header, cleanup SCons: Refactor module defines into a generated header, cleanup Feb 7, 2020
@akien-mga
Copy link
Member Author

Tested successfully with:

  • Linux, GCC 8.3.1
  • Windows, MSVC 2019
  • Windows, MinGW (recent version, didn't check which one I have)

@akien-mga akien-mga merged commit 7711e9f into godotengine:master Feb 7, 2020
@akien-mga akien-mga deleted the scons-modules-enabled-header branch February 7, 2020 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiling without GDScript fails
1 participant