built
provides a crate with information from the time it was built.
Documentation for latest release here, for master here.
built
is used as a build-time dependency to collect various information
about the build environment, serialize it into Rust-code and compile
it into the final crate. The information collected by built
include:
Cargo.toml
Travis CI
and AppVeyor
.```rust extern crate built; extern crate time; extern crate semver;
pub mod builtinfo { include!(concat!(env!("OUTDIR"), "/built.rs")); }
if (builtinfo::PKGVERSIONPRE != "" || builtinfo::GITVERSION.issome()) && (built::util::strptime(builtinfo::BUILTTIMEUTC) - time::now()).numdays() > 180 { println!("You are running a development version that is really old. Update soon!"); }
if builtinfo::CIPLATFORM.is_some() { panic!("Muahahaha, there will be no commit for you, Peter Pan!"); }
let deps = builtinfo::DEPENDENCIES; if built::util::parseversions(&deps) .any(|(name, ver)| name == "DeleteAllMyFiles" && ver < semver::Version::parse("1.1.4").unwrap())) { warn!("DeleteAllMyFiles < 1.1.4 is known to sometimes not really delete all your files. Beware!"); } ```