diff --git a/bindings/apple/build_crypto_xcframework.sh b/bindings/apple/build_crypto_xcframework.sh index 10c7818de..66928bc08 100755 --- a/bindings/apple/build_crypto_xcframework.sh +++ b/bindings/apple/build_crypto_xcframework.sh @@ -54,20 +54,19 @@ lipo -create \ -output "${GENERATED_DIR}/simulator/libmatrix_sdk_crypto_ffi.a" # Generate uniffi files -cargo uniffi-bindgen generate \ +cd ../matrix-sdk-crypto-ffi && cargo run --bin matrix_sdk_crypto_ffi generate \ --language swift \ - --lib-file "${TARGET_DIR}/aarch64-apple-ios-sim/${REL_TYPE_DIR}/libmatrix_sdk_crypto_ffi.a" \ - --config "${SRC_ROOT}/bindings/${TARGET_CRATE}/uniffi.toml" \ + --library "${TARGET_DIR}/aarch64-apple-ios-sim/${REL_TYPE_DIR}/libmatrix_sdk_crypto_ffi.a" \ --out-dir ${GENERATED_DIR} \ - "${SRC_ROOT}/bindings/${TARGET_CRATE}/src/olm.udl" # Move headers to the right place HEADERS_DIR=${GENERATED_DIR}/headers mkdir -p ${HEADERS_DIR} mv ${GENERATED_DIR}/*.h ${HEADERS_DIR} -# Rename and move modulemap to the right place -mv ${GENERATED_DIR}/*.modulemap ${HEADERS_DIR}/module.modulemap +# Rename and merge the modulemap files into a single file to the right place +for f in ${GENERATED_DIR}/*.modulemap; do cat $f; echo; done > ${HEADERS_DIR}/module.modulemap +rm ${GENERATED_DIR}/*.modulemap # Move source files to the right place SWIFT_DIR="${GENERATED_DIR}/Sources" diff --git a/bindings/matrix-sdk-crypto-ffi/Cargo.toml b/bindings/matrix-sdk-crypto-ffi/Cargo.toml index 70aefacde..da4870270 100644 --- a/bindings/matrix-sdk-crypto-ffi/Cargo.toml +++ b/bindings/matrix-sdk-crypto-ffi/Cargo.toml @@ -12,6 +12,10 @@ publish = false [lib] crate-type = ["cdylib", "staticlib"] +[[bin]] +name = "matrix_sdk_crypto_ffi" +path = "uniffi-bindgen.rs" + [features] default = ["bundled-sqlite"] bundled-sqlite = ["matrix-sdk-sqlite/bundled"] @@ -31,7 +35,7 @@ sha2 = { workspace = true } thiserror = { workspace = true } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } # keep in sync with uniffi dependency in matrix-sdk-ffi, and uniffi_bindgen in ffi CI job -uniffi = { workspace = true } +uniffi = { workspace = true , features = ["cli"]} vodozemac = { workspace = true } zeroize = { workspace = true, features = ["zeroize_derive"] } @@ -54,6 +58,7 @@ features = ["rt-multi-thread"] [build-dependencies] vergen = { version = "8.2.5", features = ["build", "git", "gitcl"] } +uniffi = { workspace = true, features = ["build"] } [dev-dependencies] tempfile = "3.8.0" diff --git a/bindings/matrix-sdk-crypto-ffi/uniffi-bindgen.rs b/bindings/matrix-sdk-crypto-ffi/uniffi-bindgen.rs new file mode 100644 index 000000000..145309ad2 --- /dev/null +++ b/bindings/matrix-sdk-crypto-ffi/uniffi-bindgen.rs @@ -0,0 +1,4 @@ + +fn main() { + uniffi::uniffi_bindgen_main() +} \ No newline at end of file