refactor: Move git version info gather in into a build script

This commit is contained in:
Jade Ellis 2025-05-01 00:38:35 +01:00
parent e1655edd83
commit a98da7d942
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
14 changed files with 231 additions and 123 deletions

23
src/build_metadata/mod.rs Normal file
View file

@ -0,0 +1,23 @@
pub mod built {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
pub static GIT_COMMIT_HASH: Option<&str> = option_env!("GIT_COMMIT_HASH");
pub static GIT_COMMIT_HASH_SHORT: Option<&str> = option_env!("GIT_COMMIT_HASH_SHORT");
// this would be a lot better if Option::or was const.
pub static VERSION_EXTRA: Option<&str> =
if let v @ Some(_) = option_env!("CONTINUWUITY_VERSION_EXTRA") {
v
} else if let v @ Some(_) = option_env!("CONDUWUIT_VERSION_EXTRA") {
v
} else if let v @ Some(_) = option_env!("CONDUIT_VERSION_EXTRA") {
v
} else {
GIT_COMMIT_HASH_SHORT
};
pub static GIT_REMOTE_WEB_URL: Option<&str> = option_env!("GIT_REMOTE_WEB_URL");
pub static GIT_REMOTE_COMMIT_URL: Option<&str> = option_env!("GIT_REMOTE_COMMIT_URL");
// TODO: Mark dirty builds within the version string