[][src]Crate build_info

Begin by adding build-info as a [dependency] and build-info-build as a [build-dependency] to your Cargo.toml. Please make sure that both dependencies use the same version!

If it does not already exist, add a build.rs to your project's root, where you call build_info_build::build_script(). This will collect build information at compile time.

Then, either use the build_info! macro to add a function that returns version information at runtime:

This example is not tested
build_info::build_info!(fn version);

or use build_info::format! to generate a string at compile time:

This example is not tested
// sample output: "{sample v0.0.13 built with rustc 1.45.0-nightly (4bd32c980 2020-05-29) at 2020-05-30 11:22:46Z}"
build_info::format!("{{{} v{} built with {} at {}}}", $.crate_info.name, $.crate_info.version, $.compiler, $.timestamp)

You can also check out the sample project that shows both variants.


The ´build-info` crate has the following features:

  • runtime (enabled by default): Enables the use of build_info::build_info! and provides the prerequisite types.
  • serde (disabled by default): Adds serde support to the objects returned by build_info::build_info!. Implies the runtime feature.
  • nested (disabled by default): Enables proc-macro-nested for build_info::format!, which lets it be nested inside another proc-macro invocation in some cases.


pub use build_info_common::chrono;
pub use build_info_common::semver;



Call as build_info!(fn name) to create a function called name that returns a reference to a lazily created and cached BuildInfo object.


Generates a string at compile-time that includes build information.



Information about the current build


rustc version and configuration


Information about the current crate (i.e., the crate for which build information has been generated)


Information about a git repository



rustc distribution channel (some compiler features are only available on specific channels)


Support for different version control systems