Skip to content

Commit c1649e5

Browse files
committed
chore: speed up bindings generation pipeline
1 parent 7a3d322 commit c1649e5

5 files changed

Lines changed: 29 additions & 22 deletions

bindgen.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
RUSTFLAGS="--cfg no_download" cargo build \
5-
&& ./scripts/uniffi_bindgen_generate.sh \
6-
&& ./scripts/swift_create_xcframework_archive.sh \
7-
&& sh scripts/uniffi_bindgen_generate_kotlin.sh \
8-
&& sh scripts/uniffi_bindgen_generate_kotlin_android.sh
4+
# Install gobley-uniffi-bindgen once for all Kotlin scripts
5+
echo "Installing gobley-uniffi-bindgen fork..."
6+
cargo install --git https://github.com/ovitrif/gobley.git \
7+
--branch fix-v0.2.0 gobley-uniffi-bindgen --force
8+
export BINDGEN_GOBLEY_INSTALLED=1
9+
10+
# Standardize on release-smaller for all targets
11+
export BINDGEN_PROFILE="release-smaller"
12+
13+
./scripts/uniffi_bindgen_generate.sh \
14+
&& ./scripts/swift_create_xcframework_archive.sh

scripts/uniffi_bindgen_generate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export CMAKE_IOS_DEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET
1313
unset SDKROOT
1414
unset BINDGEN_EXTRA_CLANG_ARGS
1515

16-
source ./scripts/uniffi_bindgen_generate_kotlin.sh || exit 1
1716
source ./scripts/uniffi_bindgen_generate_python.sh || exit 1
17+
source ./scripts/uniffi_bindgen_generate_kotlin.sh || exit 1
18+
source ./scripts/uniffi_bindgen_generate_kotlin_android.sh || exit 1
1819
source ./scripts/uniffi_bindgen_generate_swift.sh || exit 1
19-

scripts/uniffi_bindgen_generate_kotlin.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,34 @@ TARGET_DIR="target"
55
PROJECT_DIR="ldk-node-jvm"
66
JVM_LIB_DIR="$BINDINGS_DIR/$PROJECT_DIR"
77

8-
# Install gobley-uniffi-bindgen from fork with patched version
9-
echo "Installing gobley-uniffi-bindgen fork..."
10-
cargo install --git https://github.com/ovitrif/gobley.git --branch fix-v0.2.0 gobley-uniffi-bindgen --force
8+
# Install gobley-uniffi-bindgen from fork (skip if orchestrator already installed it)
9+
if [ -z "${BINDGEN_GOBLEY_INSTALLED:-}" ]; then
10+
echo "Installing gobley-uniffi-bindgen fork..."
11+
cargo install --git https://github.com/ovitrif/gobley.git --branch fix-v0.2.0 gobley-uniffi-bindgen --force
12+
fi
1113
UNIFFI_BINDGEN_BIN="gobley-uniffi-bindgen"
1214

1315
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
1416
echo "Building for Linux x86_64..."
1517
rustup target add x86_64-unknown-linux-gnu || exit 1
16-
cargo build --release --target x86_64-unknown-linux-gnu --features uniffi || exit 1
17-
DYNAMIC_LIB_PATH="$TARGET_DIR/x86_64-unknown-linux-gnu/release/libldk_node.so"
18+
cargo build --profile release-smaller --target x86_64-unknown-linux-gnu --features uniffi || exit 1
19+
DYNAMIC_LIB_PATH="$TARGET_DIR/x86_64-unknown-linux-gnu/release-smaller/libldk_node.so"
1820
RES_DIR="$JVM_LIB_DIR/lib/src/main/resources/linux-x86-64/"
1921
mkdir -p $RES_DIR || exit 1
2022
cp $DYNAMIC_LIB_PATH $RES_DIR || exit 1
2123
else
2224
echo "Building for macOS x86_64..."
2325
rustup target add x86_64-apple-darwin || exit 1
24-
cargo build --release --target x86_64-apple-darwin --features uniffi || exit 1
25-
DYNAMIC_LIB_PATH="$TARGET_DIR/x86_64-apple-darwin/release/libldk_node.dylib"
26+
cargo build --profile release-smaller --target x86_64-apple-darwin --features uniffi || exit 1
27+
DYNAMIC_LIB_PATH="$TARGET_DIR/x86_64-apple-darwin/release-smaller/libldk_node.dylib"
2628
RES_DIR="$JVM_LIB_DIR/lib/src/main/resources/darwin-x86-64/"
2729
mkdir -p $RES_DIR || exit 1
2830
cp $DYNAMIC_LIB_PATH $RES_DIR || exit 1
2931

3032
echo "Building for macOS aarch64..."
3133
rustup target add aarch64-apple-darwin || exit 1
32-
cargo build --release --target aarch64-apple-darwin --features uniffi || exit 1
33-
DYNAMIC_LIB_PATH_ARM="$TARGET_DIR/aarch64-apple-darwin/release/libldk_node.dylib"
34+
cargo build --profile release-smaller --target aarch64-apple-darwin --features uniffi || exit 1
35+
DYNAMIC_LIB_PATH_ARM="$TARGET_DIR/aarch64-apple-darwin/release-smaller/libldk_node.dylib"
3436
RES_DIR="$JVM_LIB_DIR/lib/src/main/resources/darwin-aarch64/"
3537
mkdir -p $RES_DIR || exit 1
3638
cp $DYNAMIC_LIB_PATH_ARM $RES_DIR || exit 1

scripts/uniffi_bindgen_generate_kotlin_android.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ TARGET_DIR="target"
55
PROJECT_DIR="ldk-node-android"
66
ANDROID_LIB_DIR="$BINDINGS_DIR/$PROJECT_DIR"
77

8-
# Install gobley-uniffi-bindgen from fork with patched version
9-
echo "Installing gobley-uniffi-bindgen fork..."
10-
cargo install --git https://github.com/ovitrif/gobley.git --branch fix-v0.2.0 gobley-uniffi-bindgen --force
8+
# Install gobley-uniffi-bindgen from fork (skip if orchestrator already installed it)
9+
if [ -z "${BINDGEN_GOBLEY_INSTALLED:-}" ]; then
10+
echo "Installing gobley-uniffi-bindgen fork..."
11+
cargo install --git https://github.com/ovitrif/gobley.git --branch fix-v0.2.0 gobley-uniffi-bindgen --force
12+
fi
1113
UNIFFI_BINDGEN_BIN="gobley-uniffi-bindgen"
1214

1315
export_variable_if_not_present() {

scripts/uniffi_bindgen_generate_swift.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ set -eox pipefail
44
BINDINGS_DIR="./bindings/swift"
55
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"
66

7-
cargo build --release || exit 1
8-
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language swift -o "$BINDINGS_DIR" || exit 1
9-
107
mkdir -p $BINDINGS_DIR
118

129
# Install rust target toolchains

0 commit comments

Comments
 (0)