fn main() { let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); let manifest_path = std::path::Path::new(&manifest_dir); let lib_path = manifest_path.join("..\\..\\lib\\windows\\amd64"); println!("cargo:rustc-link-search=native={}", lib_path.display()); // Vite outputs the Svelte bundle into ../../frontend/dist/client. If the // user runs a bare `cargo build -p jarvis-gui` without going through // `cargo tauri build`, the beforeBuildCommand in tauri.conf.json never // fires and the new release exe ends up bundling whatever stale dist is // sitting on disk — including UI states from days ago. Force a rebuild // here when any Svelte / TS source under frontend/src changes. let frontend = manifest_path.join("..\\..\\frontend"); let src = frontend.join("src"); if src.is_dir() { println!("cargo:rerun-if-changed={}", src.display()); println!("cargo:rerun-if-changed={}", frontend.join("package.json").display()); let npm = if cfg!(target_os = "windows") { "npm.cmd" } else { "npm" }; let status = std::process::Command::new(npm) .arg("run") .arg("build") .current_dir(&frontend) .status(); match status { Ok(s) if s.success() => { println!("cargo:warning=jarvis-gui: frontend rebuilt via npm run build"); } Ok(s) => { println!("cargo:warning=jarvis-gui: npm run build exited with {}", s); } Err(e) => { println!("cargo:warning=jarvis-gui: npm not found ({}). Bundling existing dist; run `npm install && npm run build` in frontend/ if the UI looks stale.", e); } } } tauri_build::build() }