45 lines
1.7 KiB
Rust
45 lines
1.7 KiB
Rust
fn main() {
|
|
// Version livrée : `VERSION` (racine du dépôt) est la source unique de
|
|
// vérité (même fichier que backend/version.py et l'image Docker).
|
|
// Repli : `git describe` quand le fichier n'est pas dans le contexte de build.
|
|
let version = std::fs::read_to_string(
|
|
std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../VERSION"),
|
|
)
|
|
.ok()
|
|
.map(|s| s.trim().to_string())
|
|
.filter(|s| !s.is_empty())
|
|
.unwrap_or_else(|| {
|
|
std::process::Command::new("git")
|
|
.args(["describe", "--tags", "--dirty=-dirty"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
.map(|s| s.trim().trim_start_matches('v').to_string())
|
|
.unwrap_or_else(|| "0.0.0".to_string())
|
|
});
|
|
|
|
// Extract short hash for display
|
|
let short_hash = std::process::Command::new("git")
|
|
.args(["rev-parse", "--short", "HEAD"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
.map(|s| s.trim().to_string())
|
|
.unwrap_or_else(|| "unknown".to_string());
|
|
|
|
// SemVer base (strip -suffix)
|
|
let semver_base = version.split('-').next().unwrap_or("0.0.0");
|
|
|
|
println!("cargo:rustc-env=GIT_VERSION={}", version);
|
|
println!("cargo:rustc-env=GIT_HASH={}", short_hash);
|
|
println!("cargo:rustc-env=SEMVER={}", semver_base);
|
|
println!("cargo:rerun-if-changed=../VERSION");
|
|
println!("cargo:rerun-if-changed=.git/HEAD");
|
|
println!("cargo:rerun-if-changed=.git/refs/heads/main");
|
|
println!("cargo:rerun-if-changed=.git/refs/tags");
|
|
|
|
println!("cargo:rerun-if-changed=permissions");
|
|
|
|
tauri_build::build()
|
|
}
|