π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[ensu] Load host ORT dynamically
laurenspriem26dcab0183bf
diff --git a/.github/scripts/ensu-codegen.mjs b/.github/scripts/ensu-codegen.mjsdeleted file mode 100644index 65e96bebe5..0000000000--- a/.github/scripts/ensu-codegen.mjs+++ /dev/null@@ -1,38 +0,0 @@-#!/usr/bin/env node--import { execFileSync } from "node:child_process";-import path from "node:path";-import { fileURLToPath } from "node:url";--const root = path.resolve(- path.dirname(fileURLToPath(import.meta.url)),- "../..",-);-execFileSync(process.execPath, [path.join(root, "desktop/scripts/ort.js")], {- cwd: root,- stdio: "inherit",-});--const runtime = path.join(- root,- "desktop/node_modules/.cache/ente-onnxruntime",- process.arch,-);-const loaderPath =- process.platform === "darwin"- ? "DYLD_LIBRARY_PATH"- : process.platform === "win32"- ? "PATH"- : "LD_LIBRARY_PATH";-execFileSync("cargo", ["codegen", "native", "ensu"], {- cwd: path.join(root, "rust"),- stdio: "inherit",- env: {- ...process.env,- ORT_LIB_PATH: runtime,- ORT_PREFER_DYNAMIC_LINK: "1",- [loaderPath]: [runtime, process.env[loaderPath]]- .filter(Boolean)- .join(path.delimiter),- },-});diff --git a/.github/workflows/ensu-build.yml b/.github/workflows/ensu-build.ymlindex 74ee64f08c..fe18a1f17e 100644--- a/.github/workflows/ensu-build.yml+++ b/.github/workflows/ensu-build.yml@@ -334,14 +334,8 @@ jobs:sudo apt-get updatesudo apt-get install -y libvulkan-dev glslc spirv-headers- - name: Setup Node.js- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1- with:- node-version: 24-- - name: Generate native bindings- run: node .github/scripts/ensu-codegen.mjs- working-directory: .+ - run: cargo codegen native+ working-directory: rust- name: Setup signing keysenv:@@ -435,14 +429,8 @@ jobs:with:ref: ${{ needs.build-metadata.outputs.commit_sha }}- - name: Setup Node.js- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1- with:- node-version: 24-- - name: Generate native bindings- run: node .github/scripts/ensu-codegen.mjs- working-directory: .+ - run: cargo codegen native+ working-directory: rust- name: Import Apple Distribution certificateuses: Apple-Actions/import-codesign-certs@77ba2a2a8f5cfc8c405ebf3159f767c323e238f9 # v7.1.0diff --git a/android/apps/ensu/README.md b/android/apps/ensu/README.mdindex 2fb461d220..a15130b1c8 100644--- a/android/apps/ensu/README.md+++ b/android/apps/ensu/README.md@@ -6,28 +6,27 @@ To know more about Ente, see [our main README](../../../README.md) or visit [ent## Building from source-1. Install [Android Studio](https://developer.android.com/studio), [Rust](https://www.rust-lang.org/tools/install), [Node.js 24](https://nodejs.org/), and CMake (e.g. `brew install cmake`).+1. Install [Android Studio](https://developer.android.com/studio), [Rust](https://www.rust-lang.org/tools/install), and CMake (e.g. `brew install cmake`).2. Generate the Kotlin bindings:- ```sh- node .github/scripts/ensu-codegen.mjs- ```-- Run this from the repository root. The helper uses Photos' checksum-pinned Ente ONNX Runtime installer to supply the host library needed by the binding generator. Gradle uses the packaged Android AAR when cross-compiling the app.+ ```sh+ cd rust+ cargo codegen native+ ```3. Open `android/` in Android Studio and run Ensu's `app` module. If the Android NDK is missing, Android Studio will prompt to install it.-That's it. Apart from generating the bindings, this is a normal Android project. Gradle cross-compiles the Rust libraries to JNI `.so` files automatically when building the app.+That's it. Apart from the `cargo codegen`, this is a normal Android project. Gradle cross-compiles the Rust libraries to JNI `.so` files automatically when building the app.> [!NOTE]>-> Re-run the helper whenever the UniFFI-exported surface under `rust/bindings/uniffi/` changes. Internal Rust changes (function bodies, private helpers) are picked up by the normal Gradle build.+> Re-run `cargo codegen native` whenever the UniFFI-exported surface under `rust/bindings/uniffi/` changes. Internal Rust changes (function bodies, private helpers) are picked up by the normal Gradle build.>> From anywhere in the repo:>> ```sh-> (cd "$(git rev-parse --show-toplevel)" && node .github/scripts/ensu-codegen.mjs)+> (cd "$(git rev-parse --show-toplevel)/rust" && cargo codegen native)> ```## Terminal buildsdiff --git a/apple/apps/ensu/README.md b/apple/apps/ensu/README.mdindex 208768715f..7b066e5617 100644--- a/apple/apps/ensu/README.md+++ b/apple/apps/ensu/README.md@@ -4,28 +4,27 @@ Source code for the Ensu iOS app.## Building from source-1. Install [Xcode](https://developer.apple.com/xcode/), [Rust](https://www.rust-lang.org/tools/install), [Node.js 24](https://nodejs.org/), and CMake (e.g. `brew install cmake`).+1. Install [Xcode](https://developer.apple.com/xcode/), [Rust](https://www.rust-lang.org/tools/install), and CMake (e.g. `brew install cmake`).2. Generate the Swift bindings:- ```sh- node .github/scripts/ensu-codegen.mjs- ```-- Run this from the repository root. The helper uses Photos' checksum-pinned Ente ONNX Runtime installer to supply the host library needed by the binding generator. Xcode links the packaged iOS XCFramework when building the app.+ ```sh+ cd rust+ cargo codegen native+ ```3. Open `Ensu.xcodeproj` in Xcode and run the `Ensu` scheme.-That's it. Apart from generating the bindings, this is a normal iOS project. Xcode compiles and statically links the Rust libraries automatically when building the app.+That's it. Apart from the `cargo codegen`, this is a normal iOS project. Xcode compiles and statically links the Rust libraries automatically when building the app.> [!NOTE]>-> Re-run the helper whenever the UniFFI-exported surface under `rust/bindings/uniffi/` changes. Internal Rust changes (function bodies, private helpers) are picked up by the normal Xcode build.+> Re-run `cargo codegen native` whenever the UniFFI-exported surface under `rust/bindings/uniffi/` changes. Internal Rust changes (function bodies, private helpers) are picked up by the normal Xcode build.>> From anywhere in the repo:>> ```sh-> (cd "$(git rev-parse --show-toplevel)" && node .github/scripts/ensu-codegen.mjs)+> (cd "$(git rev-parse --show-toplevel)/rust" && cargo codegen native)> ```## Terminal buildsdiff --git a/rust/crates/ensu/Cargo.toml b/rust/crates/ensu/Cargo.tomlindex adbc034214..7272294e65 100644--- a/rust/crates/ensu/Cargo.toml+++ b/rust/crates/ensu/Cargo.toml@@ -41,7 +41,7 @@ llama-cpp-2 = { version = "=0.1.158", features = ["mtmd"] }[target.'cfg(all(target_os = "android", target_arch = "aarch64"))'.dependencies]llama-cpp-2 = { version = "=0.1.158", features = ["dynamic-backends", "mtmd"] }-[target.'cfg(target_os = "android")'.dependencies]+[target.'cfg(not(target_os = "ios"))'.dependencies]ort = { workspace = true, features = ["load-dynamic"], optional = true }# The iOS app links Ente's custom ONNX Runtime XCFramework via SPM, so ort-sys