Skip to content

Commit 49f7f59

Browse files
committed
WIP: Add binding generation to CI
1 parent f269d9f commit 49f7f59

File tree

4 files changed

+57
-14
lines changed

4 files changed

+57
-14
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,48 @@ jobs:
2222
profile: minimal
2323
- name: Build on Rust ${{ matrix.toolchain }}
2424
run: cargo build --verbose --color always
25-
- name: Check formatting
25+
- name: Check release build on Rust ${{ matrix.toolchain }}
26+
run: cargo check --release --verbose --color always
27+
- name: Check formatting on Rust ${{ matrix.toolchain }}
2628
if: matrix.check-fmt
2729
run: rustup component add rustfmt && cargo fmt --all -- --check
2830
- name: Test on Rust ${{ matrix.toolchain }}
2931
run: cargo test
32+
33+
# generate_bindings:
34+
# strategy:
35+
# matrix:
36+
# toolchain: [ stable ]
37+
# runs-on: ubuntu-latest
38+
# steps:
39+
# - name: Checkout source code
40+
# uses: actions/checkout@v2
41+
# - name: Install Rust ${{ matrix.toolchain }} toolchain
42+
# uses: actions-rs/toolchain@v1
43+
# with:
44+
# toolchain: ${{ matrix.toolchain }}
45+
# override: true
46+
# profile: minimal
47+
# - name: Generate language bindings
48+
# run: scripts/uniffi_bindgen_generate.sh
49+
# - name: Cache bitcoind binary
50+
# id: cache-bitcoind
51+
# uses: actions/cache@v3
52+
# with:
53+
# path: bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
54+
# key: bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
55+
# - name: Fetch Bitcoind
56+
# if: steps.cache-bitcoind.outputs.cache-hit != 'true'
57+
# run: |
58+
# curl --verbose -L -o ${BITCOIND_FILENAME} ${BITCOIND_URL}
59+
# echo "Sha sum: $(sha256sum ${BITCOIND_FILENAME} | awk '{ print $1 }')"
60+
# if [ "$(sha256sum $BITCOIND_FILENAME | awk '{ print $1 }')" != "${EXPECTED_BITCOIND_SHASUM}" ]; then
61+
# echo "Bad hash"
62+
# exit 1
63+
# fi
64+
# tar xvzf ${BITCOIND_FILENAME}
65+
# ./bitcoin-24.0.1/bin/bitcoind -regtest --fallbackfee=0.00001 &
66+
# env:
67+
# EXPECTED_BITCOIND_SHASUM: 49df6e444515d457ea0b885d66f521f2a26ca92ccf73d5296082e633544253bf
68+
# BITCOIND_URL: https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
69+
# BITCOIND_FILENAME: bitcoin-24.0.1-x86_64-linux-gnu.tar.gz

scripts/uniffi_bindgen_generate.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
source ./scripts/uniffi_bindgen_generate_kotlin.sh
3-
source ./scripts/uniffi_bindgen_generate_python.sh
4-
source ./scripts/uniffi_bindgen_generate_swift.sh
2+
source ./scripts/uniffi_bindgen_generate_kotlin.sh || exit 1
3+
source ./scripts/uniffi_bindgen_generate_python.sh || exit 1
4+
source ./scripts/uniffi_bindgen_generate_swift.sh || exit 1
55

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#!/bin/bash
2-
BINDINGS_DIR="./bindings/kotlin"
3-
TARGET_DIR="./target/bindings/kotlin"
2+
BINDINGS_DIR="bindings/kotlin"
3+
TARGET_DIR="target/bindings/kotlin"
44
PROJECT_DIR="ldk-node-jvm"
55
PACKAGE_DIR="org/lightningdevkit/ldknode"
66
UNIFFI_BINDGEN_BIN="cargo run --features=uniffi/cli --bin uniffi-bindgen"
77

8-
cargo build --target aarch64-apple-darwin
9-
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language kotlin -o "$TARGET_DIR"
8+
#rustup target add aarch64-apple-darwin
9+
#cargo build --target aarch64-apple-darwin || exit 1
10+
cargo build --release || exit 1
11+
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language kotlin -o "$TARGET_DIR" || exit 1
1012

11-
mkdir -p "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR"
12-
mkdir -p "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/resources/darwin-aarch64/
13+
mkdir -p "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR" || exit 1
14+
mkdir -p "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/resources/darwin-aarch64/ || exit 1
1315

14-
cp "$TARGET_DIR"/"$PACKAGE_DIR"/ldk_node.kt "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR"/
15-
cp ./target/aarch64-apple-darwin/debug/libldk_node.dylib "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/resources/darwin-aarch64/libldk_node.dylib
16+
cp "$TARGET_DIR"/"$PACKAGE_DIR"/ldk_node.kt "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/kotlin/"$PACKAGE_DIR"/ || exit 1
17+
#cp ./target/aarch64-apple-darwin/debug/libldk_node.dylib "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/resources/darwin-aarch64/libldk_node.dylib || exit 1
18+
cp target/release/libldk_node.dylib "$BINDINGS_DIR"/"$PROJECT_DIR"/lib/src/main/resources/libldk_node.dylib || exit 1

scripts/uniffi_bindgen_generate_swift.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
BINDINGS_DIR="./bindings/swift"
33
UNIFFI_BINDGEN_BIN="cargo run --features=uniffi/cli --bin uniffi-bindgen"
44

5-
cargo build --release
6-
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language swift -o "$BINDINGS_DIR"
5+
cargo build --release || exit 1
6+
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language swift -o "$BINDINGS_DIR" || exit 1
77

88
mkdir -p $BINDINGS_DIR
99

0 commit comments

Comments
 (0)