2023-06-11 19:18:58 +05:00
fn main ( ) {
2026-04-22 18:07:33 +03:00
let manifest_dir = std ::env ::var ( " CARGO_MANIFEST_DIR " ) . unwrap ( ) ;
2026-05-15 13:18:08 +03:00
let manifest_path = std ::path ::Path ::new ( & manifest_dir ) ;
2026-04-22 18:07:33 +03:00
2026-05-15 13:18:08 +03:00
let lib_path = manifest_path . join ( " .. \\ .. \\ lib \\ windows \\ amd64 " ) ;
2026-04-22 18:07:33 +03:00
println! ( " cargo:rustc-link-search=native= {} " , lib_path . display ( ) ) ;
2026-05-15 13:18:08 +03:00
// 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 ) ;
}
}
}
2023-06-11 19:18:58 +05:00
tauri_build ::build ( )
}