-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathuniffi_bindgen_generate_python.sh
More file actions
executable file
·56 lines (49 loc) · 1.6 KB
/
Copy pathuniffi_bindgen_generate_python.sh
File metadata and controls
executable file
·56 lines (49 loc) · 1.6 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
BINDINGS_DIR="$REPO_ROOT/bindings/python/src/ldk_node"
TARGET_DIR="${CARGO_TARGET_DIR:-$REPO_ROOT/target}"
CARGO_BUILD_ARGS=()
UNIFFI_FEATURES="uniffi-default"
if [[ -n "${LDK_NODE_EXTRA_FEATURES:-}" ]]; then
UNIFFI_FEATURES+=",$LDK_NODE_EXTRA_FEATURES"
fi
case " ${RUSTFLAGS:-} " in
*" --cfg tokio_unstable "*|*" --cfg=tokio_unstable "*) ;;
*) export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }--cfg tokio_unstable" ;;
esac
case "$(uname -s)" in
Linux) DYNAMIC_LIB_PATH="$TARGET_DIR/release-smaller/libldk_node.so" ;;
Darwin)
case "${ARCHFLAGS:-}" in
"") DYNAMIC_LIB_PATH="$TARGET_DIR/release-smaller/libldk_node.dylib" ;;
"-arch x86_64")
CARGO_BUILD_ARGS=(--target x86_64-apple-darwin)
DYNAMIC_LIB_PATH="$TARGET_DIR/x86_64-apple-darwin/release-smaller/libldk_node.dylib"
;;
"-arch arm64")
CARGO_BUILD_ARGS=(--target aarch64-apple-darwin)
DYNAMIC_LIB_PATH="$TARGET_DIR/aarch64-apple-darwin/release-smaller/libldk_node.dylib"
;;
*)
echo "Unsupported ARCHFLAGS: $ARCHFLAGS" >&2
exit 1
;;
esac
;;
*)
echo "Unsupported operating system: $(uname -s)" >&2
exit 1
;;
esac
cd "$REPO_ROOT"
mkdir -p "$BINDINGS_DIR"
cargo build "${CARGO_BUILD_ARGS[@]}" --profile release-smaller --no-default-features \
--features "$UNIFFI_FEATURES"
cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml -- \
generate bindings/ldk_node.udl \
--lib-file "$DYNAMIC_LIB_PATH" \
--language python \
-o "$BINDINGS_DIR"
cp "$DYNAMIC_LIB_PATH" "$BINDINGS_DIR"