2021-10-12 18:22:02 -07:00
|
|
|
# BDK UniFFI Language Bindings
|
2021-10-11 23:04:18 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
## Setup Android build environment
|
2021-10-11 23:04:18 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
1. Add Android rust targets
|
2021-10-13 03:05:55 +05:30
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
```sh
|
|
|
|
rustup target add x86_64-apple-darwin x86_64-unknown-linux-gnu x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android
|
|
|
|
```
|
2021-10-11 23:04:18 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
2. Set ANDROID_NDK_HOME
|
|
|
|
|
|
|
|
```sh
|
|
|
|
export ANDROID_NDK_HOME=/home/<user>/Android/Sdk/ndk/<NDK version, ie. 21.4.7075529>
|
|
|
|
```
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
## Setup Swift build environment
|
2021-09-25 21:17:40 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
1. install Swift, see ["Download Swift"](https://swift.org/download/) page
|
|
|
|
(or on Mac OSX install the latest Xcode)
|
2021-09-25 21:17:40 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
## Setup UniFFI
|
2021-09-25 21:17:40 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
1. `cargo install uniffi_bindgen`
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
## Adding new structs and functions
|
2021-10-02 12:08:34 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
See the [UniFFI User Guide](https://mozilla.github.io/uniffi-rs/)
|
2021-10-02 12:08:34 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
### For pass by value objects
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
1. create new rust struct with only fields that are supported UniFFI types
|
|
|
|
2. update mapping `bdk.udl` file with new `dictionary`
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
### For pass by reference values
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
1. create wrapper rust struct/impl with only fields that are `Sync + Send`
|
|
|
|
2. update mapping `bdk.udl` file with new `interface`
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
### Build and test
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-10-12 18:22:02 -07:00
|
|
|
1. Use `build.sh` script (TODO do it all in build.rs instead)
|
|
|
|
2. Create tests in `bindings/bdk-kotlin` and/or `bindings/bdk-swift`
|
|
|
|
3. Use `test.sh` to run all bindings tests
|