[][src]Crate oysterpack_built

From a DevOps perspective, it is critical to know exactly what is deployed. oysterpack_built is used as a build-time dependency to gather application build related metadata. The information is gathered from the cargo build. It produces a Rust source file named built.rs in the project's build script output directory. The location can be obtained via:

This example is not tested
let built_rs = concat!(env!("OUT_DIR"), "/built.rs");

How to integrate within your project

This crate meant to be used in conjunction with oysterpack_app_metadata. This crate generates the application build metadata source file. oysterpack_app_metadata is used to load the application build netadata.

  1. Add the following to Cargo.toml:

    build = "build.rs"
    oysterpack_app_metadata = "0.1"
    semver = "0.9"
    chrono = "0.4"
    oysterpack_built = "0.3"
    • oysterpack_built is added as a build dependency
    • build.rs is the name of the cargo build script to use
    • oysterpack_app_metadata is used in conjuction with this crate to load the application build metadata into the domain model defined by oysterpack_app_metadata
  1. Include the following in build.rs:

    This example is not tested
    extern crate oysterpack_built;
    fn main() {
  2. The build script will write a file named built.rs into Cargo's build output directory, which will contain the following constants:

Constant Type Description
BUILT_TIME_UTC&strThe built-time in RFC822, UTC
CFG_ENDIAN&strThe endianness, given by cfg!(target_endian).
CFG_ENV&strThe toolchain-environment, given by cfg!(target_env).
CFG_FAMILY&strThe OS-family, given by cfg!(target_family).
CFG_OS&strThe operating system, given by cfg!(target_os).
CFG_POINTER_WIDTHu8The pointer width, given by cfg!(target_pointer_width).
CFG_TARGET_ARCH&strThe target architecture, given by cfg!(target_arch).
CI_PLATFORMOption<&str>The Continuous Integration platform detected during compilation.
DEBUGboolValue of DEBUG for the profile used during compilation.
FEATURES[&str; N]The features that were enabled during compilation.
FEATURES_STR&strThe features as a comma-separated string.
GIT_VERSIONOption<&str>If the crate was compiled from within a git-repository, GIT_VERSION contains HEAD's tag. The short commit id is used if HEAD is not tagged.
HOST&strThe host triple of the rust compiler.
NUM_JOBSu32The parallelism that was specified during compilation.
OPT_LEVEL&strValue of OPT_LEVEL for the profile used during compilation.
PKG_AUTHORS&strA colon-separated list of authors.
PKG_DESCRIPTION&strThe description.
PKG_HOMEPAGE&strThe homepage.
PKG_NAME&strThe name of the package.
PKG_VERSION&strThe full version.
PKG_VERSION_MAJOR&strThe major version.
PKG_VERSION_MINOR&strThe minor version.
PKG_VERSION_PATCH&strThe patch version.
PKG_VERSION_PRE&strThe pre-release version.
PROFILE&strrelease for release builds, debug for other builds.
RUSTC&strThe compiler that cargo resolved to use.
RUSTC_VERSION&strThe output of rustc -V
RUSTDOC&strThe documentation generator that cargo resolved to use.
RUSTDOC_VERSION&strThe output of rustdoc -V
DEPENDENCIES_GRAPHVIZ_DOT&strgraphviz .dot format for the effective dependency graph

The application metadata can be loaded via oysterpack_app_metadata op_build_mod!()):

This example is not tested
extern crate oysterpack_app_metadata;
extern crate chrono;
extern crate semver;

// loads the application metadata into `pub mod build {...}'

use oysterpack_app_metadata::Build;

fn main () {
    let app_build = build::get();
    // integrate the application build metadata ...


pub use build_time::run;



collects application metadata at build time