-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Add custom_modules
build option to compile external, user-defined C++ modules
#36922
Conversation
Managed to resolve remaining issues with collecting and generating custom documentation for external modules. I had to modify the doctool to distinguish between relative and absolute paths respectively. Similarly fixed modules editor icons collection by editor icon builder. All-in-all, this makes it work exactly like built-in modules, making this PR feature-complete IMO. 🤞 🤞 |
This version is much better then the one that I did. Really good Job! |
The flag I'm looking at the other examples like |
--module(s)_path? (We can drop the s to shorten it even further?) |
There is only one path to a folder of modules. So |
Multiple modules can be detected at provided path, so the option should suggest that, else it may lead to confusion that only a single module can be linked, which is not the case here.
See above. If the option supported multiple paths, the name would be Some more suggestions:
We could go further and introduce either Especially if the option could support multiple search paths. You could combine several module packages residing at different locations, but that's too much to ask I guess. |
modules_search_path
build option to compile external C++ modulescustom_modules
build option to compile external C++ modules
Renamed
I've also added an explicit check to prevent passing a path to a single module (parent directory should be used instead in that case). |
I've took some time to test this further. Fixed an issue with path includes. Namely when you include modules as dependencies of other modules: #ifndef YOUR_MODULE_H
#define YOUR_MODULE_H
#include "modules/my_module/my_class.h"
// ... Now, |
To test this with existing project, I've had to port this PR to 3.2, so to whoever want to test this against 3.2, here's the commit: https://github.com/Xrayez/godot/commit/e237bf51f58e388a639e821927058ce1cabce93d. Also providing a raw link to 3.2 patch, and some commands: Linux (not tested)
Windows
|
Here's an astonishing way to test this PR:
Compilation successful. Classes, editor icons and documentation are still there! Notice absolute paths when compiling modules, that's the way |
Added ability to specify multiple search paths for custom modules, not much changes internally.
Notice that paths must be separated either by That way, you can define your C++ packages as a collection of modules, so to speak. I haven't added support for checking Unix:
Windows:
Also added a note that custom modules can override built-in ones at build-time. For instance, it's perfectly possible to maintain your own |
custom_modules
build option to compile external C++ modulescustom_modules
build option to compile external, user-defined C++ modules
@Xrayez I'm using this PR for some time now and it works really well. With this I'm not anymore constrained to have a specific godot repository per each proejct. Indeed, I just need to update my main godot source code once to be able to use it with all projects. Also, the various compilations takes much much less time since the 90% of the code is already compiled. But the most important thing is that now it's really simple handles the shared modules and I don't need anymore perform cherry-picks. I didn't used docs and icons yet, but for me even without those two features is a really good job. Thanks for this contribution! |
The code looks fine to me, the changes are straightforward and not invasive. I would love for this to be merged soon, looking forward to it! |
Is your 3.2 branch still updated? |
@fire I've updated I don't think there's anything left to be added to this PR feature-wise. Depending on my own needs, I might keep updating the |
Any idea when this can be merged or what is needed to start the process to merge this? |
i don't think c++ is getting enough love :( |
@RaTcHeT302 If C++ wasn't getting any love, then nobody would be contributing to Godot 😉 It's just that pull request reviews are currently slowed down because the |
i mean i would help if i knew how, but i'm not really familiar with the engine yet, and i haven't had the time to figure things out - my end goals would clash with godot either way, and i have a weird style, where i tend to write comments everywhere, as i tend to forget everything i've learned if i stop looking at the same thing for a month or two i find myself relying on comments a lot, otherwise most source code ends up looking like complete gibberish to me as a whole, so i tend to waste a lot of time trying to dissect things and to figure out how everything actually works - i don't think i would be of much help with godot, considering how long it would take me to learn how to do anything properly i know what i want from the engine as a whole, but i have no idea as to how to actually implement anything in it yet, i think if i tried to, it would all be very hacky \ half assed i really hope to see these make it in though, i don't have the dexterity to learn both gd script and c++ at the same time, i'd rather deal with the quirks of c++ and focus on that godotengine/godot-proposals#565 |
Can you add the custom_modules flag to vsproj for Windows Visual Studio? |
@fire tbh I rarely use Visual Studio IDE (if at all), mostly VSCode, so not sure what needs to be made in order for this to work. I've read through the Lines 504 to 515 in 6a0473b
I suspect the In any case this can be added as part of another PR I guess, lets review this one first. 🙂 |
I want to report that this also works from within WSL with VSCode integration, I've just compiled |
Thanks for bearing with me, I'm now ready to review this :) I can already say 👍 for the proposal/use case, I'll review the implementation more in-depth but a priori this should be good to integrate in the engine. Once merged in |
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.
Some nitpicks, but looks great overall.
This patch adds ability to include external, user-defined C++ modules to be compiled as part of Godot via `custom_modules` build option which can be passed to `scons`. ``` scons platform=x11 tools=yes custom_modules="../project/modules" ``` Features: - detects all available modules under `custom_modules` directory the same way as it does for built-in modules (not recursive); - works with both relative and absolute paths on the filesystem; - multiple search paths can be specified as a comma-separated list. Module custom documentation and editor icons collection and generation process is adapted to work with absolute paths needed by such modules. Also fixed doctool bug mixing absolute and relative paths respectively. Implementation details: - `env.module_list` is a dictionary now, which holds both module name as key and either a relative or absolute path to a module as a value. - `methods.detect_modules` is run twice: once for built-in modules, and second for external modules, all combined later. - `methods.detect_modules` was not doing what it says on the tin. It is split into `detect_modules` which collects a list of available modules and `write_modules` which generates `register_types` sources for each. - whether a module is built-in or external is distinguished by relative or absolute paths respectively. `custom_modules` scons converter ensures that the path is absolute even if relative path is supplied, including expanding user paths and symbolic links. - treats the parent directory as if it was Godot's base directory, so that there's no need to change include paths in cases where custom modules are included as dependencies in other modules.
All in all I think this is ready to merge, I've just left some notes for some future changes if some more advanced features are needed. |
Thanks! |
Thanks, I'll work on the 3.2 version now then! |
Closes #31457, namely as suggested by @fire in #31457 (comment), also @willnationsdev.
Closes godotengine/godot-proposals#565.
Description
This PR adds ability to include external, user-defined C++ modules to be compiled as part of Godot:
Feature-wise this PR is similar to #36883 in a sense that both provide a command line option to compile something externally, with the following differences:
doctool
bug, but mostly only build scripts are modified.custom_modules
, while Added game module compilation argument #36883 aims to provide a way to compile a single C++ package (which can compile other modules though).One could just create
game
module and do this:Then run this command from within
godot
directory:with the added benefit of having ability to include any other module alongside.
The
register types
would look like this for agame
module:Pretty intuitive isn't it? 🙂
Features
custom_modules
directory the same way as it does for built-in modules (not recursive).PATH
env var.Benefits
godot/modules
, just point the path where your custom modules reside in your project.git
as submodules, as C++ modules can be independent from Godot repository.Implementation details
See commit description.
Suggestions
Option name is subject to discussion, feedback welcome.