-
Notifications
You must be signed in to change notification settings - Fork 65
add lib crate-type to bdk-ffi to be able to reuse it for other bindings like bdk-dart #924
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
Conversation
thunderbiscuit
left a comment
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'm not against this change per se, but I'd like to understand better why the plugin for dart needs it when others don't (JVM, Android, Swift, Python, React Native).
I took some time to clean this up a while back and my understanding was that the lib type is required in situations where your Rust code is used as a dependency itself, whereas for us here it's the compiled artifacts that are used by the plugins.
Again I'm not against it because it doesn't impact us negatively other than build times, but I want to make sure I know why each of those crate types are required (cdylib is for Android/JVM/Python, staticlib is for iOS).
It's because Dart has a new build system that does the compiling of the artifacts/native code dynamically when a user imports the The only requirement is that the native/foreign code (Rust in the case of Here is some more context about Native Assets in Dart and it being the new standard and way to go for bindings:
source: https://blog.dart.dev/announcing-dart-3-10-ea8b952b6088 |
reez
left a comment
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.
ACK ea7be23
Thought a good bit about this, I think because it's such a minimal change and is a big unblock for bdk-dart im in favor. I know it slows down build times, but that as well was minimal in my testing: dev builds ~+0.66s, release builds ~+1.03, release-smaller negligible.
The other alternatives are to do nothing or a much larger refactor, so this PR seemed like a clear winner in my mind of all the options.
Open to anyone else's feedback or if I missed anything
|
Sounds good! Again not a problem on our end (thanks for testing the time diff @reez). But just for my own curiosity I'd love to know more about how it impacts the builds/users of bdk-dart. Maybe we can add it as an agenda item on the next dev call @kumulynja? Mostly I'm wondering about whether this means that the "build" then becomes user-side and so we offload the difficulties of Rust compilation onto Flutter/Dart users who might not have the Rust toolchain installed or other little quirks instead of having it already precompiled + bundled for them. Like are the artifacts compiled user-side (apps that add bdk-dart as a dependency) or is it somehow done at the bdk-dart layer, and the artifact we publish on pub.dev are all ready to go? |
thunderbiscuit
left a comment
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.
@kumulynja would you mind squashing your two commits into one? Then this one is ready to go and I'll merge it today.
Done! |
I have a conflicting meeting tomorrow, so I won't be able to connect to the call sadly, but you already got it right: we offload the Rust compilation to the users (devs) adding It greatly simplifies things on the An advantage of the envisioned |
thunderbiscuit
left a comment
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.
ACK a3d8365.
Description
This PR just adds "lib" as a crate-type besides "cdylib" and "staticlib". In this way bdk-ffi can be more easily wrapped and reused for other bindings like the dart bindings in bdk-dart. Without it, more code from bdk-ffi has to be duplicated to bdk-dart and the process becomes more complex and hacky.
Notes to the reviewers
I tested this PR in the following bdk-dart PR already: bitcoindevkit/bdk-dart#12
It would be good to get this merged here first to be able to remove the patch to my fork of bdk-ffi there.
Checklists
All Submissions:
cargo fmtandcargo clippybefore committing