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

Pre-generate bindgen file #12

Closed
Bromeon opened this issue Nov 6, 2022 · 4 comments · Fixed by #211
Closed

Pre-generate bindgen file #12

Bromeon opened this issue Nov 6, 2022 · 4 comments · Fixed by #211
Labels
c: tooling CI, automation, tools quality-of-life No new functionality, but improves ergonomics/internals

Comments

@Bromeon
Copy link
Member

Bromeon commented Nov 6, 2022

Bindgen not only adds a ton of dependencies that slow down initial compilation, but it is regularly an obstacle for users to get started, because they don't have LLVM installed or correctly configured.

We could generate the bindings Rust file on developer machines and ship it. CI could be used to enforce that bindings are up-to-date.

If it turns out that different platforms have different binding files, conditional compilation is an option. Would add a bit of development of maintenance effort, but probably worth the easier and faster setup process for everyone.

@Bromeon Bromeon added quality-of-life No new functionality, but improves ergonomics/internals c: tooling CI, automation, tools labels Nov 6, 2022
@nikitalita
Copy link

you'd need to version them per release version; I've found that even patch number updates can introduce breaking changes (semver not withstanding). This also wouldn't work with custom builds, like Godot versions with Steam integration built in.

@Bromeon
Copy link
Member Author

Bromeon commented Nov 7, 2022

Yes, there would still need to be an option to generate bindings in godot-ffi, also for CI to verify that the binding is up-to-date.

What I could imagine is something similar to the custom-godot feature in GDNative: by default, we support the latest Godot version out-of-the-box, and allow customization via feature flag (which would pull and run bindgen). We could even verify at build time that the Godot engine version in PATH is the same as the one for which bindgen was run, and throw an error otherwise.

This is a bit a mess during Godot 4 beta, as I'd like to use nightly Godot builds for CI (changing every day), and then every single version is possibly breaking. Maybe a compromise would be to always support latest Godot nightly on master, and issue a warning (but no error) if someone uses an older version. That way, people can decide themselves whether they want to take the risk.

A very involved approach is to maintain a list of all nightly versions since the last time the binding headers changed, and check if Godot in PATH is one of them. This would be quite some effort, and still not work of Godot is newer than godot-rust, or of a version between those that were used for nightly builds.

So many options... 😅 I'm open for input!

@nikitalita
Copy link

nikitalita commented Nov 8, 2022

IMO, it’s not worth the effort to try and support people developing on top of the current master. If they’re doing that, then they likely have LLVM already installed (or know how to do it easily). I’d recommend only keeping the official beta releases as the prebuilt ones and if users have something else, throw an error and tell them they need to use bindgen by compiling with a feature flag or something.

This is a bit a mess during Godot 4 beta, as I'd like to use nightly Godot builds for CI (changing every day), and then every single version is possibly breaking

lord, tell me about it. I developed on top of master for a year and a half, and it was a pain in the ass. What I did was I had the main CI workflow pinned to the last good commit, and I had a separate workflow that ran on a timer that just compiled to see if I had drifted out of sync.

@Bromeon
Copy link
Member Author

Bromeon commented Nov 8, 2022

I’d recommend only keeping the official beta releases as the prebuilt ones and if users have something else, throw an error and tell them they need to use bindgen by compiling with a feature flag or something.

Yeah, maybe "support latest Beta release out of the box" might be a good policy.

We can still run CI additionally against Godot nightly builds, maybe in a way that allows failing, to learn about potential changes sooner.

@bors bors bot closed this as completed in e0d45a3 Apr 2, 2023
Hapenia-Lans pushed a commit to Hapenia-Lans/gdextension that referenced this issue May 26, 2023
# This is the 1st commit message:

Parse gdextension_interface.h declarations using regex

# This is the commit message #2:

AsUninit trait to convert FFI pointers to their uninitialized versions

# This is the commit message godot-rust#3:

GodotFfi::from_sys_init() now uses uninitialized pointer types

# This is the commit message godot-rust#4:

Introduce GDExtensionUninitialized*Ptr, without changing semantics

# This is the commit message godot-rust#5:

Adjust init code to new get_proc_address mechanism

# This is the commit message godot-rust#6:

Make `trace` feature available in godot-ffi, fix interface access before initialization

# This is the commit message godot-rust#7:

Compatibility layer between Godot 4.0 and 4.1 (different GDExtension APIs)

# This is the commit message godot-rust#8:

Add GdextBuild to access build/runtime metadata

# This is the commit message godot-rust#9:

Detect 4.0 <-> 4.1 mismatches in both directions + missing `compatibility_minimum = 4.1`

# This is the commit message godot-rust#10:

Detect legacy/modern version of C header (also without `custom-godot` feature)

# This is the commit message godot-rust#11:

CI: add jobs that use patched 4.0.x versions

# This is the commit message godot-rust#12:

Remove several memory leaks by constructing into uninitialized pointers

# This is the commit message godot-rust#13:

CI: memcheck jobs for both 4.0.3 and nightly

# This is the commit message godot-rust#14:

Remove ToVariant, FromVariant, and VariantMetadata impls for pointers

This commit splits SignatureTuple into two separate traits:
PtrcallSignatureTuple and VarcallSignatureTuple. The latter is a child
of the former. PtrcallSignatureTuple is used for ptrcall and only
demands GodotFuncMarshall of its arguments. VarcallSignatureTuple is
used for varcall and additionally demands ToVariant, FromVariant, and
VariantMetadata of its arguments, so pointers cannot benefit from the
optimizations provided by varcall over ptrcall.

# This is the commit message godot-rust#15:

Adds FromVariant and ToVariant proc macros

# This is the commit message godot-rust#16:

godot-core: builtin: reimplement Plane functions/methods

# This is the commit message godot-rust#17:

impl GodotFfi for Option<T> when T is pointer sized and nullable godot-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.

# This is the commit message godot-rust#18:

Fix UB in virtual method calls that take objects
Fix incorrect incrementing of refcount when calling in to godot
Fix refcount not being incremented when we receive a refcounted object in virtual methods

# This is the commit message godot-rust#19:

fix UB caused by preload weirdness

# This is the commit message godot-rust#20:

Implements swizzle and converts from/to tuples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: tooling CI, automation, tools quality-of-life No new functionality, but improves ergonomics/internals
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants