Sfoglia il codice sorgente

feat: added go ffi build

asmo 4 mesi fa
parent
commit
2b9be4f30a
3 ha cambiato i file con 28 aggiunte e 8 eliminazioni
  1. 1 1
      crates/cdk-ffi/Cargo.toml
  2. 3 0
      crates/cdk-ffi/uniffi.toml
  3. 24 7
      justfile

+ 1 - 1
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"] }
 

+ 3 - 0
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"

+ 24 - 7
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}}