Coder Social home page Coder Social logo

built's Introduction

built provides a crate with information from the time it was built.

Crates.io Version Docs Build status Build Status

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:

  • 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!, like target_os and target_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 and AppVeyor.
  • The used compiler and it's version; the used documentation generator and it's version.

pub mod built_info {
    include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

info!("This is version {}{}, built for {} by {}.",
       built_info::PKG_VERSION,
       built_info::GIT_VERSION.map_or_else(|| "".to_owned(),
                                           |v| format!(" (git {})", v)),
       built_info::TARGET,
       built_info::RUSTC_VERSION);
trace!("I was built with profile \"{}\", features \"{}\" on {} using {}",
       built_info::PROFILE,
       built_info::FEATURES_STR,
       built_info::BUILT_TIME_UTC,
       built_info::DEPENDENCIES_STR);
This is version 0.1.0 (git 62eb1e2), built for x86_64-apple-darwin
by rustc 1.16.0-nightly (bf6d7b665 2017-01-15).

I was built with profile "debug", features "DEFAULT, ERR_PRINTLN"
on Thu, 16 Feb 2017 19:00:08 GMT using android_glue 0.2.1,
ansi_term 0.9.0, bitflags 0.3.3, bitflags 0.4.0, bitflags 0.6.0,
bitflags 0.7.0, block 0.1.6, built 0.1.0, byteorder 0.5.3,
bytes 0.3.0, cfg-if 0.1.0, cgl 0.1.5, cgmath 0.7.0, ...

extern crate built;
extern crate time;
extern crate semver;

pub mod built_info {
    include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

if (built_info::PKG_VERSION_PRE != "" || built_info::GIT_VERSION.is_some())
   && (built::util::strptime(built_info::BUILT_TIME_UTC) - time::now()).num_days() > 180 {
    println!("You are running a development version that is really old. Update soon!");
}

if built_info::CI_PLATFORM.is_some() {
    panic!("Muahahaha, there will be no commit for you, Peter Pan!");
}

let deps = built_info::DEPENDENCIES;
if built::util::parse_versions(&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!");
}

built's People

Contributors

adamgreig avatar lukaslueg avatar pyrrho avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.