//! 빌드 타임스탬프를 환경변수 BUILD_TIMESTAMP 로 내보냄. //! `env!("BUILD_TIMESTAMP")` 로 소비. 사용자가 실행 중인 바이너리가 최신 빌드인지 //! 타이틀 바에서 즉시 확인할 수 있게 함. use std::process::Command; fn main() { // 항상 재실행 → 타임스탬프가 매 빌드마다 갱신. println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=src"); let ts = current_timestamp(); println!("cargo:rustc-env=BUILD_TIMESTAMP={}", ts); } fn current_timestamp() -> String { // Windows: PowerShell / Unix: date. 실패 시 epoch 초. #[cfg(target_os = "windows")] let out = Command::new("powershell") .args([ "-NoProfile", "-Command", "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'", ]) .output(); #[cfg(not(target_os = "windows"))] let out = Command::new("date").args(["+%Y-%m-%d %H:%M:%S"]).output(); if let Ok(o) = out { if o.status.success() { let s = String::from_utf8_lossy(&o.stdout).trim().to_string(); if !s.is_empty() { return s; } } } // 폴백: Unix epoch 초 use std::time::{SystemTime, UNIX_EPOCH}; let secs = SystemTime::now() .duration_since(UNIX_EPOCH) .map(|d| d.as_secs()) .unwrap_or(0); format!("epoch-{secs}") }