mod build_info;
mod crate_version;
pub use build_info::BuildInfo;
pub use crate_version::{CrateVersion, Meta};
#[doc(hidden)]
pub use std::sync::OnceLock;
#[macro_export]
macro_rules! build_info {
() => {
$crate::BuildInfo {
crate_name: env!("CARGO_PKG_NAME").into(),
features: env!("RE_BUILD_FEATURES").into(),
version: $crate::CrateVersion::parse(env!("CARGO_PKG_VERSION")),
rustc_version: env!("RE_BUILD_RUSTC_VERSION").into(),
llvm_version: env!("RE_BUILD_LLVM_VERSION").into(),
git_hash: env!("RE_BUILD_GIT_HASH").into(),
git_branch: env!("RE_BUILD_GIT_BRANCH").into(),
is_in_rerun_workspace: env!("RE_BUILD_IS_IN_RERUN_WORKSPACE") == "yes",
target_triple: env!("RE_BUILD_TARGET_TRIPLE").into(),
datetime: env!("RE_BUILD_DATETIME").into(),
is_debug_build: cfg!(debug_assertions),
}
};
}
#[macro_export]
macro_rules! exposed_version {
() => {{
static EXPOSED_VERSION: $crate::OnceLock<String> = $crate::OnceLock::new();
EXPOSED_VERSION
.get_or_init(|| {
if let Some(version) = std::env::var("EXPOSED_VERSION")
.ok()
.filter(|v| !v.is_empty())
{
version
} else {
let info = $crate::build_info!();
let mut version = format!("build:{}", env!("CARGO_PKG_VERSION"));
if !info.git_branch.is_empty() {
version.push('-');
version.push_str(&info.git_branch);
}
if !info.short_git_hash().is_empty() {
version.push('-');
version.push_str(info.short_git_hash());
}
version
}
})
.as_str()
}};
}