π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use napi cross toolchain for Linux desktop builds
laurenspriemc4e1d8208224
diff --git a/.github/workflows/photos-desktop-build.yml b/.github/workflows/photos-desktop-build.ymlindex cfbf5e9424..21d0de3ccc 100644--- a/.github/workflows/photos-desktop-build.yml+++ b/.github/workflows/photos-desktop-build.yml@@ -82,7 +82,7 @@ jobs:strategy:matrix:- os: [macos-latest, ubuntu-22.04, windows-latest]+ os: [macos-latest, ubuntu-latest, windows-latest]env:RELEASE_TAG: ${{ needs.build-metadata.outputs.release_tag }}diff --git a/desktop/scripts/ml-native.js b/desktop/scripts/ml-native.jsindex 1d43a773a0..f189019c39 100644--- a/desktop/scripts/ml-native.js+++ b/desktop/scripts/ml-native.js@@ -63,9 +63,8 @@ const rustTriple = (platform, arch) => {** The build always runs so that edits to the Rust sources cannot be missed* when packaging; cargo's incremental compilation makes this cheap when- * nothing has changed. For the host architecture we omit `--target` so that- * the build shares the cargo cache of the `cargo codegen napi` that- * postinstall runs (which also omits it).+ * nothing has changed. Linux always uses napi-cli's cross toolchain, including+ * for the host architecture, to keep the addon's glibc requirement at 2.17.*/const buildAddon = async (appDir, platform, arch) => {const addonPath = path.join(@@ -81,12 +80,9 @@ const buildAddon = async (appDir, platform, arch) => {"--release --strip --platform --no-js","--dts index.d.ts","--output-dir rust-bindings",- ...(arch != process.arch+ ...(platform == "linux" || arch != process.arch? [`--target ${rustTriple(platform, arch)}`,- // Cross-compiling for the other Linux architecture needs a- // gcc cross toolchain; let napi-cli download its prebuilt- // one....(platform == "linux" ? ["--use-napi-cross"] : []),]: []),diff --git a/rust/apps/codegen/src/main.rs b/rust/apps/codegen/src/main.rsindex 1d12e1df2a..975f7efc6c 100644--- a/rust/apps/codegen/src/main.rs+++ b/rust/apps/codegen/src/main.rs@@ -218,6 +218,16 @@ fn generate_napi() -> Result<(), DynError> {// On Windows npm is a .cmd shim, which CreateProcess doesn't resolve.let npm = if cfg!(windows) { "npm.cmd" } else { "npm" };+ let linux_cross_args = if cfg!(target_os = "linux") {+ let target = match env::consts::ARCH {+ "x86_64" => "x86_64-unknown-linux-gnu",+ "aarch64" => "aarch64-unknown-linux-gnu",+ arch => return Err(format!("unsupported Linux architecture for NAPI: {arch}").into()),+ };+ vec!["--target", target, "--use-napi-cross"]+ } else {+ Vec::new()+ };run_command(Command::new(npm).arg("exec")@@ -236,6 +246,7 @@ fn generate_napi() -> Result<(), DynError> {.arg("index.d.ts").arg("--output-dir").arg(&out_dir)+ .args(linux_cross_args).current_dir(&desktop_dir),"failed to build the desktop Node addon (run npm install in desktop/ first)".to_owned(),)diff --git a/rust/bindings/frb/photos/Cargo.toml b/rust/bindings/frb/photos/Cargo.tomlindex e22dc35a1b..ae4eb49eb8 100644--- a/rust/bindings/frb/photos/Cargo.toml+++ b/rust/bindings/frb/photos/Cargo.toml@@ -8,7 +8,7 @@ crate-type = ["cdylib", "staticlib"][dependencies]flutter_rust_bridge = "=2.12.0"ente-image.workspace = true-ente-photos.workspace = true+ente-photos = { workspace = true, features = ["usearch"] }[lints.rust]unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }diff --git a/rust/bindings/napi/photos/Cargo.toml b/rust/bindings/napi/photos/Cargo.tomlindex 7ef5b71e8d..1b03a44353 100644--- a/rust/bindings/napi/photos/Cargo.toml+++ b/rust/bindings/napi/photos/Cargo.toml@@ -6,6 +6,7 @@ edition = "2024"crate-type = ["cdylib"][dependencies]+# Keep usearch disabled: its C++17 code cannot use napi-cli's GCC 4.8 toolchain.ente-photos.workspace = truenapi = { version = "3", default-features = false, features = ["napi8"] }napi-derive = "3"diff --git a/rust/crates/photos/Cargo.toml b/rust/crates/photos/Cargo.tomlindex 7d008a55ae..4f0c822e0e 100644--- a/rust/crates/photos/Cargo.toml+++ b/rust/crates/photos/Cargo.toml@@ -11,7 +11,7 @@ ente-image.workspace = truequick-xml = "0.41"# The FRB photos bridge calls the SimSIMD symbol exported by usearch 2.21.x.# Newer usearch releases switched that implementation to numkong symbols.-usearch = "=2.21.4"+usearch = { version = "=2.21.4", optional = true }fast_image_resize = { version = "5.5.0", features = ["image", "rayon"] }image = { version = "0.25.5", default-features = true }imageproc = "0.25.0"diff --git a/rust/crates/photos/src/ml/mod.rs b/rust/crates/photos/src/ml/mod.rsindex c555236335..88b35b1544 100644--- a/rust/crates/photos/src/ml/mod.rs+++ b/rust/crates/photos/src/ml/mod.rs@@ -12,5 +12,6 @@ mod postprocess;mod preprocess;pub mod runtime;pub mod types;+#[cfg(feature = "usearch")]pub mod vector_db;mod webgpu;