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

Add Rust -> Kotlin interop and an example. #23

Closed
wants to merge 2 commits into from

Conversation

Yury-Fridlyand
Copy link

@Yury-Fridlyand Yury-Fridlyand commented Oct 13, 2023

stateDiagram-v2
state "interop/lib.rs" as Rust
state "interop/babushka.udl" as UDL
state "babushka.uniffi.rs" as uniffi.rs
state "Native Lib" as lib
state "Autogenerated Kotlin bindings" as kotlinsrc
state "jar (Platform-dependent)" as jar
state "Kotlin/jvm" as kotlinjvm
state "java/jvm" as javajvm

Rust --> uniffi.rs : uniffi
UDL --> uniffi.rs
uniffi.rs --> lib : Rust Compiler
uniffi.rs --> kotlinsrc : uniffi
lib --> jar
kotlinsrc --> jar
jar --> kotlinjvm
jar --> javajvm
Loading

A resulting jar is platform dependent. It contains a native library and required jvm classes which can load and use it.
A client library/app which uses it should have following dependencies loaded to make things working:

    implementation "net.java.dev.jna:jna:5.8.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.20"

Workflow is copied from BDK: https://github.com/bitcoindevkit/bdk-ffi/tree/master

TODOs:

  • Add platform name to the jar file name
  • Make dependencies transitive or shadow
  • Confirm that we can copy/reuse code from BDK

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.

2 participants