Skip to content

Commit

Permalink
Merge pull request #3 from getAlby/downgrade-uniffi
Browse files Browse the repository at this point in the history
Add the Go bindings build script
  • Loading branch information
rolznz authored Mar 3, 2024
2 parents 728bf76 + 37cf3f7 commit 854d5f4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/uniffi_bindgen_generate_go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e

if ! command -v cross &> /dev/null; then
echo "cross-rs is required to build bindings. Install it by running:"
echo " cargo install cross --git https://github.com/cross-rs/cross"
exit 1
fi

uniffi-bindgen-go bindings/ldk_node.udl -o ffi/golang -c ./uniffi.toml

build_lib() {
local TOOL=$1
local TARGET=$2
local OUTPUT_FILE=$3

$TOOL build --release --target $TARGET --features uniffi || exit 1
mkdir -p "ffi/golang/ldk_node/$TARGET" || exit 1
cp "target/$TARGET/release/$OUTPUT_FILE" "ffi/golang/ldk_node/$TARGET/" || exit 1
}

is_target_installed() {
local TARGET=$1
rustup target list --installed | grep -q $TARGET
}

# If we're running on macOS, build the macOS library using the host compiler.
# Cross compilation is not supported (needs more complex setup).
if [[ "$OSTYPE" == "darwin"* ]]; then
build_lib "cargo" "aarch64-apple-darwin" "libldk_node.dylib"
fi

build_lib "cross" "x86_64-unknown-linux-gnu" "libldk_node.so"
build_lib "cross" "x86_64-pc-windows-gnu" "ldk_node.dll"

0 comments on commit 854d5f4

Please sign in to comment.