forked from lightningdevkit/ldk-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuniffi_bindgen_generate_kotlin.sh
More file actions
executable file
·39 lines (34 loc) · 1.8 KB
/
Copy pathuniffi_bindgen_generate_kotlin.sh
File metadata and controls
executable file
·39 lines (34 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
BINDINGS_DIR="bindings/kotlin"
TARGET_DIR="target/bindings/kotlin"
PROJECT_DIR="ldk-node-jvm"
PACKAGE_DIR="org/lightningdevkit/ldknode"
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"
case " ${RUSTFLAGS:-} " in
*" --cfg tokio_unstable "*|*" --cfg=tokio_unstable "*) ;;
*) export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }--cfg tokio_unstable" ;;
esac
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
rustup target add x86_64-unknown-linux-gnu || exit 1
cargo build --release --target x86_64-unknown-linux-gnu --features uniffi || exit 1
DYNAMIC_LIB_PATH="target/x86_64-unknown-linux-gnu/release/libldk_node.so"
RES_DIR="$BINDINGS_DIR/$PROJECT_DIR/lib/src/main/resources/linux-x86-64/"
mkdir -p $RES_DIR || exit 1
cp $DYNAMIC_LIB_PATH $RES_DIR || exit 1
else
rustup target add x86_64-apple-darwin || exit 1
cargo build --release --target x86_64-apple-darwin --features uniffi || exit 1
DYNAMIC_LIB_PATH="target/x86_64-apple-darwin/release/libldk_node.dylib"
RES_DIR="$BINDINGS_DIR/$PROJECT_DIR/lib/src/main/resources/darwin-x86-64/"
mkdir -p $RES_DIR || exit 1
cp $DYNAMIC_LIB_PATH $RES_DIR || exit 1
rustup target add aarch64-apple-darwin || exit 1
cargo build --release --target aarch64-apple-darwin --features uniffi || exit 1
DYNAMIC_LIB_PATH="target/aarch64-apple-darwin/release/libldk_node.dylib"
RES_DIR="$BINDINGS_DIR/$PROJECT_DIR/lib/src/main/resources/darwin-aarch64/"
mkdir -p $RES_DIR || exit 1
cp $DYNAMIC_LIB_PATH $RES_DIR || exit 1
fi
mkdir -p "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR" || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --lib-file "$DYNAMIC_LIB_PATH" --language kotlin -o "$TARGET_DIR" || exit 1
cp "$TARGET_DIR"/"$PACKAGE_DIR"/ldk_node.kt "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR"/ || exit 1