diff --git a/build.rs b/build.rs index 72e0b5e..5f3b008 100644 --- a/build.rs +++ b/build.rs @@ -16,19 +16,23 @@ fn main() { if target_os == "windows" { let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); let icon = format!("{manifest_dir}/assets/Cagire.ico"); - eprintln!("winres: manifest_dir = {manifest_dir}"); - eprintln!("winres: icon path = {icon}"); - eprintln!("winres: icon exists = {}", std::path::Path::new(&icon).exists()); - eprintln!("winres: OUT_DIR = {}", std::env::var("OUT_DIR").unwrap_or_default()); - eprintln!("winres: TARGET = {}", std::env::var("TARGET").unwrap_or_default()); let mut res = winres::WindowsResource::new(); + // Cross-compiling from Unix: use prefixed MinGW tools + if cfg!(unix) { + res.set_windres_path("x86_64-w64-mingw32-windres"); + res.set_ar_path("x86_64-w64-mingw32-ar"); + res.set_toolkit_path("/"); + } res.set_icon(&icon) .set("ProductName", "Cagire") .set("FileDescription", "Forth-based music sequencer") .set("LegalCopyright", "Copyright (c) 2025 Raphaƫl Forment"); - if let Err(e) = res.compile() { - eprintln!("winres: compile error: {e:?}"); - panic!("Failed to compile Windows resources: {e}"); + res.compile().expect("Failed to compile Windows resources"); + // GNU ld discards unreferenced sections from static archives, + // so link the resource object directly to ensure .rsrc is kept. + if cfg!(unix) { + let out_dir = std::env::var("OUT_DIR").unwrap(); + println!("cargo:rustc-link-arg-bins={out_dir}/resource.o"); } } } diff --git a/src/app/dispatch.rs b/src/app/dispatch.rs index cc81fa1..d2f17e1 100644 --- a/src/app/dispatch.rs +++ b/src/app/dispatch.rs @@ -503,8 +503,5 @@ impl App { if self.page == Page::Script { self.load_script_to_editor(); } - if self.page == Page::Engine { - self.audio.refresh_devices(); - } } }