From 2b9be4f30afd1e98020c3ce1c15c0dc320828de8 Mon Sep 17 00:00:00 2001 From: asmo Date: Mon, 22 Sep 2025 11:37:20 +0200 Subject: [PATCH 1/2] feat: added go ffi build --- crates/cdk-ffi/Cargo.toml | 2 +- crates/cdk-ffi/uniffi.toml | 3 +++ justfile | 31 ++++++++++++++++++++++++------- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/crates/cdk-ffi/Cargo.toml b/crates/cdk-ffi/Cargo.toml index ff61416ebf..e1f44ab216 100644 --- a/crates/cdk-ffi/Cargo.toml +++ b/crates/cdk-ffi/Cargo.toml @@ -30,7 +30,7 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["sync", "rt", "rt-multi-thread"] } -uniffi = { version = "0.29", features = ["cli", "tokio"] } +uniffi = { version = "0.28.3", features = ["cli", "tokio"] } url = { workspace = true } uuid = { workspace = true, features = ["v4"] } diff --git a/crates/cdk-ffi/uniffi.toml b/crates/cdk-ffi/uniffi.toml index 7b95d596a1..aa554f19ee 100644 --- a/crates/cdk-ffi/uniffi.toml +++ b/crates/cdk-ffi/uniffi.toml @@ -8,3 +8,6 @@ cdylib_name = "cdk_ffi" [bindings.swift] module_name = "CashuDevKit" cdylib_name = "cdk_ffi" + +[bindings.go] +go_mod = "github.com/cashubtc/cdk-go" diff --git a/justfile b/justfile index 2fe9d06dd0..e8e34e2f3f 100644 --- a/justfile +++ b/justfile @@ -437,11 +437,11 @@ ffi-generate LANGUAGE *ARGS="--release": ffi-build # Validate language case "$LANG" in - python|swift|kotlin) + python|swift|kotlin|go) ;; *) echo "❌ Unsupported language: $LANG" - echo "Supported languages: python, swift, kotlin" + echo "Supported languages: python, swift, kotlin, go" exit 1 ;; esac @@ -451,6 +451,7 @@ ffi-generate LANGUAGE *ARGS="--release": ffi-build python) EMOJI="🐍" ;; swift) EMOJI="🍎" ;; kotlin) EMOJI="🎯" ;; + go) EMOJI="🚀" ;; esac # Determine build type and library path @@ -465,11 +466,24 @@ ffi-generate LANGUAGE *ARGS="--release": ffi-build echo "$EMOJI Generating $LANG bindings..." mkdir -p target/bindings/$LANG - - cargo run --bin uniffi-bindgen generate \ - --library target/$BUILD_TYPE/libcdk_ffi.$LIB_EXT \ - --language $LANG \ - --out-dir target/bindings/$LANG + + + # Use uniffi-bindgen-go for Go, otherwise the standard uniffi-bindgen + if [[ "$LANG" == "go" ]]; then + if ! command -v uniffi-bindgen-go >/dev/null 2>&1; then + echo "⬇️ Installing uniffi-bindgen-go..." + cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.4.0+v0.28.3 + fi + uniffi-bindgen-go "target/$BUILD_TYPE/libcdk_ffi.$LIB_EXT" \ + --library \ + --out-dir "target/bindings/$LANG" + else + cargo run --bin uniffi-bindgen generate \ + --library "target/$BUILD_TYPE/libcdk_ffi.$LIB_EXT" \ + --language "$LANG" \ + --out-dir "target/bindings/$LANG" + fi + echo "✅ $LANG bindings generated in target/bindings/$LANG/" @@ -477,6 +491,9 @@ ffi-generate LANGUAGE *ARGS="--release": ffi-build ffi-generate-python *ARGS="--release": just ffi-generate python {{ARGS}} +ffi-generate-go *ARGS="--release": + just ffi-generate go {{ARGS}} + # Generate Swift bindings (shorthand) ffi-generate-swift *ARGS="--release": just ffi-generate swift {{ARGS}} From d616b4a79fcf35f6c0628ba2c1bedd42de89da06 Mon Sep 17 00:00:00 2001 From: asmo Date: Thu, 15 Jan 2026 10:27:41 +0100 Subject: [PATCH 2/2] using kegsays uniffi --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index 7d14779a77..fa03225a78 100644 --- a/justfile +++ b/justfile @@ -477,7 +477,7 @@ ffi-generate LANGUAGE *ARGS="--release": ffi-build if [[ "$LANG" == "go" ]]; then if ! command -v uniffi-bindgen-go >/dev/null 2>&1; then echo "⬇️ Installing uniffi-bindgen-go..." - cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.4.0+v0.28.3 + cargo install uniffi-bindgen-go --git https://github.com/kegsay/uniffi-bindgen-go --tag v0.4.0+v0.28.3 fi uniffi-bindgen-go "target/$BUILD_TYPE/libcdk_ffi.$LIB_EXT" \ --library \