- tools/make_icon.py genere assets/icon/ (police Bangers, aucune image du jeu) - launcher/build.rs compile dtr.rc avec rc.exe du SDK Windows (sans dependance) - la fenetre du launcher prend dtr-256.png au lieu du curseur du jeu Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
2.2 KiB
Rust
59 lines
2.2 KiB
Rust
//! Icône de l'exécutable : compile assets/icon/dtr.rc avec rc.exe du SDK Windows (installé avec les
|
|
//! Build Tools) et lie la ressource. Sans rc.exe, le launcher se compile quand même, sans icône.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::Command;
|
|
|
|
fn find_rc() -> Option<PathBuf> {
|
|
if let Some(p) = std::env::var_os("RC").map(PathBuf::from).filter(|p| p.is_file()) {
|
|
return Some(p);
|
|
}
|
|
let arch = if cfg!(target_arch = "aarch64") { "arm64" } else { "x64" };
|
|
for base in ["ProgramFiles(x86)", "ProgramFiles"] {
|
|
let Some(b) = std::env::var_os(base) else { continue };
|
|
let bin = Path::new(&b).join("Windows Kits").join("10").join("bin");
|
|
let Ok(rd) = std::fs::read_dir(&bin) else { continue };
|
|
// la version la plus récente qui contient rc.exe
|
|
let mut found: Vec<PathBuf> = rd
|
|
.flatten()
|
|
.map(|e| e.path().join(arch).join("rc.exe"))
|
|
.filter(|p| p.is_file())
|
|
.collect();
|
|
found.sort();
|
|
if let Some(p) = found.pop() {
|
|
return Some(p);
|
|
}
|
|
}
|
|
None
|
|
}
|
|
|
|
fn main() {
|
|
let icon_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("..").join("assets").join("icon");
|
|
println!("cargo:rerun-if-changed={}", icon_dir.join("dtr.rc").display());
|
|
println!("cargo:rerun-if-changed={}", icon_dir.join("dtr.ico").display());
|
|
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows")
|
|
|| std::env::var("CARGO_CFG_TARGET_ENV").as_deref() != Ok("msvc")
|
|
{
|
|
return;
|
|
}
|
|
let Some(rc) = find_rc() else {
|
|
println!("cargo:warning=rc.exe introuvable (SDK Windows) : launcher sans icone d'executable");
|
|
return;
|
|
};
|
|
let res = PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("dtr.res");
|
|
let ok = Command::new(&rc)
|
|
.current_dir(&icon_dir)
|
|
.arg("/nologo")
|
|
.arg("/fo")
|
|
.arg(&res)
|
|
.arg("dtr.rc")
|
|
.status()
|
|
.map(|s| s.success())
|
|
.unwrap_or(false);
|
|
if ok {
|
|
println!("cargo:rustc-link-arg-bins={}", res.display());
|
|
} else {
|
|
println!("cargo:warning=echec de rc.exe : launcher sans icone d'executable");
|
|
}
|
|
}
|