Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/cdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
3 changes: 3 additions & 0 deletions crates/cdk-ffi/uniffi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
31 changes: 24 additions & 7 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -470,18 +471,34 @@ 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/"

# Generate Python bindings (shorthand)
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}}
Expand Down
Loading