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-28 15:34:17 -07:00
|
|
|
2. Install Android SDK and Build-Tools for API level 30+
|
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`
|
2021-10-14 10:58:16 -07:00
|
|
|
3. Use `test.sh` to run all bindings tests
|
2021-10-16 14:45:32 +05:30
|
|
|
|
|
|
|
### Run kotlin demo application
|
|
|
|
|
|
|
|
We have a kotlin demo console application which uses bdk.
|
|
|
|
It uses stdin for inputs and can be run from gradle.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cd bindings/bdk-kotlin
|
|
|
|
./gradlew :demo:run
|
|
|
|
```
|
|
|
|
|