-
Notifications
You must be signed in to change notification settings - Fork 212
[Discussion] Simplify custom bindings generation for custom builds #640
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
Comments
Seems like a good idea to me. Thanks for the suggestion! Could you create a PR for this? |
Is the feature flag necessary? It may work that way: if some env var (let's say |
Could we also use |
829: Support Godot 3.4 r=Bromeon a=Bromeon Updates api.json, CI scripts and examples. This is a **breaking change**. Some GDNative APIs added default parameters, which can currently not be modeled in a backwards-compatible way in godot-rust (Rust itself doesn't support default parameters). It is however possible to manually generate `api.json` for an older Godot version (3.2 or 3.3) and keep using godot-rust normally. Addresses #814 in the short-term 🛠️ Still on the radar: #640 📡 Co-authored-by: Jan Haller <[email protected]>
829: Support Godot 3.4 r=Bromeon a=Bromeon Updates api.json, CI scripts and examples. This is a **breaking change**. Some GDNative APIs added default parameters, which can currently not be modeled in a backwards-compatible way in godot-rust (Rust itself doesn't support default parameters). It is however possible to manually generate `api.json` for an older Godot version (3.2 or 3.3) and keep using godot-rust normally. Addresses #814 in the short-term 🛠️ Still on the radar: #640 📡 Co-authored-by: Jan Haller <[email protected]>
@rminderhoud and @bluenote10: Thanks a lot for your input! I realized your ideas as a proof-of-concept in #833. Let me know if you have time to test it or other feedback (you could leave it directly in the PR)! 🙂 @carmel4a: I think it's important that godot-rust in its default configuration behaves consistently. If the presence of an executable on the system alters runtime behavior (to the point of incompatibility) without the user opting in, that will lead to unpleasant surprises. That's why |
@Bromeon, happy new year. I didn't get a chance to test this before it merged but the changes look awesome! |
@rminderhoud Thanks, happy new year to you too! 🍾 Glad to hear! No worries about the testing, we can continuously enhance the experience. Now that it's in |
Hello, I just wanted to make a small proposal to this wonderful crate. Namely, to improve the ergonomics for when using a custom build of godot.
Problem
The problem is as such, a user wants to use godot-rust with a custom build of godot so they need a custom build of
gdnative-bindings
to usegodot-rust
. The current process is nicely documented here but it is quite convoluted. To summarize, when using a custom godot build we need to rebuild thegdnative-bindings
with the correctapi.json
exported from our custom godot build. The recommended steps are to download thegdnative-bindings
crate, modify the storedapi.json
file, and then do some magic in our project'sCargo.toml
.Criticism
My main argument against this implementation is that it's neither here, nor there. On the one hand, there's the kind of user that is comfortable customizing godot, making a custom build, using these bindings, etc. For those people I think we can safely assume that they would be comfortable maintaining a fork of this repo and can simply change the
api.json
directly. For these power users, I would argue the guidance can be simplified to "regenerate the api.json here and rebuild".On the other hand I think there is a second type of user who uses a custom build of godot but maybe makes very minor modifications (disable specific modules, compiler tweaks, etc.) or none at all (e.g. is on a minor version beta). For this user I think the steps outlined in the docs are too cumbersome. If I am on 3.2.3-stable but I want to test my project on 3.2.4-beta then there's quite a bit of ceremony to update my gdnative lib.
Proposal
I believe we can simplify the process by leveraging the build file in
gdnative-bindings
. I propose that using a feature flag and an environment variable, theapi.json
can be automatically generated at build time. This would allow users to use the latest sources without having to modify any source code but still be able to target a custom build. Here is an example of how I would foresee this working.A new feature flag would be introduced in the top level crate that gets forwarded to the
gdnative-bindings
crate. Users who want to use a custom build would specify this feature flag.The user would then also have to specify an environment variable to their custom godot build, e.g.
GODOT_BIN
. The feature could then be detected ingdnative-bindings/build.rs
and if it is enabled and the var set then theapi.json
can be re-built on the fly.I believe this would be a big enhancement to support the workflow of custom builds and would not be too disruptive. It would require adding a feature flag to the crates, adding the feature check to the
build.rs
and adding some minor logic to pick the correctapi.json
after it has been generated.The text was updated successfully, but these errors were encountered: