-
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
[WIP] Using UniFFi bindgen as a cargo subcommand #1002
Conversation
@@ -11,7 +11,7 @@ edition = "2018" | |||
keywords = ["ffi", "bindgen"] | |||
|
|||
[[bin]] | |||
name = "uniffi-bindgen" |
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.
Not relevant for prototyping, but longer-term, I expect we may want to keep the existing uniffi-bindgen
command in addition to the new one for b/w compat at least for a while.
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.
This is actually a little more tricky than appears on the surface. The three ways it seems we can get this done is:
(1) in the cargo.toml have
[[bin]]
name = "cargo-uniffi"
path = "src/main.rs"
[[bin]]
name = "uniffi-bindgen"
path = "src/main.rs"
which will produce an warning warning: .../uniffi-rs/uniffi_bindgen/Cargo.toml: file found to be present in multiple build targets: .../uniffi-rs/uniffi_bindgen/src/main.rs
which may not be an issue as we are intentionally doing this...
(2) Have a second main.rs in a separate directory that just calls the mod uniffi_bindgen
(3) Create a shared lib and then have two mains use the same shared library rust-lang/cargo#5930
It seems 3 is the "recommended" solution but open to any ideas!
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.
(3) Create a shared lib and then have two mains use the same shared library rust-lang/cargo#5930
Yeah, I think if I were a new developer coming into the project, this is what I'd expect to see - a shared lib with the functionality and then several small "wrapper" crates that use it to implement a specific command-line tool.
_ => bail!("No command specified; try `--help` for some help."), | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn gen_comands<'a>() -> ArgMatches<'a> { | ||
const POSSIBLE_LANGUAGES: &[&str] = &["kotlin", "python", "swift", "gecko_js", "ruby"]; |
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.
Something to think about is, how might this inter-operate with the work @tarikeshaq is doing to split out the languages in separate crates? Would we end up shelling out to cargo-uniffi-kotlin
which then implements its own suite of sub-sub-sub-commands?
(I think it would be fine for us to do that, just thinkin' it through out loud)
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.
hmmm yes that's definitely something that's been in the back of my mind during these meetings -- I think that might be the most straightforward way to implement it. One thought I had is the idea of "plugins" to the uniffi bindgen that allows the commands from other bindgens to be "imported" to the main bindgen. I got inspired from the bevy game engine:
https://bevyengine.org/learn/book/getting-started/plugins/
Of course it wouldn't look like how their doing it but throwing some some wild ideas out there.
72cf9b2
to
3ecbc89
Compare
Trying to write some "production-ready" code and thinking about this just a tad bit more. I wonder if it makes sense instead of having a |
It sounds worth a try! One thing about a separate |
So here's an example of something that I think would be a really interesting direction for UniFFI - what if I didn't need to specify the There are a number of ways we could achieve that:
What I'm interested in is the big-picture shift from pointing at an interface file, to pointing at the crate itself. |
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.
Not sure if we will pick this back up or not, but requesting changes to not have it show up as awaiting review.
Given the progressing work on #1257, it might not sure a whole lot of sense to continue work on improving UDL-related workflows, which are likely going to be replaced entirely by that in a few months. |
the uniffi-bindgen binary is since gone, so this would need some rethinking. I think the best for now is to close it. |
Discussion #472
Taking a crack at making a more robust UniFFi CLI that allows for more flexibility as well as potential new tooling for checking environment to ensure success when building using UniFFi.
Suggestions welcome!
To install: In the bindgen dir ->
cargo install --path .
will install two binariesuniffi-bindgen
andcargo-uniffi
To use:
uniffi-bindgen <commands>
cargo uniffi <commands>
New args:
cargo uniffi check -l [language]
will ensure that you have things properly installed(in progress)
cargo uniffi check ?
will check scaffolding and udl files are properly setupPlanned changes:
cargo uniffi scaffolding <udl>