kotlin cross-arch build

This commit is contained in:
Evan Feenstra
2022-07-07 11:05:29 -07:00
parent f91ced311b
commit 2b3946b014
6 changed files with 21 additions and 12 deletions

2
crypter-ffi/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
notes.md
src/crypter.uniffi.rs

View File

@@ -13,7 +13,6 @@ sphinx-key-crypter = { path = "../crypter" }
uniffi = "0.19.2" uniffi = "0.19.2"
hex = "0.4.3" hex = "0.4.3"
thiserror = "1.0.31" thiserror = "1.0.31"
uniffi_macros = "0.19.2"
[build-dependencies] [build-dependencies]
uniffi_build = "0.19.2" uniffi_build = "0.19.2"

12
crypter-ffi/build-kotlin.sh Executable file
View File

@@ -0,0 +1,12 @@
echo "=> creating kotlin bindings"
uniffi-bindgen generate src/crypter.udl --language kotlin
echo "=> creating C FFI scaffolding"
uniffi-bindgen scaffolding src/crypter.udl
echo "=> building i686-linux-android"
cross build --target i686-linux-android --release
echo "=> building aarch64-linux-android"
cross build --target aarch64-linux-android --release
echo "=> building armv7-linux-androideabi"
cross build --target armv7-linux-androideabi --release

View File

@@ -1,3 +0,0 @@
fn main() {
uniffi_build::generate_scaffolding("./src/crypter.udl").unwrap();
}

View File

@@ -2,22 +2,21 @@ uniffi-bindgen --version
should match the uniffi version in Cargo.toml should match the uniffi version in Cargo.toml
### build the C ffi
uniffi-bindgen scaffolding src/crypter.udl
### kotlin ### kotlin
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android x86_64-unknown-linux-gnu rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android x86_64-unknown-linux-gnu
uniffi-bindgen generate src/crypter.udl --language kotlin uniffi-bindgen generate src/crypter.udl --language kotlin
cargo build --target aarch64-linux-android --release cross build --target i686-linux-android --release
cargo build --target armv7-linux-androideabi --release
cargo build --target i686-linux-android --release
cross build --target aarch64-linux-android --release cross build --target aarch64-linux-android --release
cross build --target armv7-linux-androideabi --release
### swift ### swift
uniffi-bindgen generate src/crypter.udl --language swift uniffi-bindgen generate src/crypter.udl --language swift
### manually build the C ffi
uniffi-bindgen scaffolding src/crypter.udl

View File

@@ -3,7 +3,7 @@ mod parse;
use sphinx_key_crypter::chacha::{decrypt as chacha_decrypt, encrypt as chacha_encrypt}; use sphinx_key_crypter::chacha::{decrypt as chacha_decrypt, encrypt as chacha_encrypt};
use sphinx_key_crypter::ecdh::derive_shared_secret_from_slice; use sphinx_key_crypter::ecdh::derive_shared_secret_from_slice;
uniffi_macros::include_scaffolding!("crypter"); include!("crypter.uniffi.rs");
pub type Result<T> = std::result::Result<T, CrypterError>; pub type Result<T> = std::result::Result<T, CrypterError>;