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:
ignore
let built_rs = concat!(env!("OUT_DIR"), "/built.rs");
Add the following to Cargo.toml:
```toml [package] build = "build.rs"
[dependencies] oysterpackappmetadata = "0.1" semver = "0.9" chrono = "0.4"
[build-dependencies] oysterpack_built = "0.3" ```
oysterpack_built
is added as a build dependencybuild.rs
is the name of the cargo build script to useInclude the following in build.rs:
```ignore extern crate oysterpack_built;
fn main() { oysterpack_built::run(); } ```
The build script will by default write a file named built.rs into Cargo's build output directory, which will contain the following constants:
Constant | Type | Description -------- | ---- | ----------- BUILTTIMEUTC|&str|The built-time in RFC822, UTC CFGENDIAN|&str|The endianness, given by cfg!(targetendian). CFGENV|&str|The toolchain-environment, given by cfg!(targetenv). CFGFAMILY|&str|The OS-family, given by cfg!(targetfamily). CFGOS|&str|The operating system, given by cfg!(targetos). CFGPOINTERWIDTH|u8|The pointer width, given by cfg!(targetpointerwidth). CFGTARGETARCH|&str|The target architecture, given by cfg!(targetarch). CIPLATFORM|Option<&str>|The Continuous Integration platform detected during compilation. DEBUG|bool|Value of DEBUG for the profile used during compilation. FEATURES|[&str; N]|The features that were enabled during compilation. FEATURESSTR|&str|The features as a comma-separated string. GITVERSION|Option<&str>|If the crate was compiled from within a git-repository, GITVERSION contains HEAD's tag. The short commit id is used if HEAD is not tagged. HOST|&str|The host triple of the rust compiler. NUMJOBS|u32|The parallelism that was specified during compilation. OPTLEVEL|&str|Value of OPTLEVEL for the profile used during compilation. PKGAUTHORS|&str|A colon-separated list of authors. PKGDESCRIPTION|&str|The description. PKGHOMEPAGE|&str|The homepage. PKGNAME|&str|The name of the package. PKGVERSION|&str|The full version. PKGVERSIONMAJOR|&str|The major version. PKGVERSIONMINOR|&str|The minor version. PKGVERSIONPATCH|&str|The patch version. PKGVERSIONPRE|&str|The pre-release version. PROFILE|&str|release for release builds, debug for other builds. RUSTC|&str|The compiler that cargo resolved to use. RUSTCVERSION|&str|The output of rustc -V RUSTDOC|&str|The documentation generator that cargo resolved to use. RUSTDOCVERSION|&str|The output of rustdoc -V DEPENDENCIESGRAPHVIZ_DOT|&str|graphviz .dot format for the effective dependency graph
The application metadata can be loaded via oysterpackappmetadata opbuildmod!()):
```ignore
extern crate oysterpackappmetadata; extern crate chrono; extern crate semver;
// loads the application metadata into `pub mod build {...}' opbuildmod!()
use oysterpackappmetadata::Build;
fn main () { let app_build = build::get(); // integrate the application build metadata ... } ```