Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Better integration of custom ORT builds

laurenspriem35a48af5f773
diff --git a/mobile/apps/photos/android/app/build.gradle b/mobile/apps/photos/android/app/build.gradle
index d544b4c245..8c224a2429 100644
--- a/mobile/apps/photos/android/app/build.gradle
+++ b/mobile/apps/photos/android/app/build.gradle
@@ -29,26 +29,24 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
-// The pinned custom ONNX Runtime release is defined once in
-// mobile/native/onnxruntime/version.properties.
-def onnxRuntimeVersionFile = file('../../../../native/onnxruntime/version.properties')
-def onnxRuntimeVersions = new Properties()
-onnxRuntimeVersionFile.withInputStream { onnxRuntimeVersions.load(it) }
-def onnxRuntimeAar = new File(
- gradle.gradleUserHomeDir,
- "caches/io.ente/onnxruntime/${onnxRuntimeVersions.getProperty('ortRelease')}/" +
- onnxRuntimeVersions.getProperty('ortAndroidAsset'),
-)
-def prepareOnnxRuntimeAndroid = tasks.register('prepareOnnxRuntimeAndroid', Exec) {
- def prepareScript = file('../../../../native/onnxruntime/prepare-android.sh')
- inputs.file(prepareScript)
- inputs.file(onnxRuntimeVersionFile)
- outputs.file(onnxRuntimeAar)
- outputs.upToDateWhen { false }
- commandLine 'sh', prepareScript, onnxRuntimeAar
+// Ente's custom prebuilt ONNX Runtime AAR is resolved straight from its
+// GitHub release through an Ivy repository; its SHA-256 is pinned in
+// gradle/verification-metadata.xml. See mobile/native/onnxruntime/README.md.
+repositories {
+ exclusiveContent {
+ forRepository {
+ ivy {
+ name = 'enteOnnxRuntimePackaging'
+ url = 'https://github.com/laurens-pilot/ort-packaging/releases/download'
+ patternLayout {
+ artifact 'ort-[revision]/[artifact]-[revision].[ext]'
+ }
+ metadataSources { artifact() }
+ }
+ }
+ filter { includeGroup 'io.ente.onnxruntime' }
+ }
}
-def onnxRuntimeFiles = files(onnxRuntimeAar)
-onnxRuntimeFiles.builtBy(prepareOnnxRuntimeAndroid)
configurations.configureEach {
// mobile_ocr also declares Microsoft's stock AAR. The custom AAR exposes
@@ -202,7 +200,7 @@ dependencies {
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
// Custom WebGPU/XNNPACK build required by Rust ML, which dynamically
// loads libonnxruntime.so.
- implementation(onnxRuntimeFiles)
+ implementation 'io.ente.onnxruntime:onnxruntime-webgpu-android:1.27.0-r2@aar'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
diff --git a/mobile/apps/photos/android/gradle/verification-metadata.xml b/mobile/apps/photos/android/gradle/verification-metadata.xml
new file mode 100644
index 0000000000..ba604aa2fb
--- /dev/null
+++ b/mobile/apps/photos/android/gradle/verification-metadata.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Gradle dependency verification.
+
+ Every artifact is deliberately trusted except Ente's custom ONNX Runtime
+ binaries: those are fetched from a plain GitHub release (no repository
+ metadata), so their SHA-256 digests are pinned here. The digests come from
+ the SHA256SUMS asset published with the ort-packaging release.
+
+ See mobile/native/onnxruntime/README.md for the release bump checklist.
+-->
+<verification-metadata xmlns="https://schema.gradle.org/dependency-verification"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="https://schema.gradle.org/dependency-verification https://schema.gradle.org/dependency-verification/dependency-verification-1.3.xsd">
+ <configuration>
+ <verify-metadata>false</verify-metadata>
+ <verify-signatures>false</verify-signatures>
+ <trusted-artifacts>
+ <trust group="^(?!io\.ente\.onnxruntime$).*$" regex="true"/>
+ </trusted-artifacts>
+ </configuration>
+ <components>
+ <component group="io.ente.onnxruntime" name="onnxruntime-webgpu-android" version="1.27.0-r2">
+ <artifact name="onnxruntime-webgpu-android-1.27.0-r2.aar">
+ <sha256 value="0752f9b026df55780602cf482d9acddbe662d21383a2530d6e8c3d34a1ca8090"/>
+ </artifact>
+ </component>
+ </components>
+</verification-metadata>
diff --git a/mobile/apps/photos/ios/Podfile b/mobile/apps/photos/ios/Podfile
index 650a58b824..44c98ef96c 100644
--- a/mobile/apps/photos/ios/Podfile
+++ b/mobile/apps/photos/ios/Podfile
@@ -33,6 +33,11 @@ target 'Runner' do
use_frameworks!
use_modular_headers!
+ # Ente's custom prebuilt ONNX Runtime static libraries (download + SHA-256
+ # verification handled by CocoaPods). Consumed by the ente_photos_rust
+ # build phase, which points the Rust `ort` crate at the platform slice.
+ pod 'EnteOnnxRuntime', :podspec => '../../../native/onnxruntime/EnteOnnxRuntime.podspec'
+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'ShareExtension' do
diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lock
index 0a29ad64ed..f9f78657d0 100644
--- a/mobile/apps/photos/ios/Podfile.lock
+++ b/mobile/apps/photos/ios/Podfile.lock
@@ -24,6 +24,7 @@ PODS:
- Flutter
- ente_screen_cover (0.0.1):
- Flutter
+ - EnteOnnxRuntime (1.27.0-r2)
- ffmpeg_kit_custom (6.0.3)
- ffmpeg_kit_flutter (6.0.3):
- ffmpeg_kit_custom
@@ -262,6 +263,7 @@ DEPENDENCIES:
- ente_qr (from `.symlinks/plugins/ente_qr/ios`)
- ente_rust (from `.symlinks/plugins/ente_rust/ios`)
- ente_screen_cover (from `.symlinks/plugins/ente_screen_cover/ios`)
+ - EnteOnnxRuntime (from `../../../native/onnxruntime/EnteOnnxRuntime.podspec`)
- ffmpeg_kit_flutter (from `.symlinks/plugins/ffmpeg_kit_flutter/ios`)
- file_saver (from `.symlinks/plugins/file_saver/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
@@ -358,6 +360,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/ente_rust/ios"
ente_screen_cover:
:path: ".symlinks/plugins/ente_screen_cover/ios"
+ EnteOnnxRuntime:
+ :podspec: "../../../native/onnxruntime/EnteOnnxRuntime.podspec"
ffmpeg_kit_flutter:
:path: ".symlinks/plugins/ffmpeg_kit_flutter/ios"
file_saver:
@@ -466,10 +470,11 @@ SPEC CHECKSUMS:
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
cupertino_http: 94ac07f5ff090b8effa6c5e2c47871d48ab7c86c
device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe
- ente_photos_rust: 740b0d5775f04a70cf5463316d20abd39cadb02a
+ ente_photos_rust: 380a324fc22445a1281e206726ccddd86582ad28
ente_qr: 86beaf5d2644705db9b565b32dd8b82c05fb36af
ente_rust: d0197ebd5460e8f67576579452b073d698404abe
ente_screen_cover: 6792566774f1c83939f9c1d03ed0a1f1ded45ae4
+ EnteOnnxRuntime: e8d3561a618fd03bf46e2e6c9219967b52487bef
ffmpeg_kit_custom: 682b4f2f1ff1f8abae5a92f6c3540f2441d5be99
ffmpeg_kit_flutter: 915b345acc97d4142e8a9a8549d177ff10f043f5
file_saver: 6cdbcddd690cb02b0c1a0c225b37cd805c2bf8b6
@@ -537,6 +542,6 @@ SPEC CHECKSUMS:
wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556
workmanager_apple: 904529ae31e97fc5be632cf628507652294a0778
-PODFILE CHECKSUM: 980a2602621422bdfd82e34ef370d44ddd600fad
+PODFILE CHECKSUM: 7af4c0a38ff14aa9b6ef0b1309156a8d783a20c6
COCOAPODS: 1.16.2
diff --git a/mobile/apps/photos/rust_builder/cargokit/build_pod.sh b/mobile/apps/photos/rust_builder/cargokit/build_pod.sh
index 9a360d7342..3714ee190d 100755
--- a/mobile/apps/photos/rust_builder/cargokit/build_pod.sh
+++ b/mobile/apps/photos/rust_builder/cargokit/build_pod.sh
@@ -35,19 +35,6 @@ export CARGOKIT_TOOL_TEMP_DIR=$TARGET_TEMP_DIR/build_tool
# Directory inside root project. Not necessarily the top level directory of root project.
export CARGOKIT_ROOT_PROJECT_DIR=$SRCROOT
-case "$PLATFORM_NAME" in
- iphoneos|iphonesimulator)
- ONNXRUNTIME_CACHE_DIR=${ENTE_ORT_CACHE_DIR:-$HOME/Library/Caches/io.ente/onnxruntime}
- ORT_LIB_PATH=$(
- sh "$BASEDIR/../../../../native/onnxruntime/prepare-ios.sh" \
- "$ONNXRUNTIME_CACHE_DIR" \
- "$PLATFORM_NAME"
- )
- export ORT_LIB_PATH
- unset ORT_IOS_XCFWK_PATH ORT_IOS_XCFWK_LOCATION
- ;;
-esac
-
FLUTTER_EXPORT_BUILD_ENVIRONMENT=(
"$PODS_ROOT/../Flutter/ephemeral/flutter_export_environment.sh" # macOS
"$PODS_ROOT/../Flutter/flutter_export_environment.sh" # iOS
diff --git a/mobile/apps/photos/rust_builder/ios/ente_photos_rust.podspec b/mobile/apps/photos/rust_builder/ios/ente_photos_rust.podspec
index 41bdcd0d21..14611c84cf 100644
--- a/mobile/apps/photos/rust_builder/ios/ente_photos_rust.podspec
+++ b/mobile/apps/photos/rust_builder/ios/ente_photos_rust.podspec
@@ -29,8 +29,26 @@ A new Flutter FFI plugin project.
s.script_phase = {
:name => 'Build Rust library',
- # First argument is relative path to the `rust` folder, second is name of rust library
- :script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../../../../../rust/bindings/frb/photos ente_photos_rust',
+ # Point the Rust `ort` crate at the custom prebuilt ONNX Runtime static
+ # archive for the active platform (downloaded and SHA-256 verified by
+ # CocoaPods as the EnteOnnxRuntime pod), then run the Cargokit build.
+ # The build_pod.sh arguments are the relative path to the `rust` folder
+ # and the name of the Rust library.
+ :script => <<-SCRIPT,
+ set -e
+ case "$PLATFORM_NAME" in
+ iphoneos) ort_slice=ios-arm64 ;;
+ iphonesimulator) ort_slice=ios-arm64-simulator ;;
+ *) echo "error: unsupported platform for ONNX Runtime: $PLATFORM_NAME" >&2; exit 1 ;;
+ esac
+ export ORT_LIB_PATH="$PODS_ROOT/EnteOnnxRuntime/static-lib/$ort_slice"
+ if [ ! -f "$ORT_LIB_PATH/libonnxruntime.a" ]; then
+ echo "error: $ORT_LIB_PATH/libonnxruntime.a is missing; run 'pod install'" >&2
+ exit 1
+ fi
+ unset ORT_IOS_XCFWK_PATH ORT_IOS_XCFWK_LOCATION
+ sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../../../../../rust/bindings/frb/photos ente_photos_rust
+ SCRIPT
:execution_position => :before_compile,
:input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'],
# Let Xcode know that the static library linked below is created by this
diff --git a/mobile/native/android/apps/ensu/gradle/verification-metadata.xml b/mobile/native/android/apps/ensu/gradle/verification-metadata.xml
new file mode 100644
index 0000000000..ba604aa2fb
--- /dev/null
+++ b/mobile/native/android/apps/ensu/gradle/verification-metadata.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Gradle dependency verification.
+
+ Every artifact is deliberately trusted except Ente's custom ONNX Runtime
+ binaries: those are fetched from a plain GitHub release (no repository
+ metadata), so their SHA-256 digests are pinned here. The digests come from
+ the SHA256SUMS asset published with the ort-packaging release.
+
+ See mobile/native/onnxruntime/README.md for the release bump checklist.
+-->
+<verification-metadata xmlns="https://schema.gradle.org/dependency-verification"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="https://schema.gradle.org/dependency-verification https://schema.gradle.org/dependency-verification/dependency-verification-1.3.xsd">
+ <configuration>
+ <verify-metadata>false</verify-metadata>
+ <verify-signatures>false</verify-signatures>
+ <trusted-artifacts>
+ <trust group="^(?!io\.ente\.onnxruntime$).*$" regex="true"/>
+ </trusted-artifacts>
+ </configuration>
+ <components>
+ <component group="io.ente.onnxruntime" name="onnxruntime-webgpu-android" version="1.27.0-r2">
+ <artifact name="onnxruntime-webgpu-android-1.27.0-r2.aar">
+ <sha256 value="0752f9b026df55780602cf482d9acddbe662d21383a2530d6e8c3d34a1ca8090"/>
+ </artifact>
+ </component>
+ </components>
+</verification-metadata>
diff --git a/mobile/native/android/apps/ensu/rust/build.gradle.kts b/mobile/native/android/apps/ensu/rust/build.gradle.kts
index 49dde44449..da8ce53626 100644
--- a/mobile/native/android/apps/ensu/rust/build.gradle.kts
+++ b/mobile/native/android/apps/ensu/rust/build.gradle.kts
@@ -1,5 +1,4 @@
import java.io.ByteArrayOutputStream
-import java.util.Properties
plugins {
id("com.android.library")
@@ -10,25 +9,6 @@ val knownAbis = listOf("arm64-v8a", "armeabi-v7a", "x86_64")
val debugJniLibsDir = layout.buildDirectory.dir("generated/jniLibs/debug")
val releaseJniLibsDir = layout.buildDirectory.dir("generated/jniLibs/release")
-// The pinned custom ONNX Runtime release is defined once in
-// mobile/native/onnxruntime/version.properties.
-val onnxRuntimeVersionFile = file("../../../../onnxruntime/version.properties")
-val onnxRuntimeVersions = Properties().apply {
- onnxRuntimeVersionFile.inputStream().use { load(it) }
-}
-val onnxRuntimeAar = gradle.gradleUserHomeDir.resolve(
- "caches/io.ente/onnxruntime/${onnxRuntimeVersions.getProperty("ortRelease")}/" +
- onnxRuntimeVersions.getProperty("ortAndroidAsset"),
-)
-val prepareOnnxRuntimeAndroid = tasks.register<Exec>("prepareOnnxRuntimeAndroid") {
- val prepareScript = file("../../../../onnxruntime/prepare-android.sh")
- inputs.file(prepareScript)
- inputs.file(onnxRuntimeVersionFile)
- outputs.file(onnxRuntimeAar)
- outputs.upToDateWhen { false }
- commandLine("sh", prepareScript, onnxRuntimeAar)
-}
-val onnxRuntimeFiles = files(onnxRuntimeAar).builtBy(prepareOnnxRuntimeAndroid)
fun capture(vararg cmd: String): String? = runCatching {
val out = ByteArrayOutputStream()
@@ -152,6 +132,7 @@ dependencies {
api("net.java.dev.jna:jna:5.18.1@aar")
api("androidx.annotation:annotation:1.7.1")
// Custom WebGPU/XNNPACK build; the Rust runtime dynamically loads its
- // libonnxruntime.so.
- api(onnxRuntimeFiles)
+ // libonnxruntime.so. Resolved from the Ivy repository declared in
+ // settings.gradle.kts and SHA-256 pinned in gradle/verification-metadata.xml.
+ api("io.ente.onnxruntime:onnxruntime-webgpu-android:1.27.0-r2@aar")
}
diff --git a/mobile/native/android/apps/ensu/settings.gradle.kts b/mobile/native/android/apps/ensu/settings.gradle.kts
index 973fb9540e..cabf7d6ad0 100644
--- a/mobile/native/android/apps/ensu/settings.gradle.kts
+++ b/mobile/native/android/apps/ensu/settings.gradle.kts
@@ -12,6 +12,22 @@ dependencyResolutionManagement {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
+ // Ente's custom prebuilt ONNX Runtime AAR is resolved straight from
+ // its GitHub release; its SHA-256 is pinned in
+ // gradle/verification-metadata.xml. See mobile/native/onnxruntime/README.md.
+ exclusiveContent {
+ forRepository {
+ ivy {
+ name = "enteOnnxRuntimePackaging"
+ url = uri("https://github.com/laurens-pilot/ort-packaging/releases/download")
+ patternLayout {
+ artifact("ort-[revision]/[artifact]-[revision].[ext]")
+ }
+ metadataSources { artifact() }
+ }
+ }
+ filter { includeGroup("io.ente.onnxruntime") }
+ }
}
}
diff --git a/mobile/native/onnxruntime/EnteOnnxRuntime.podspec b/mobile/native/onnxruntime/EnteOnnxRuntime.podspec
new file mode 100644
index 0000000000..58518c8f5a
--- /dev/null
+++ b/mobile/native/onnxruntime/EnteOnnxRuntime.podspec
@@ -0,0 +1,25 @@
+# Download vehicle for Ente's pinned custom ONNX Runtime iOS static
+# libraries. CocoaPods downloads the release ZIP at `pod install` time,
+# verifies its SHA-256, and caches it. Nothing is compiled or linked here:
+# the ente_photos_rust pod's build phase points the Rust `ort` crate at the
+# pre-thinned static archive for the active platform via ORT_LIB_PATH.
+#
+# See README.md next to this file for the release bump checklist.
+Pod::Spec.new do |s|
+ s.name = 'EnteOnnxRuntime'
+ s.version = '1.27.0-r2'
+ s.summary = "Ente's custom prebuilt ONNX Runtime static libraries for iOS."
+ s.homepage = 'https://github.com/laurens-pilot/ort-packaging'
+ s.authors = { 'Ente' => '[email protected]' }
+ s.license = { :type => 'MIT', :file => 'ThirdPartyNotices.txt' }
+ s.source = {
+ :http => 'https://github.com/laurens-pilot/ort-packaging/releases/download/ort-1.27.0-r2/onnxruntime-coreml-ios-1.27.0-r2.zip',
+ :sha256 => '87f27a8d899ff9dbea29a0eac99e08d58a854b0d58542cc131de16f029bb8d5f',
+ }
+
+ s.platform = :ios, '15.1'
+
+ # Keep only the pre-thinned per-slice static archives; the XCFramework in
+ # the ZIP is not used (the Rust build consumes the .a files directly).
+ s.preserve_paths = 'static-lib/**/*', 'ThirdPartyNotices.txt'
+end
diff --git a/mobile/native/onnxruntime/README.md b/mobile/native/onnxruntime/README.md
index 51f4d955bb..67dae69eed 100644
--- a/mobile/native/onnxruntime/README.md
+++ b/mobile/native/onnxruntime/README.md
@@ -1,21 +1,42 @@
# Custom ONNX Runtime binaries
-The mobile apps use Ente's pinned custom ONNX Runtime 1.27.0 packaging build:
+The mobile apps use Ente's pinned custom ONNX Runtime 1.27.0 packaging build
+(`ort-1.27.0-r2` from the ort-packaging repository):
- Android: WebGPU, XNNPACK, and CPU; ARM64, ARMv7, and x86_64
- iOS: CoreML and CPU; iOS 15.1+ device and ARM64 Simulator
-The release tag, asset names, and SHA-256 digests are defined once in
-`version.properties`; the prepare scripts and the Android Gradle builds all
-read from it. To bump the release, update only that file.
+Each platform's own package manager downloads and checksum-verifies the
+binaries; there are no custom download scripts.
-Android's AAR is downloaded by `prepare-android.sh` into the Gradle user cache.
-iOS's XCFramework ZIP is downloaded by `prepare-ios.sh`; the selected static
-archive slice is then bundled by the Rust build. Both downloads are verified
-against the SHA-256 digests published with the release.
+- **Android**: the AAR is resolved as a regular Gradle dependency
+ (`io.ente.onnxruntime:onnxruntime-webgpu-android`) from an Ivy repository
+ that points directly at the GitHub release. Its SHA-256 is pinned via
+ Gradle dependency verification. Used by the photos app and ensu.
+- **iOS**: the release ZIP is downloaded by CocoaPods as the local
+ `EnteOnnxRuntime` pod (`EnteOnnxRuntime.podspec` in this directory), which
+ pins its SHA-256. The `ente_photos_rust` pod's build phase exports
+ `ORT_LIB_PATH` pointing at the pre-thinned static archive for the active
+ platform slice, which the Rust `ort` crate links statically.
Desktop ONNX Runtime packaging is intentionally unchanged.
+## Bumping the pinned release
+
+Update the release tag, version, and SHA-256 digests (published as the
+`SHA256SUMS` release asset) in each of:
+
+1. `EnteOnnxRuntime.podspec` (this directory): `s.version`, `:http` URL, and
+ `:sha256`; then run `pod install` in `mobile/apps/photos/ios`.
+2. `mobile/apps/photos/android/app/build.gradle`: the
+ `io.ente.onnxruntime:onnxruntime-webgpu-android` dependency version.
+3. `mobile/apps/photos/android/gradle/verification-metadata.xml`: the
+ component version, artifact file name, and SHA-256.
+4. `mobile/native/android/apps/ensu/rust/build.gradle.kts`: the dependency
+ version.
+5. `mobile/native/android/apps/ensu/gradle/verification-metadata.xml`: same
+ as 3.
+
## WebGPU rollout status
On Android, the WebGPU execution provider is opt-in at runtime
@@ -25,17 +46,18 @@ Android 12+ (SDK 31). All other devices use the XNNPACK/CPU chain.
## Building the Rust photos crate for iOS outside Xcode
-The iOS `ort` dependency no longer downloads prebuilt binaries; the Cargokit
-build exports `ORT_LIB_PATH` pointing at the custom static archive. For direct
-`cargo` invocations against an iOS target (for example `cargo check`), export
-it manually:
+The iOS `ort` dependency does not download prebuilt binaries; the
+`ente_photos_rust` build phase exports `ORT_LIB_PATH` pointing at the custom
+static archive inside the `EnteOnnxRuntime` pod. For direct `cargo`
+invocations against an iOS target (for example `cargo check`), run
+`pod install` in `mobile/apps/photos/ios` once, then export it manually:
```sh
-ORT_LIB_PATH="$(sh mobile/native/onnxruntime/prepare-ios.sh \
- "$HOME/Library/Caches/io.ente/onnxruntime" iphoneos)" \
+ORT_LIB_PATH="$PWD/mobile/apps/photos/ios/Pods/EnteOnnxRuntime/static-lib/ios-arm64" \
IPHONEOS_DEPLOYMENT_TARGET=15.1 \
cargo check -p ente-photos --target aarch64-apple-ios
```
-Use `iphonesimulator` and `--target aarch64-apple-ios-sim` for the Simulator.
-The deployment target must be at least 15.1 to match the archive.
+Use the `ios-arm64-simulator` slice and `--target aarch64-apple-ios-sim` for
+the Simulator. The deployment target must be at least 15.1 to match the
+archive.
diff --git a/mobile/native/onnxruntime/prepare-android.sh b/mobile/native/onnxruntime/prepare-android.sh
deleted file mode 100755
index de8daef4e9..0000000000
--- a/mobile/native/onnxruntime/prepare-android.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh
-set -eu
-
-script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
-properties_file="$script_dir/version.properties"
-
-read_property() {
- sed -n "s/^$1=//p" "$properties_file" | head -n 1
-}
-
-base_url=$(read_property ortReleaseBaseUrl)
-release=$(read_property ortRelease)
-asset_name=$(read_property ortAndroidAsset)
-expected_sha256=$(read_property ortAndroidSha256)
-if [ -z "$base_url" ] || [ -z "$release" ] || [ -z "$asset_name" ] || [ -z "$expected_sha256" ]; then
- echo "Failed to read the ONNX Runtime release from $properties_file" >&2
- exit 1
-fi
-asset_url="$base_url/$release/$asset_name"
-
-destination=${1:?"usage: prepare-android.sh <destination.aar>"}
-
-sha256_file() {
- if command -v sha256sum >/dev/null 2>&1; then
- sha256sum "$1" | awk '{print $1}'
- elif command -v shasum >/dev/null 2>&1; then
- shasum -a 256 "$1" | awk '{print $1}'
- else
- echo "A SHA-256 utility (sha256sum or shasum) is required" >&2
- exit 1
- fi
-}
-
-if [ -f "$destination" ] && [ "$(sha256_file "$destination")" = "$expected_sha256" ]; then
- exit 0
-fi
-
-mkdir -p "$(dirname "$destination")"
-temporary_file="$destination.download.$$"
-trap 'rm -f "$temporary_file"' EXIT HUP INT TERM
-
-curl --fail --location --retry 3 --silent --show-error \
- --output "$temporary_file" \
- "$asset_url"
-
-actual_sha256=$(sha256_file "$temporary_file")
-if [ "$actual_sha256" != "$expected_sha256" ]; then
- echo "SHA-256 mismatch for $asset_name: got $actual_sha256, expected $expected_sha256" >&2
- exit 1
-fi
-
-mv "$temporary_file" "$destination"
-trap - EXIT HUP INT TERM
diff --git a/mobile/native/onnxruntime/prepare-ios.sh b/mobile/native/onnxruntime/prepare-ios.sh
deleted file mode 100755
index c51674b411..0000000000
--- a/mobile/native/onnxruntime/prepare-ios.sh
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/bin/sh
-set -eu
-
-script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
-properties_file="$script_dir/version.properties"
-
-read_property() {
- sed -n "s/^$1=//p" "$properties_file" | head -n 1
-}
-
-base_url=$(read_property ortReleaseBaseUrl)
-release=$(read_property ortRelease)
-asset_name=$(read_property ortIosAsset)
-expected_sha256=$(read_property ortIosSha256)
-if [ -z "$base_url" ] || [ -z "$release" ] || [ -z "$asset_name" ] || [ -z "$expected_sha256" ]; then
- echo "Failed to read the ONNX Runtime release from $properties_file" >&2
- exit 1
-fi
-asset_url="$base_url/$release/$asset_name"
-
-cache_root=${1:?"usage: prepare-ios.sh <cache-root> <iphoneos|iphonesimulator>"}
-platform=${2:?"usage: prepare-ios.sh <cache-root> <iphoneos|iphonesimulator>"}
-
-case "$platform" in
- iphoneos)
- xcframework_slice="ios-arm64"
- ;;
- iphonesimulator)
- xcframework_slice="ios-arm64-simulator"
- ;;
- *)
- echo "Unsupported iOS platform: $platform" >&2
- exit 1
- ;;
-esac
-
-sha256_file() {
- if command -v shasum >/dev/null 2>&1; then
- shasum -a 256 "$1" | awk '{print $1}'
- elif command -v sha256sum >/dev/null 2>&1; then
- sha256sum "$1" | awk '{print $1}'
- else
- echo "A SHA-256 utility (shasum or sha256sum) is required" >&2
- exit 1
- fi
-}
-
-asset_cache="$cache_root/$release"
-archive="$asset_cache/$asset_name"
-extract_root="$asset_cache/$expected_sha256"
-verified_marker="$extract_root/.verified"
-temporary_file=""
-temporary_extract=""
-temporary_library=""
-
-cleanup() {
- if [ -n "$temporary_file" ]; then
- rm -f "$temporary_file"
- fi
- if [ -n "$temporary_extract" ]; then
- rm -rf "$temporary_extract"
- fi
- if [ -n "$temporary_library" ]; then
- rm -f "$temporary_library"
- fi
-}
-trap cleanup EXIT HUP INT TERM
-
-mkdir -p "$asset_cache"
-if [ ! -f "$archive" ] || [ "$(sha256_file "$archive")" != "$expected_sha256" ]; then
- temporary_file="$archive.download.$$"
- curl --fail --location --retry 3 --silent --show-error \
- --output "$temporary_file" \
- "$asset_url"
-
- actual_sha256=$(sha256_file "$temporary_file")
- if [ "$actual_sha256" != "$expected_sha256" ]; then
- echo "SHA-256 mismatch for $asset_name: got $actual_sha256, expected $expected_sha256" >&2
- exit 1
- fi
-
- mv "$temporary_file" "$archive"
- temporary_file=""
-fi
-
-framework_binary="$extract_root/onnxruntime.xcframework/$xcframework_slice/onnxruntime.framework/onnxruntime"
-if [ ! -f "$verified_marker" ] || [ ! -f "$framework_binary" ]; then
- temporary_extract="$extract_root.extract.$$"
- mkdir -p "$temporary_extract"
- unzip -q "$archive" -d "$temporary_extract"
-
- extracted_binary="$temporary_extract/onnxruntime.xcframework/$xcframework_slice/onnxruntime.framework/onnxruntime"
- if [ ! -f "$extracted_binary" ]; then
- echo "The $xcframework_slice ONNX Runtime archive is missing from $asset_name" >&2
- exit 1
- fi
-
- printf '%s\n' "$expected_sha256" > "$temporary_extract/.verified"
- rm -rf "$extract_root"
- mv "$temporary_extract" "$extract_root"
- temporary_extract=""
-fi
-
-library_dir="$extract_root/static-lib/$xcframework_slice"
-mkdir -p "$library_dir"
-library="$library_dir/libonnxruntime.a"
-if [ ! -f "$library" ] || [ -L "$library" ]; then
- temporary_library="$library.thin.$$"
- xcrun lipo "$framework_binary" -thin arm64 -output "$temporary_library"
- mv "$temporary_library" "$library"
- temporary_library=""
-fi
-printf '%s\n' "$library_dir"
diff --git a/mobile/native/onnxruntime/version.properties b/mobile/native/onnxruntime/version.properties
deleted file mode 100644
index 824c481158..0000000000
--- a/mobile/native/onnxruntime/version.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# Single source of truth for Ente's pinned custom ONNX Runtime packaging
-# release. Read by prepare-android.sh and prepare-ios.sh, and by the Android
-# Gradle builds that locate the downloaded AAR in the Gradle user cache.
-#
-# When bumping the release, update every value below; the prepare scripts
-# verify the SHA-256 digests published with the release.
-ortReleaseBaseUrl=https://github.com/laurens-pilot/ort-packaging/releases/download
-ortRelease=ort-1.27.0-r1
-ortAndroidAsset=onnxruntime-webgpu-android-1.27.0-r1.aar
-ortAndroidSha256=697df7554462e1dd1f1528aa1a6c3273a1f7fb339223f4de767a19d7c343bc96
-ortIosAsset=onnxruntime-coreml-ios-1.27.0-r1.zip
-ortIosSha256=048c3d55054182e02b50ad5f79fadf2680cbcf9f88d973d54955923c81c21e38