Upgrade to latest uniffi (0.23.0) (#7)
* Upgrade to latest uniffi (0.23.0) * upgrade gradle and simplify android ci
This commit is contained in:
parent
987cc3f8a5
commit
2087e90861
|
@ -33,17 +33,12 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
lfs: true
|
lfs: true
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: 11
|
java-version: '17'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
# Reference: https://github.com/mozilla/rust-android-gradle/blob/master/.github/workflows/check.yml
|
# Reference: https://github.com/mozilla/rust-android-gradle/blob/master/.github/workflows/check.yml
|
||||||
- name: Setup Android SDK
|
|
||||||
uses: android-actions/setup-android@v2
|
|
||||||
- uses: nttld/setup-ndk@v1
|
|
||||||
with:
|
|
||||||
ndk-version: r21e
|
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
# Reference: https://github.com/rust-windowing/android-ndk-rs/blob/master/.github/workflows/rust.yml
|
# Reference: https://github.com/rust-windowing/android-ndk-rs/blob/master/.github/workflows/rust.yml
|
||||||
with:
|
with:
|
||||||
|
@ -54,8 +49,5 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
make prepare-android
|
make prepare-android
|
||||||
- name: "Build Android library"
|
- name: "Build Android library"
|
||||||
env:
|
run: make android
|
||||||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
working-directory: hello
|
||||||
run: |
|
|
||||||
cd hello
|
|
||||||
make android
|
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -3,7 +3,6 @@ prepare-apple:
|
||||||
rustup toolchain install nightly
|
rustup toolchain install nightly
|
||||||
rustup target add aarch64-apple-ios-sim --toolchain nightly && rustup target add aarch64-apple-ios x86_64-apple-ios
|
rustup target add aarch64-apple-ios-sim --toolchain nightly && rustup target add aarch64-apple-ios x86_64-apple-ios
|
||||||
rustup component add rust-src --toolchain nightly
|
rustup component add rust-src --toolchain nightly
|
||||||
make install-uniffi-bindgen
|
|
||||||
|
|
||||||
prepare-android:
|
prepare-android:
|
||||||
rustup toolchain install stable
|
rustup toolchain install stable
|
||||||
|
@ -12,7 +11,3 @@ prepare-android:
|
||||||
rustup target add aarch64-linux-android
|
rustup target add aarch64-linux-android
|
||||||
rustup target add armv7-linux-androideabi
|
rustup target add armv7-linux-androideabi
|
||||||
rustup target add i686-linux-android
|
rustup target add i686-linux-android
|
||||||
make install-uniffi-bindgen
|
|
||||||
|
|
||||||
install-uniffi-bindgen:
|
|
||||||
cargo install uniffi_bindgen --version 0.17.0
|
|
|
@ -17,7 +17,7 @@ Please read <https://www.rust-lang.org/tools/install>.
|
||||||
|
|
||||||
### iOS
|
### iOS
|
||||||
|
|
||||||
1. Latest Xcode (13.x)
|
1. Latest Xcode (14.3)
|
||||||
1. Rust toolchains for iOS: `make prepare-apple` or `rustup target add aarch64-apple-ios-sim --toolchain nightly && rustup target add aarch64-apple-ios x86_64-apple-ios`. Check installaion:
|
1. Rust toolchains for iOS: `make prepare-apple` or `rustup target add aarch64-apple-ios-sim --toolchain nightly && rustup target add aarch64-apple-ios x86_64-apple-ios`. Check installaion:
|
||||||
```shell
|
```shell
|
||||||
$ rustup target list --installed | grep ios
|
$ rustup target list --installed | grep ios
|
||||||
|
|
|
@ -8,14 +8,18 @@ version = "0.1.0"
|
||||||
crate-type = ["staticlib", "cdylib"]
|
crate-type = ["staticlib", "cdylib"]
|
||||||
name = "hello"
|
name = "hello"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "uniffi-bindgen"
|
||||||
|
path = "bin/uniffi-bindgen.rs"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uniffi = "0.22.0"
|
uniffi = "0.23.0"
|
||||||
uniffi_macros = "0.22.0"
|
uniffi_macros = "0.23.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
uniffi_build = "0.22.0"
|
uniffi = { version = "0.23.0", features = [ "build" ] }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
|
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
|
||||||
|
|
|
@ -8,18 +8,18 @@ apple:
|
||||||
@make cp-xcframeowrk-source
|
@make cp-xcframeowrk-source
|
||||||
|
|
||||||
build-targets:
|
build-targets:
|
||||||
cargo build --release --target x86_64-apple-ios
|
cargo build --lib --release --target x86_64-apple-ios
|
||||||
cargo +nightly build --release --target aarch64-apple-ios-sim
|
cargo +nightly build --lib --release --target aarch64-apple-ios-sim
|
||||||
cargo +nightly build -Z build-std --release --target aarch64-apple-ios-macabi
|
cargo +nightly build -Z build-std --lib --release --target aarch64-apple-ios-macabi
|
||||||
cargo +nightly build -Z build-std --release --target x86_64-apple-ios-macabi
|
cargo +nightly build -Z build-std --lib --release --target x86_64-apple-ios-macabi
|
||||||
cargo build --release --target aarch64-apple-ios
|
cargo build --lib --release --target aarch64-apple-ios
|
||||||
|
|
||||||
bindgen-swift:
|
bindgen-swift:
|
||||||
uniffi-bindgen generate src/hello.udl --language swift
|
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/hello.udl --language swift
|
||||||
sed -i '' 's/module\ HelloFFI/framework\ module\ HelloFFI/' src/HelloFFI.modulemap
|
sed -i '' 's/module\ HelloFFI/framework\ module\ HelloFFI/' src/HelloFFI.modulemap
|
||||||
|
|
||||||
bindgen-kotlin:
|
bindgen-kotlin:
|
||||||
uniffi-bindgen generate src/hello.udl --language kotlin -o platforms/android/UniffiRustExample/app/src/main/java
|
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/hello.udl --language kotlin -o platforms/android/UniffiRustExample/app/src/main/java
|
||||||
sed -i '' 's/return "uniffi_Hello"/return "hello"/' platforms/android/UniffiRustExample/app/src/main/java/uniffi/Hello/Hello.kt
|
sed -i '' 's/return "uniffi_Hello"/return "hello"/' platforms/android/UniffiRustExample/app/src/main/java/uniffi/Hello/Hello.kt
|
||||||
|
|
||||||
assemble-frameworks:
|
assemble-frameworks:
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
uniffi::uniffi_bindgen_main()
|
||||||
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
uniffi_build::generate_scaffolding("./src/hello.udl").unwrap();
|
uniffi::generate_scaffolding("./src/hello.udl").unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,12 @@ cargo {
|
||||||
module = "../../../.." // Or whatever directory contains your Cargo.toml
|
module = "../../../.." // Or whatever directory contains your Cargo.toml
|
||||||
libname = "hello" // Or whatever matches Cargo.toml's [package] name.
|
libname = "hello" // Or whatever matches Cargo.toml's [package] name.
|
||||||
targets = ["arm", "x86", "x86_64", "arm64"]
|
targets = ["arm", "x86", "x86_64", "arm64"]
|
||||||
|
extraCargoBuildArguments = ["--lib"]
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 31
|
compileSdk 31
|
||||||
// ndkVersion rootProject.ext.ndkVersion
|
ndkVersion "25.2.9519653"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.demo.mobile.uniffirustexample"
|
applicationId "com.demo.mobile.uniffirustexample"
|
||||||
|
@ -42,6 +43,7 @@ android {
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
}
|
}
|
||||||
|
namespace 'com.example.mobile.demo.uniffirustexample'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
package="com.example.mobile.demo.uniffirustexample">
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
|
@ -8,9 +8,9 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application' version '7.1.2' apply false
|
id 'com.android.application' version '8.0.2' apply false
|
||||||
id 'com.android.library' version '7.1.2' apply false
|
id 'com.android.library' version '8.0.2' apply false
|
||||||
id 'org.jetbrains.kotlin.android' version '1.5.30' apply false
|
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
|
||||||
id "org.mozilla.rust-android-gradle.rust-android" version "0.9.2"
|
id "org.mozilla.rust-android-gradle.rust-android" version "0.9.2"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,6 @@ kotlin.code.style=official
|
||||||
# Enables namespacing of each library's R class so that its R class includes only the
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
# resources declared in the library itself and none from the library's dependencies,
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
# thereby reducing the size of the R class for that library
|
# thereby reducing the size of the R class for that library
|
||||||
android.nonTransitiveRClass=true
|
android.nonTransitiveRClass=true
|
||||||
|
android.defaults.buildfeatures.buildconfig=true
|
||||||
|
android.nonFinalResIds=false
|
|
@ -1,6 +1,6 @@
|
||||||
#Mon Mar 07 11:58:42 CST 2022
|
#Mon Mar 07 11:58:42 CST 2022
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
@ -21,7 +21,7 @@ let package = Package(
|
||||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||||
.target(
|
.target(
|
||||||
name: "Hello",
|
name: "Hello",
|
||||||
dependencies: []
|
dependencies: ["HelloFFI"]
|
||||||
),
|
),
|
||||||
.binaryTarget(name: "HelloFFI", path: "Sources/HelloFFI.xcframework"),
|
.binaryTarget(name: "HelloFFI", path: "Sources/HelloFFI.xcframework"),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
|
|
Loading…
Reference in New Issue