re_build_info/
lib.rs

1//! Information about the build of a Rust crate.
2//!
3//! To use this you also need to call `re_build_tools::export_env_vars()` from your build.rs.
4
5mod build_info;
6mod crate_version;
7
8pub use build_info::BuildInfo;
9pub use crate_version::{CrateVersion, Meta};
10
11/// Create a [`BuildInfo`] at compile-time using environment variables exported by
12/// calling `re_build_tools::export_env_vars()` from your build.rs.
13#[macro_export]
14macro_rules! build_info {
15    () => {
16        $crate::BuildInfo {
17            crate_name: env!("CARGO_PKG_NAME").into(),
18            features: env!("RE_BUILD_FEATURES").into(),
19            version: $crate::CrateVersion::parse(env!("CARGO_PKG_VERSION")),
20            rustc_version: env!("RE_BUILD_RUSTC_VERSION").into(),
21            llvm_version: env!("RE_BUILD_LLVM_VERSION").into(),
22            git_hash: env!("RE_BUILD_GIT_HASH").into(),
23            git_branch: env!("RE_BUILD_GIT_BRANCH").into(),
24            // TODO(cmc): `PartialEq` is not available in const contexts, so this won't actually
25            // build if you try to instantiate a BuildInfo in a constant.
26            is_in_rerun_workspace: env!("RE_BUILD_IS_IN_RERUN_WORKSPACE") == "yes",
27            target_triple: env!("RE_BUILD_TARGET_TRIPLE").into(),
28            datetime: env!("RE_BUILD_DATETIME").into(),
29            is_debug_build: cfg!(debug_assertions),
30        }
31    };
32}