From 2cddfb098f6cf54a54e2812e1070bf238bb4d20e Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Mon, 9 Mar 2026 15:21:43 +0800 Subject: Add build script to compile and copy Windows GUI executable --- build.rs | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 build.rs (limited to 'build.rs') diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d69d05e --- /dev/null +++ b/build.rs @@ -0,0 +1,57 @@ +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); + } +} -- cgit