-
Notifications
You must be signed in to change notification settings - Fork 235
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
Allow the binding generator to not depend on builtin bindings. #2066
Conversation
@@ -136,12 +137,13 @@ pub fn calc_cdylib_name(library_path: &Utf8Path) -> Option<&str> { | |||
None | |||
} | |||
|
|||
fn find_sources<Config: BindingsConfig>( | |||
fn find_sources<T: BindingGenerator>( | |||
generator: &T, | |||
cargo_metadata: &cargo_metadata::Metadata, | |||
library_path: &Utf8Path, | |||
cdylib_name: Option<&str>, | |||
config_file_override: Option<&Utf8Path>, |
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.
If I could wave a magic wand, I'd also have the API take in the actual Config
instead of a path to the file that needs to be parsed. I think think the Config loading + parsing should happen in the CLI tool (as soon as possible).
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.
Can you please elaborate here? I've some vague ideas for going further in a later patch and I'd like to understand your thoughts. Here in particular I don't think we have the path to the TOML yet - we use the cargo metadata to find potentially one TOML file per crate.
What I think I'd like to do is work out how to separate the Config
from the Generator
- this would mean everything could pass around a dyn BindingGenerator
and a dyn BindingConfig
which would simplify a number of things. However, the only way I can see to make that work is to lean in to std::any::Any
and have the binding downcast from the dyn BindingConfig
back into its concrete Config
. Any thoughts on that?
I like it! |
Oops, I meant to comment on uniffi-rs/uniffi_bindgen/src/lib.rs Lines 223 to 253 in 6b09f11
|
baca5c2
to
961a82a
Compare
This seems tricky to avoid in "library mode" - we need to possibly load one file per crate, but don't know the list of crates before hand. What would a non-file-based config setup look like in this scenario? |
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.
The code looks fine to me and I have a vague sense of how this will simplify the bindings generation. But could you update the commit/PR message to discuss exactly how this will help?
uniffi/src/cli.rs
Outdated
@@ -79,6 +78,112 @@ enum Commands { | |||
}, | |||
} | |||
|
|||
// Type-bounds on trait implementations makes selecting between languages a bit tedious. |
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.
I didn't get this docstring at first, I think it refers to the match languages
statement which does seem tedious. How about moving it to the match to make it more obvious.
Previously there were internal `Config` details which only worked with builtin bindings types. This leans in to the `BindingGenerator` trait to make things less coupled with the builtin bindings and better for external bindings. Follows up on mozilla#1991.
961a82a
to
f555842
Compare
Previously there were internal
Config
details which only worked withbuiltin bindings types. This leans in to the
BindingGenerator
traitto make things less coupled with the builtin bindings and better
for external bindings.