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

added Scons modules #define generator #32453

Closed
wants to merge 1 commit into from
Closed

added Scons modules #define generator #32453

wants to merge 1 commit into from

Conversation

jeronimo-schreyer
Copy link
Contributor

No description provided.

@jeronimo-schreyer
Copy link
Contributor Author

Generated file describes what modules are available

@akien-mga
Copy link
Member

There's already code to define MODULE_*_ENABLED right next to where you generate this header, the only difference is that it's passed only to env_modules, and not to the main env. So modules can know which other modules are enabled, but scene/ or editor/ code doesn't.

The main reason for that is that passing all MODULE_*_ENABLED defines to the command line would likely double the length of an already quite long compiler call. Generate a header with those defines can indeed be an alternative, but if we go this route, there's no reason to keep passing the defines to env_modules.

There's also SVG_ENABLED and FREETYPE_ENABLED defines passed to the main env in their respective module, which should also be ported to MODULE_*_ENABLED via a generated header if we go this route.

All in all this is more something for thorough proposal on how to refactor the way module dependencies are handled. Your PR lacks description so it's not clear what you want to achieve, but if the aim is just to allow disabling regex support, a simpler fix would be to define append REGEX_ENABLED to the env as done for SVG and FREETYPE, and we can further discuss how to refactor all this for 4.0.

@@ -29,6 +29,7 @@
/*************************************************************************/

#include "rich_text_label.h"
#include "../../modules/modules_enabled.gen.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be below together with other includes. It should also start from the root, we don't use relative paths.
modules/regex/regex.h should not be included if the module is disabled.

@Xrayez
Copy link
Contributor

Xrayez commented Oct 1, 2019

The main reason for that is that passing all MODULE_*_ENABLED defines to the command line would likely double the length of an already quite long compiler call.

I wanted to do this while attempting to not compile Bullet-related code if the module is disabled. In fact I've successfully done this, except I realized that there's quite a bunch of places already to wrap with MODULE_BULLET_ENABLED. The idea has originated from #32216.

There's also SVG_ENABLED and FREETYPE_ENABLED defines passed to the main env in their respective module, which should also be ported to MODULE_*_ENABLED via a generated header if we go this route.

Also GDSCRIPT_ENABLED.

I think this needs godot-proposal again. 🤔

@punto-
Copy link
Contributor

punto- commented Oct 3, 2019

I like this as an alternative to passing MODULE_*_ENABLED (but just to be clear @jeronimo-schreyer works for me). I never really liked adding those defines outside of modules/ and in reality almost none of the modules use them, except that ones that use other modules, like ogg and vorbis, and it makes sense for code outside modules/ to sometimes need to know if a module is there. This header would allow anyone to know about the modules, without having to pollute the compile command (and causing a full rebuild when one module is enabled/disabled). This doesn't remove the defines from the command line to keep compatibility, it's just to address the issue of regexp used in the RichTextLabel (regexp can't be used in consoles because it has a jit)

modules/SCsub Outdated Show resolved Hide resolved
modules/SCsub Outdated
for x in env.module_list:
if (x in env.disabled_modules):
continue
env_modules.Append(CPPDEFINES=["MODULE_" + x.upper() + "_ENABLED"])
SConscript(x + "/SCsub")

env.Command("modules_enabled.gen.h", [], generate_modules_enabled)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use CommandNoCache so that it doesn't get cached on CI, but re-generated each time.

The method should also be called with run_in_subprocess to avoid build issues on Windows. See #17595 for context and core/SCsub, main/SCsub and editor/SCsub for examples of how it's done for existing .gen.h files.

@akien-mga
Copy link
Member

This doesn't remove the defines from the command line to keep compatibility, it's just to address the issue of regexp used in the RichTextLabel (regexp can't be used in consoles because it has a jit)

IMO this change is fine, but then the old style should be removed, we don't need to keep both. It only breaks compatibility for thirdparty modules that would happen to reuse our own env_modules, as it's the only one which is aware of MODULE_*_ENABLED macros so far, and then only those modules who actively use features provided by modules and thought about adding checks. So all in all it's probably a relatively safe change.

@akien-mga
Copy link
Member

Apart from above comments, I'd like to see this changed:

  • Remove no longer necessary CPPDEFINES for MODULE_*_ENABLED, and fix their few uses by including modules/modules_enabled.gen.h.
  • Remove SVG_ENABLED, FREETYPE_ENABLED and GDSCRIPT_ENABLED from their respective SCsub, and replace their uses by the equivalent MODULE_*_ENABLED and header (GDSCRIPT_ENABLED is actually defined in SConstruct and only used in main/tests/test_gdscript.cpp, that's bogus. You can remove the "gdscript" build option that controls it).

@akien-mga
Copy link
Member

There's one potential issue with this approach though, which is that any time a module is enabled or disabled, the header will change and this will force recompilation of all the files that include it. This could be particularly problematic if we also remove the hardcoded MINIZIP_ENABLED and include modules/modules_enabled.gen.h in core/.

So we may need to tread cautiously here as our incremental builds are already a bit on the edge.

@jeronimo-schreyer
Copy link
Contributor Author

I squashed previous commits into one

@akien-mga
Copy link
Member

Superseded by #35963. Thanks for the contribution nevertheless, which was used as basis for that bigger PR.

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.

None yet

5 participants