-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Create a built-in editor tool for organizing and mass/selectively compiling GDNative projects and addons #119
Comments
Given how this proposal ended up quite a read, I should note that instead of trying to compensate for GDNative lack of usability/flexibility, there could be done necessary steps to improve the core first, despite the naysayers. 😛
For gameplay programming, I really hope GDScript could be optimized further. As I recall, GDNative was not advertised as a go-to tool for gameplay programming initially, but rather as a quick way to bind third-party libraries without having to recompile the entire engine. So, GDNative's design decisions simply did not cover those gameplay use cases to full extent to improve usability in this regard yet. Godot would become a nice alternative for those with previous experience developing with UE4, for instance. Having said that, Godot C++ modules are still more usable for me so far, it doesn't really take too much time to compile the entire source (5-15 mins on my machine, depending on what modules are enabled), and Scons only compiles the source that was changed (mostly), improving build time significantly. But if you plan to reuse the modules in other projects, or when you want to cater to user needs more/benefit from open-source community and free CI tools, this is where the pain of dealing with GDNative pays off I guess. |
Godot's GDNative in 3.0 was one of the major reasons I ditched Unreal for Godot initially. So yeah, this is definitely a big reason for people who want to just write C++ scripts and use them in a lightweight FOSS engine.
I agree that they are more user-friendly to setup and use at the moment.
This is just as true for GDNative except that it always builds far faster since there are fewer files involved. The initial build is faster, and fewer libraries/dependencies are involved usually. If I make a change to the header files or registration code, then the whole modules static library and the final binary all need to be rebuilt.
Exactly. |
I thought that my difficulties while trying GDNative were solely due to my lack of cpp skills. Many info required for native scripts compilation aren't related to a particular language. As instance, executable and sources location, required platforms... and could be provided by the Godot editor in some resource. Then the binding author is free to plug his build script to retrieve these infos, whatever if he uses Scons , Cmake or Meson... |
Having just spent the past two days trying to get native script c++ working in my project, I can't thumb this up enough. So much of my experience with Godot so far has been incredibly intuitive and "batteries included". I was flying down the highway that is Godot, and then took a hard turn onto the unpaved road that is native script and my wheels came off! |
That's an understatement. I remember spending over half a day just to make C++ example running (outdated wiki, missing documentation). I implemented literally same functionality as in C# before (for purpose of benchmarking) and I spent so much time with the C++ variant, definitely more than 3 times more of what it took for C# (to previously mentioned problems I also had to modify build script [uses SCons which isn't supported by CLion], hit bugs in bindings, it took significant time to figure out how mostly undocumented non-standard memory management works [random crashes in seemingly unrelated calls were really treacherous], undocumented [different than in GDS] behaviour of properties in init/ready and I probably forget a few). It was a giant pain which I don't intend to repeat any time soon. It seems to me Unity + C# + Burst is better choice (nice language, first-class, performance approaching C++) than Godot + C++ (tried only GDNative, not modules, since I wanted a C++ scripts, not modifying innards of the engine). Godot has a lot of work to do in this area. |
I understand the will to comply with standards, I really do. Consider, for a moment, that on the other hand, if this is all this project would have ever done, it would not even be started. Reading this gives me a headache and I ask myself if it is worth the effort. I consider the work that has to go into this C++ integration as diametral to its use and can imagine going the route instead, that Godot got popular in the first place: Innovation and progress. I understand that some people - especially those ones with the money - want to simply use C++, no matter what, so it will happen. I give to think, that you can implement a far superior solution, in the form of F#. F# is an amazing scripting language, clean, looks like Python, brings an ML type system and tons of goodies, plus its already halfway implemented. I know it will not happen - since again, people are stubborn and stubbornness almost always wins over scientific logic - while I am optimistic that some of you can see its benefits and the benefits for this project. In the end, even John Carmack switched from C++ to Haskell after couple of decades, so why going back instead of leading the future? Thanks a lot |
@ShalokShalom I think there must to be something really innovative in order to overcome the stubbornness, to the point where everybody starts to drop their existing tools within a short period of time, making it evolutionary, I think that's the only way. Are you one of those influencers? If so, start creating something which would be picked up by millions of developers. John Carmack cannot lead the future all by himself. 🙂 I'm not sure if this has something specific to do with C++ alone, you could likely conveniently compile any other GDNative-ready language, it's just that it would make the process more transparent to users. Godot is being written in C++ so that's the most obvious example which was used here in my opinion. |
@ShalokShalom I think you are slightly misunderstanding the purpose of this proposal, perhaps? This would be something that would allow the editor itself to have a built-in solution for compiling GDNative projects. Those who create GDNative bindings would then also be able to create GDNativeBuild resources which would teach the Godot Editor how to properly build and use those bindings into libraries / include those bindings in a built dynamic library / GDNativeLibrary resource. So, for example, Haskell has a The above proposal is more about creating the platform within Godot that would enable users to instruct the Editor on how to build/generate the script code. It effectively raises all languages to the level of C#, to a degree. As for F# (which I agree is a brilliant language which I've already created editor tools for generating), I already created a separate proposal just for that purpose (#191). If you bundle this proposal, #191, and #22 together, and if you then also added support for inheritance in VisualScript (don't think that's been implemented yet...), it effectively brings all possible scripting languages to an equivalent level of support within the engine. The only reason C++ is covered so much in this proposal is because C++ is the only "officially maintained" set of GDNative bindings, and I would expect the Godot Editor to come with a built-in GDNativeBuild resource for that language for the same reason. Which makes sense since Godot itself is written in C++. |
Oh thanks a ton. I got here from another issue and did not understand the proposal here. This seems like a sensible solution. |
Many thumbs up for this. I've been trying to port over some performance-sensitive code (procedural mesh generation, custom Some IF Statements simulations, etc) from GDScript to C++ and it's been a constant hell. I think that improving C++ work with Godot would also improve the amount and quality of contributions, since it would make it easier for users to start using C++ and understand more of the engine core. I can speak for myself, that using GDNative Cpp code is what is making me more comfortable with going into the C++ code of the engine itself. |
This is not a solution by far but people coming here may find those tricks usefull. Last.. use Visual Studio Code! |
@kakoeimon One of the things I'd like this Proposal to do is enable people to have separately versioned builds of different languages' bindings in user folders so that they can be reused between projects, much like you are demonstrating above. :-) |
@willnationsdev I made a repo based on my previous post with some python scripts to make development with cpp a litle bit easier. |
@kakoeimon the part which generates files reminds me of |
@Xrayez gdgen looks realy cool, thanks. |
This plugin, in my mind is the first step into approaching this: https://gitlab.com/turtlewit/godot_cpp_helper_plugin |
This comment has been minimized.
This comment has been minimized.
@nathanfranke Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
I'm currently working on a implementation of this issue, First I'm trying with The plugin is installed locally, as any other one: But, the source files (CPP Header Godot) is installed globally, this way N Godot Projects Can Interact with N Native projects: This way the user Generate bindings only one time, and any script one time, when compiled the GDLIB and NativeScript is generated inside the current Godot Project! |
@nonunknown You can use |
Already using :D But I let user choose in case they want to do other stuff while compiling. |
@nonunknown This looks great, is there a possibility you could maybe take a look at the Nim language next after Rust? |
Yeah, I'll try to support as many languages as possible, plz give me your discord so you can help me when implementing that support for Nim language Also for those interested on the implementation of this proposal here's the link to it, its released: |
@nonunknown Dude. But now that I see this proposal, I can use this to determine how things should be done in my project. I never thought of the source files being outside of the godot project. |
Further more, I looked in your source code and found |
Wow very interesting, I think we should work on this toguether I'm working on 2.0 which adds support for android building and rust language, plans to add more (nim, and others if requested). Also globalize_path works only in-editor , which should work fine for anyone! |
Could you explain what you mean by "work together"? We are both working on similar projects, so are you suggesting that I help with your project, you help with mine, or merge the two together? |
merge the projects, get the best side of each one and make it one huge project! |
That sounds like a great idea! |
The owner should be GEL (Godot Extended Libraries) just talk with @willnationsdev at so he can add you to GEL organization! Also we should rethink the interface, I personally loved the way you did, but a mean between mine and yours should be good! The repo: Talk with willnations here: |
Alright, gotcha! |
Describe the project you are working on:
I have attempted in the past to build addons written in NativeScript C++, but the process is cumbersome and concerns me at scale.
Describe the problem or limitation you are having in your project:
Godot's NativeScript is very much a second-class citizen compared to GDScript, C#, and VisualScript. It requires a lot of technical know-how to set it up. Work that is done automatically for other languages is difficult or impossible to do for NativeScript.
init.cpp
file so thatgodot_nativescript_init(...)
properly registers the new class name..gdns
resource that points to the correct class name.PluginScript is a concept that was designed to accommodate some of these concerns. However, there are many NativeScript languages already created. Improving the toolset to create, manage, build, and use NativeScript code would provide more value to Godot's addon ecosystem overall.
In addition, many NativeScript languages must deal with the dilemma of where to put their source code.
A user who installs NativeScript code via the Godot Asset Library should have access to the source code while still keeping the source code out of their project's final binary. This means:
user://
location so that they can be referenced by the editor on a per-project basis, but not bundled into the final binary.The editor should be able to scan directories (maybe
/src
and/addons/**/src
as conventions) for necessary files (SCSub
,config.py
) which NativeScript bindings version they should use, etc. Then the editor can work out the minimal number of dynamic libraries necessary, generating all appropriate GDNativeLibrary resources, and likewise generating a NativeScript resource file for each registered class, along with optionally (in the python configuration perhaps, or ProjectSettings for project-wide configuration) assigning script class names to them all. The editor would ideally provide an intuitive GUI for configuring and automating all of this.Describe how this feature / enhancement will help you overcome this problem or limitation:
Create a base GDNativeBuild resource that allows users to configure the construction of different types of GDNative projects. The engine could then provide a derived GDNativeBuildCpp resource tailor-made for building and managing NativeScript source code. Those managing repositories could then create their own derived versions to have a user-accessible GUI built into the editor with minimal effort.
For C++, we'd need to create an "official", highly generic, parameterized SConstruct script that Godot can generate on command (if we want the language to have better first-party support). It could simply download the bindings to the user settings under a version number, thereby allowing multiple "builds" to reference the same bindings version number.
We can then use an EditorInspectorPlugin to create buttons and other behavioral elements to the GDNativeBuild to provide a unified interface for doing all operations necessary for all NativeScript projects:
.gdns
files, which are tool scripts, etc. (and toggle on/off the presence of the latter two).This would all shift work that would otherwise be difficult to learn, manually executed, and an absolute maze of chaos to manage into something simple, intuitive, built-in, automated, organized, and visual.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Some generic interface for executing necessary NativeScript processes. There could be a lot more than just this, as mentioned in other sections, but this is just a general idea. The buttons at the top are inserted via an EditorInspectorPlugin.
"Sub builds" would be an array of resources that allow one to bunch multiple other builds under a single build recursively, i.e. requesting to build the top level one would also build the lower level ones, or the lower ones could be expanded to open their own toolbar for building independently, etc.
I would imagine you could have additional GUI elements for detailing where to place the source code, which classes are present / what their status is (registered? tool? NativeScript?) and GUI elements for generating files. Everything outlined above, though I'm not the best UI designer so maybe others have better ideas.
Describe implementation detail for your proposal (in code), if possible:
/gdnative/build
submodule. It would need to have...godot-cpp
repository. Default users who are just getting started could use it while power users that prefer to write their own could replace it with their own or ignore it.If this enhancement will not be used often, can it be worked around with a few lines of script?:
It would be used very often. I have already started working with it and then frequently stopped because of how much of a hassle it is to setup, manage, and use the C++ scripts compared to GDScript and C#. If it were easier, I would be more inclined to use them. And if we are going to improve the usability of one, we may as well ensure that the NativeScript ecosystem itself can benefit from the changes rather than just C++ alone (as a PluginScript would do).
Once we start having more first-party addons that port functionality out of the core and once the addon ecosystem is improved further (teaching more users how to setup Travis CI builds for their own multi-platform GDNative projects - godotengine/godot-docs#2815), I believe we will see more and more people wanting to use it for complex projects and performance-intensive code.
Any user that wants to include third-party addon in their project shouldn't have to worry about what kind of source code was used to write that addon. Including it in their project should mean that using it works out-of-the-box with minimal effort.
You can do most of this exclusively through script code, but the code itself is highly complex and C++ is supposed to an official Godot language (as the godotengine team members directly maintain the
godot-cpp
repository). We should also put forward the minimal effort of improving the C++ workflow for users through the editor, even if it has to separately download most of the required files.Is there a reason why this should be core and not an add-on in the asset library?:
If the goal is for the manner of addon implementation to be irrelevant to the end-user, then the end-user should not need a separate tool to setup and use the code in an organized and efficient way. I should be able to use Godot as a lightweight IDE, just as it works for C#.
Furthermore, content creators should not have to go through an obscure and difficult process just to organize their addons adequately. It should all be built-in.
The text was updated successfully, but these errors were encountered: