diff --git a/crates/cdk-ffi/Cargo.toml b/crates/cdk-ffi/Cargo.toml index dd9758b8bf..8b78f642ae 100644 --- a/crates/cdk-ffi/Cargo.toml +++ b/crates/cdk-ffi/Cargo.toml @@ -25,7 +25,7 @@ serde = { workspace = true, features = ["derive", "rc"] } 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 31cb7cb44a..fbeb187c3c 100644 --- a/crates/cdk-ffi/uniffi.toml +++ b/crates/cdk-ffi/uniffi.toml @@ -10,3 +10,6 @@ module_name = "CashuDevKit" cdylib_name = "cdk_ffi" generate_codable_conformance = true generate_immutable_records = true + +[bindings.go] +go_mod = "github.com/cashubtc/cdk-go" diff --git a/justfile b/justfile index 22d93fd14b..fa03225a78 100644 --- a/justfile +++ b/justfile @@ -442,11 +442,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 @@ -456,6 +456,7 @@ ffi-generate LANGUAGE *ARGS="--release": ffi-build python) EMOJI="🐍" ;; swift) EMOJI="🍎" ;; kotlin) EMOJI="🎯" ;; + go) EMOJI="🚀" ;; esac # Determine build type and library path @@ -470,11 +471,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/kegsay/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/" @@ -482,6 +496,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}}