summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-03-09 15:21:43 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-03-09 15:21:43 +0800
commit2cddfb098f6cf54a54e2812e1070bf238bb4d20e (patch)
treede3a8aa390f4db7e50be66b48af58d88d67c0b74 /build.rs
parentb7bbfc193aeae5b0fb8db6d586aabaf992dd0cfe (diff)
Add build script to compile and copy Windows GUI executable
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs57
1 files changed, 57 insertions, 0 deletions
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);
+ }
+}