-
-
Notifications
You must be signed in to change notification settings - Fork 24.2k
GDExtension: Add mechanism to get which classes an extension is using #104129
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
GDExtension: Add mechanism to get which classes an extension is using #104129
Conversation
03334ff to
f5d8724
Compare
Could you elaboratate what "used" means here, and maybe also mention in the C API documentation?
I looked briefly at the godot-cpp implementation, but I'm not familiar with
Yes, the "editor" part seems a bit off to me, as well 😉 without that, I think the name sounds good! |
|
@Bromeon This is going be used for the Compilation Configuration Profile editor to generate build profiles. Those can dictate classes to be disabled, and it scans the project to see what classes are unused. |
As needed. But most frequently, not at all :-) The one use case we have for this right now is in the editor, in "Tools" -> "Engine Compilation Configuration Editor..." when the user clicks "Detect from Project". This would allow that feature to loop over the GDExtensions that are loaded, see which classes are used, and make sure those are enabled on the profile it generates.
Not dynamically, this would be any class that the GDExtension may use. The idea is that any classes that aren't used by anything can be compiled out of a custom engine build for that specific project. If there's even the possibility that the class may be used, then it should be included on the list of used classes. In godot-cpp, we do a trick where we try to get the linker to remove any unused classes, but it's not very good and always over-estimates which classes are used. But the developer can also provide a
I mean classes in I'll attempt to update the docs in
Yeah, it would certainly sound better if "editor" was dropped, and it's such a small thing, it wouldn't hurt to have it available always. But only the editor will ever call the callback, and it seems weird not to recognize that somehow. I guess I could just put that in the description rather than the name. |
Ah, I just saw that the surrounding functions also have the Thanks for elaborating the use case! Also, do you have a link for |
Not that I know about. It was never fully finished - that's what YelhamDev is working on
Here's two examples from real projects: |
YeldhamDev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on my end, and everything works. Will add the tie-in code to #103719 once this is merged.
f5d8724 to
5758ce4
Compare
|
@Bromeon I updated the docs in |
|
Thanks! The following parts are still not in the doc, I think they're important to mention (in condensed form) though?
TLDR:
|
5758ce4 to
02acd4c
Compare
Bromeon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typo, otherwise looks good! I'll approve already 🙂
02acd4c to
2dff9fe
Compare
|
Thanks! |
This adds a GDExtension interface function, that allows a GDExtension to register a callback, that can be called by the Godot editor to determine which classes it's using.
I created this to help @YeldhamDev with the work he's doing to allow recompiling Godot with only the classes used by a particular project.
It worked for me in a quick test!
I'd appreciate feedback on the name of the new function:
editor_register_get_used_classes_callbackIt ends up with quite a few prefixes and suffixes in there. :-) I put "editor" since the only use I can think of for this is in the editor, but it wouldn't really be a problem to allow this always?
PR godotengine/godot-cpp#1743 implements this for godot-cpp