gallery/harnesses/gtauri/build.rs
gmp e019a950b1 gtauri: Tauri v2 gallery harness WORKING on emulator
Chromium owns scroll/compositor/lazy-load/image-cache; Rust owns
scan/SQLite/thumbnail-decode behind a gallery:// custom protocol.

Hard-won gotchas (see in-code comments):
- Android: no native custom-scheme support → wry rewrites the URL to
  http://gallery.localhost/... (custom_protocol_workaround). The JS
  MUST request that form; the handler receives the reverted
  gallery://localhost/... and must strip the authority.
- tauri_build::build() in build.rs must run UNCONDITIONALLY (build
  scripts run on the host: a cfg(target_os) gate silently disables it,
  which skips the rustc-cfg=mobile emission → no mobile_entry_point →
  .so with no JNI symbols → UnsatisfiedLinkError).
- build.rs must list frontend files for rerun-if-changed (a dir-level
  directive only watches the dir mtime, not content edits) — the .so
  bakes the frontend at compile time and cargo otherwise ships stale
  UI with a 'successful' build.
- logcat drops ~75% of lines under load: use the file trace.
- fetch() is CORS-restricted (page origin http://tauri.localhost);
  <img> is not — add ACAO:* anyway.

Emulator (5853 real files): grid renders, lazy thumbs via
gallery:// with on-disk cache (87 files 35-72KB), FR log clean at
60Hz, viewer opens full-res with compositor-only pan/zoom. The single
'broken' cell is a 17-byte fake test JPEG (correct behavior).
2026-10-31 18:59:51 -04:00

28 lines
1.1 KiB
Rust

// tauri::generate_context!() embeds `frontendDist` at compile time. Without
// rerun directives cargo does NOT rebuild the .so when frontend files change
// (observed: stale grid code survived a "successful" rebuild). Directory-level
// rerun-if-changed only tracks the dir mtime (add/remove/rename, NOT content
// edits), so list every file explicitly.
fn walk(p: &std::path::Path) {
for e in std::fs::read_dir(p).unwrap() {
let e = e.unwrap();
let path = e.path();
if path.is_dir() {
walk(&path);
} else {
println!("cargo:rerun-if-changed={}", path.display());
}
}
}
fn main() {
walk(std::path::Path::new("frontend/dist"));
println!("cargo:rerun-if-changed=tauri.conf.json");
// tauri_build::build() inspects the TARGET env var itself (build scripts
// run on the HOST, so a cfg(target_os) gate would disable it). For
// android targets it emits `cargo:rustc-cfg=mobile`, which is what
// activates `#[cfg_attr(mobile, tauri::mobile_entry_point)]`.
tauri_build::build();
}