Skip to content

Commit

Permalink
Add Go bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed May 2, 2024
1 parent 0aa699d commit dc252a0
Show file tree
Hide file tree
Showing 12 changed files with 592 additions and 106 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ jobs:
working-directory: lib/ls-sdk-bindings
run: cargo build

- name: Build golang bindings
working-directory: lib/ls-sdk-bindings
run: |
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0
uniffi-bindgen-go src/breez_liquid_sdk.udl -o ffi/golang -c ./uniffi.toml
cp ../target/debug/libbreez_liquid_sdk_bindings.so ffi/golang
cp -r ffi/golang/breez_liquid_sdk tests/bindings/golang/
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: '1.19.9'

- name: Setup python
uses: actions/setup-python@v4
with:
Expand Down
138 changes: 37 additions & 101 deletions lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ version = "0.0.1"
[workspace.dependencies]
anyhow = "1.0"
thiserror = "1.0"
uniffi = "0.27.1"
uniffi_macros = "0.27.1"
uniffi = "0.25.0"
uniffi_macros = "0.25.0"

[patch.crates-io]
# https://github.com/BlockstreamResearch/rust-secp256k1-zkp/pull/48/commits
Expand Down
14 changes: 14 additions & 0 deletions lib/ls-sdk-bindings/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ bindings-swift: ios-universal darwin-universal
rm bindings-swift/Sources/BreezLiquidSDK/breez_liquid_sdkFFI.h
rm bindings-swift/Sources/BreezLiquidSDK/breez_liquid_sdkFFI.modulemap

## Go
golang-darwin: darwin-universal
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0
uniffi-bindgen-go src/breez_liquid_sdk.udl -o ffi/golang -c ./uniffi.toml
cp ../target/darwin-universal/release/libbreez_liquid_sdk_bindings.dylib ffi/golang
cp -r ffi/golang/breez_liquid_sdk tests/bindings/golang/

golang-linux: $(SOURCES)
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0
cargo build --release --target $(TARGET)
uniffi-bindgen-go src/breez_liquid_sdk.udl -o ffi/golang -c ./uniffi.toml
cp ../target/$(TARGET)/release/libbreez_liquid_sdk_bindings.so ffi/golang
cp -r ffi/golang/breez_liquid_sdk tests/bindings/golang/

## Python
python-linux: $(SOURCES)
cargo build --release --target $(TARGET)
Expand Down
1 change: 1 addition & 0 deletions lib/ls-sdk-bindings/tests/bindings/golang/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
breez_liquid_sdk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <breez_liquid_sdk.h>

// This file exists beacause of
// https://github.com/golang/go/issues/11263

void cgo_rust_task_callback_bridge_breez_liquid_sdk(RustTaskCallback cb, const void * taskData, int8_t status) {
cb(taskData, status);
}
Loading

0 comments on commit dc252a0

Please sign in to comment.