diff options
| -rw-r--r-- | build.rs | 57 | ||||
| -rw-r--r-- | gui/win32/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | gui/win32/cbuild.ps1 | 2 | ||||
| -rw-r--r-- | gui/win32/scripts/run.ps1 | 2 | ||||
| -rw-r--r-- | gui/win32/src/butckg.rc (renamed from gui/win32/src/butck_gui.rc) | 0 |
5 files changed, 65 insertions, 8 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); + } +} diff --git a/gui/win32/CMakeLists.txt b/gui/win32/CMakeLists.txt index 2fc5f79..7afcf9a 100644 --- a/gui/win32/CMakeLists.txt +++ b/gui/win32/CMakeLists.txt @@ -1,30 +1,30 @@ cmake_minimum_required(VERSION 3.10) -project(butck_gui VERSION 1.0.0 LANGUAGES C RC) +project(butckg VERSION 1.0.0 LANGUAGES C RC) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) enable_language(RC) -add_executable(butck_gui WIN32 +add_executable(butckg WIN32 src/main.c - src/butck_gui.rc + src/butckg.rc ) if(WIN32) - target_compile_definitions(butck_gui PRIVATE + target_compile_definitions(butckg PRIVATE UNICODE _UNICODE _WIN32_WINNT=0x0A00 ) - target_link_libraries(butck_gui + target_link_libraries(butckg user32 gdi32 comctl32 ) endif() -set_target_properties(butck_gui PROPERTIES +set_target_properties(butckg PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) diff --git a/gui/win32/cbuild.ps1 b/gui/win32/cbuild.ps1 index 85a7d54..a15289f 100644 --- a/gui/win32/cbuild.ps1 +++ b/gui/win32/cbuild.ps1 @@ -15,6 +15,6 @@ switch ($args[0]) { "clean" { Clean } "run" { Build; Run } default { - Write-Host "Usage: .\mgr.ps1 [build|clean|run]" + Write-Host "Usage: .\cbuild.ps1 [rebuild|clean|run]" } } diff --git a/gui/win32/scripts/run.ps1 b/gui/win32/scripts/run.ps1 index a8f50e8..7ebc2f7 100644 --- a/gui/win32/scripts/run.ps1 +++ b/gui/win32/scripts/run.ps1 @@ -2,7 +2,7 @@ $originalLocation = Get-Location $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path Set-Location $scriptPath -$exePath = "..\build\bin\butck_gui.exe" +$exePath = "..\build\bin\butckg.exe" if (Test-Path $exePath) { & $exePath } diff --git a/gui/win32/src/butck_gui.rc b/gui/win32/src/butckg.rc index a609d9d..a609d9d 100644 --- a/gui/win32/src/butck_gui.rc +++ b/gui/win32/src/butckg.rc |
