fn main() { #[cfg(target_os = "windows")] build_win32_gui(); } fn build_win32_gui() { use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; use std::str::FromStr; const EXE_NAME: &str = "butckg.exe"; let crate_root = env!("CARGO_MANIFEST_DIR"); let build_script = Path::new(crate_root).join("gui\\win32\\scripts\\build.ps1"); let status = Command::new("powershell") .arg("-ExecutionPolicy") .arg("Bypass") .arg("-File") .arg(&build_script) .status() .expect("Failed to execute build script"); if !status.success() { eprintln!( "Warning: Build script failed with exit code: {:?}", status.code() ); return; } let exe_path = Path::new(crate_root) .join("gui\\win32\\build\\bin") .join(EXE_NAME); if exe_path.exists() { let out_dir = std::env::var("OUT_DIR").unwrap(); let out_dir_path = PathBuf::from_str(&out_dir).unwrap(); let target_dir = out_dir_path .parent() .unwrap() .parent() .unwrap() .parent() .unwrap(); let dest_path = target_dir.join(EXE_NAME); if let Err(e) = fs::copy(&exe_path, &dest_path) { eprintln!( "Warning: Failed to copy executable to build directory: {}", e ); } } else { eprintln!("Warning: Executable not found at: {:?}", exe_path); } }