built
provides a crate with information from the time it was built.
built
is used as a build-time dependency to collect various information
about the build environment and serialize it into the final crate.
The information collected by built
include:
- Various metadata like version, authors, homepage etc. as set by
Cargo.toml
- The tag or commit id if the crate was being compiled from within a git repo.
- The values of various
cfg!
, liketarget_os
andtarget_arch
. - The features the crate was compiled with.
- The various dependencies, dependencies of dependencies and their versions cargo ultimately chose to compile.
- The presence of a CI-platform like
Travis CI
andAppVeyor
. - The used compiler and it's version; the used documentation generator and it's version.
// In build.rs
// In lib.rs or main.rs
println!;
match CI_PLATFORM
if detect_ci.is_some else
This is version 0.1.0 (git 0.1-62-gcfdfb93), built for x86_64-unknown-linux-gnu by rustc 1.40.0 (73528e339 2019-12-16). It seems I've not been built on a continuous integration platform, and I'm currently not executing on one!