Skip to content

Commit

Permalink
ffi: add uniffi-bindgen binary
Browse files Browse the repository at this point in the history
* Remove `uniffi-bindgen` crate

Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 19, 2024
1 parent 5462338 commit 0fa5bd8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ members = [
"bindings/nostr-sdk-ffi",
"bindings/nostr-sdk-flutter/rust",
"bindings/nostr-sdk-js",
"bindings/uniffi-bindgen",
"crates/*",
]
exclude = [
Expand Down Expand Up @@ -44,7 +43,6 @@ thiserror = "1.0"
tokio = { version = ">=1.37", default-features = false }
tracing = { version = "0.1", default-features = false }
tracing-subscriber = "0.3"
uniffi = "=0.28.0" # v0.28.1 causes issues when checking MSRV
wasm-bindgen = { version = "0.2", default-features = false }
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", default-features = false }
Expand Down
8 changes: 6 additions & 2 deletions bindings/nostr-sdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ publish = false
name = "nostr_sdk_ffi"
crate-type = ["lib", "cdylib", "staticlib"]

[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[features]
default = ["lmdb"]
lmdb = ["nostr-sdk/lmdb"]
Expand All @@ -21,10 +25,10 @@ nostr-relay-builder.workspace = true
nostr-sdk = { workspace = true, default-features = false, features = ["all-nips", "tor"] }
tracing = { workspace = true, features = ["std"] }
tracing-subscriber.workspace = true
uniffi = { workspace = true, features = ["tokio"] }
uniffi = { version = "=0.28.0", features = ["cli", "tokio"] } # cli feature is required for the `uniffi-bindgen` binary

[target.'cfg(target_os = "android")'.dependencies]
paranoid-android = "0.2"

[dev-dependencies]
uniffi = { workspace = true, features = ["bindgen-tests"] }
uniffi = { version = "=0.28.0", features = ["bindgen-tests"] }
10 changes: 5 additions & 5 deletions bindings/nostr-sdk-ffi/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ x86_64-linux-android: ndk
android: aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android

kotlin: clean-android android
cargo run -p uniffi-bindgen generate --library ../../target/x86_64-linux-android/release/libnostr_sdk_ffi.so --language kotlin --no-format -o ffi/kotlin
cargo run --bin uniffi-bindgen generate --library ../../target/x86_64-linux-android/release/libnostr_sdk_ffi.so --language kotlin --no-format -o ffi/kotlin

# Copy required modules and libs and assemble AAR
[private]
Expand Down Expand Up @@ -99,7 +99,7 @@ darwin-universal: swift-deps
[private]
assemble-swift-package:
mkdir -p swift/Sources/NostrSDK
cargo run -p uniffi-bindgen generate --library ../../target/aarch64-apple-ios/release/libnostr_sdk_ffi.a --no-format --language swift --out-dir swift/Sources/NostrSDK
cargo run --bin uniffi-bindgen generate --library ../../target/aarch64-apple-ios/release/libnostr_sdk_ffi.a --no-format --language swift --out-dir swift/Sources/NostrSDK
mv swift/Sources/NostrSDK/nostr_sdk.swift swift/Sources/NostrSDK/NostrSDK.swift
cp swift/Sources/NostrSDK/*.h swift/nostr_sdkFFI.xcframework/ios-arm64/Headers
cp swift/Sources/NostrSDK/*.h swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/Headers
Expand All @@ -118,7 +118,7 @@ python:
rm -rf python/dist
pip install -r python/requirements.txt
cargo build --release
cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.so --language python --no-format -o python/src/nostr-sdk/
cargo run --bin uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.so --language python --no-format -o python/src/nostr-sdk/
cp ../../target/release/libnostr_sdk_ffi.so python/src/nostr-sdk/
cd python && python setup.py bdist_wheel
pip install ./python/dist/nostr_sdk*.whl --force-reinstall
Expand All @@ -128,7 +128,7 @@ python:
rm -rf python/dist
pip install -r python/requirements.txt
cargo build --release
cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.dylib --language python --no-format -o python/src/nostr-sdk/
cargo run --bin uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.dylib --language python --no-format -o python/src/nostr-sdk/
cp ../../target/release/libnostr_sdk_ffi.dylib python/src/nostr-sdk/
cd python && python setup.py bdist_wheel
pip install ./python/dist/nostr_sdk*.whl --force-reinstall
Expand All @@ -137,7 +137,7 @@ python:
python:
pip install -r python\requirements.txt
cargo build --release
cargo run -p uniffi-bindgen generate --library ..\..\target\release\nostr_sdk_ffi.dll --language python --no-format -o python\src\nostr-sdk\
cargo run --bin uniffi-bindgen generate --library ..\..\target\release\nostr_sdk_ffi.dll --language python --no-format -o python\src\nostr-sdk\
copy ..\..\target\release\nostr_sdk_ffi.dll python\src\nostr-sdk
del /F /Q python\dist\* 2>nul || exit /b 0
cd python && python setup.py bdist_wheel
Expand Down
File renamed without changes.
8 changes: 0 additions & 8 deletions bindings/uniffi-bindgen/Cargo.toml

This file was deleted.

0 comments on commit 0fa5bd8

Please sign in to comment.