Skip to content

Commit de3a9f6

Browse files
benallengspacebear21
authored andcommitted
Add dart bindings generation scripts
1 parent 7b03d7e commit de3a9f6

4 files changed

Lines changed: 65 additions & 0 deletions

File tree

payjoin-ffi/dart/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ doc/api/
55

66
.DS_Store
77

8+
# Auto-generated shared libraries
9+
*.dylib
10+
*.so
11+
*.dll
12+
813
# Auto-generated bindings
914
lib/payjoin_ffi.dart
1015
lib/bitcoin.dart
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
#!/bin/bash
4+
chmod +x ./scripts/generate_linux.sh
5+
chmod +x ./scripts/generate_macos.sh
6+
7+
8+
# Run each script
9+
scripts/generate_linux.sh
10+
scripts/generate_macos.sh
11+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
LIBNAME=libpayjoin_ffi.so
4+
LINUX_TARGET=x86_64-unknown-linux-gnu
5+
6+
echo "Generating payjoin_ffi.dart..."
7+
cd ../
8+
# This is a test script the actual release should not include the test utils feature
9+
cargo build --profile release --features uniffi,_test-utils
10+
cargo run --profile release --features uniffi,_test-utils --bin uniffi-bindgen -- --library target/release/$LIBNAME --language dart --out-dir dart/lib/
11+
12+
echo "Generating native binaries..."
13+
rustup target add $LINUX_TARGET
14+
# This is a test script the actual release should not include the test utils feature
15+
cargo build --profile release-smaller --target $LINUX_TARGET --features uniffi,_test-utils
16+
17+
echo "Copying linux payjoin_ffi.so"
18+
cp target/$LINUX_TARGET/release-smaller/$LIBNAME dart/$LIBNAME
19+
20+
echo "All done!"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
LIBNAME=libpayjoin_ffi.dylib
5+
6+
echo "Generating payjoin_ffi.dart..."
7+
cd ../
8+
# This is a test script the actual release should not include the test utils feature
9+
cargo build --features uniffi,_test-utils --profile release
10+
cargo run --features uniffi,_test-utils --profile release --bin uniffi-bindgen -- --library target/release/$LIBNAME --language dart --out-dir dart/lib/
11+
12+
echo "Generating native binaries..."
13+
rustup target add aarch64-apple-darwin x86_64-apple-darwin
14+
15+
# This is a test script the actual release should not include the test utils feature
16+
cargo build --profile release-smaller --target aarch64-apple-darwin --features uniffi,_test-utils
17+
echo "Done building aarch64-apple-darwin"
18+
19+
# This is a test script the actual release should not include the test utils feature
20+
cargo build --profile release-smaller --target x86_64-apple-darwin --features uniffi,_test-utils
21+
echo "Done building x86_64-apple-darwin"
22+
23+
echo "Building macos fat library"
24+
25+
lipo -create -output dart/$LIBNAME \
26+
target/aarch64-apple-darwin/release-smaller/$LIBNAME \
27+
target/x86_64-apple-darwin/release-smaller/$LIBNAME
28+
29+
echo "All done!"

0 commit comments

Comments
 (0)