Skip to content

Conversation

@bendk
Copy link
Contributor

@bendk bendk commented Sep 10, 2025

I'm opening this based on our discussion in #2640.

@paxbun can you take a look at the new Swift code and tell me if you think this would work for Gobley?


This is a new way for binding generators to load the CIs, Configs, metadata, etc. I'm hoping that this can replace the generate_bindings and generate_external_bindings functions, as well some other functions like library_mode::find_components.

The goal for the new design is to let bindings generators drive the process instead of a function like generate_external_bindings. The advantage of this is that it's easier to customize and we don't need to keep adding new hook methods. It also feels simpler overall to me. See #2640 for a discussion of this.

If we adopt this new system, then I think we can use it to remove a bunch of duplicate code. We can keep around the old functions for backwards-compatibility, but I think they can just be wrappers around BindgenLoader. Also, we should figure out a nice way to hook this up to the pipeline code.

Made uniffi-bindgen-swift use the new system. This was mostly to test the code and to serve as an example, but a nice side-benefit is that uniffi-bindgen-swift now can handle UDL files. I also added a uniffi-bindgen-swift binary file to go with the uniffi-bindgen binary.

@bendk bendk requested a review from mhammond September 10, 2025 15:43
@bendk bendk requested a review from a team as a code owner September 10, 2025 15:43
@bendk bendk force-pushed the push-lmlnvutlvsyn branch 3 times, most recently from 38e3ae3 to ff478be Compare September 10, 2025 15:55
This is a new way for binding generators to load the CIs, Configs,
metadata, etc.  I'm hoping that this can replace the `generate_bindings`
and `generate_external_bindings` functions, as well some other functions
like `library_mode::find_components`.

The goal for the new design is to let bindings generators drive the
process instead of a function like `generate_external_bindings`.  The
advantage of this is that it's easier to customize and we don't need to
keep adding new hook methods.  It also feels simpler overall to me.  See
mozilla#2640 for a discussion of this.

If we adopt this new system, then I think we can use it to remove a
bunch of duplicate code.  We can keep around the old functions for
backwards-compatibility, but I think they can just be wrappers around
`BindgenLoader`.  Also, we should figure out a nice way to hook this up
to the pipeline code.

Made `uniffi-bindgen-swift` use the new system.  This was mostly to test
the code and to serve as an example, but a nice side-benefit is that
`uniffi-bindgen-swift` now can handle UDL files.  I also added a
`uniffi-bindgen-swift` binary file to go with the `uniffi-bindgen`
binary.
@paxbun
Copy link
Contributor

paxbun commented Sep 10, 2025

@bendk Looks good to me as well! I don't remember the exact situation, but I once thought that I wanted to adjust the timing at which BindingGenerator::update_component_configs is invoked, and this would help us achieve it more easily.

Copy link
Member

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good to me. I'm mildly surprised Swift needed so many changes instead of being able to reuse more of the core, but that's a me problem :)

@bendk
Copy link
Contributor Author

bendk commented Sep 16, 2025

This seems good to me. I'm mildly surprised Swift needed so many changes instead of being able to reuse more of the core, but that's a me problem :)

That's mostly because I was using Swift to demonstrate the changes. I'll do a second pass to update the other parts.

@bendk bendk merged commit 1b9df3e into mozilla:main Sep 16, 2025
5 checks passed
@bendk bendk deleted the push-lmlnvutlvsyn branch September 16, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants