crates.io version license: Apache 2.0 unsafe forbidden pipeline status

build-data

Include build data in your program.

Features

Alternatives

Example

```toml // Cargo.toml [dependencies] build-data = "0"

[build-dependencies] build-data-writer = "0" ```

Add a build.rs file next to your Cargo.toml. Call build_data_writer::write to collect data and write it to the file. ```rust // build.rs use std::env; use std::path::Path;

fn main() { builddatawriter::write( &Path::new(&env::varos("OUTDIR").unwrap()) .join("build-data.txt") ).unwrap(); builddatawriter::nodebugrebuilds(); } ```

When you run cargo build, Cargo compiles and runs your build.rs which writes the file: // target/build-data.txt GIT_BRANCH:release GIT_COMMIT:a5547bfb1edb9712588f0f85d3e2c8ba618ac51f GIT_DIRTY:false HOSTNAME:builder2 RUSTC_VERSION:rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) TIME:2021-04-14T06:25:59+00:00 TIME_SECONDS:1618381559

Include and parse the file in your program. See include_str!, concat!, env!, and build_data::BuildData::new. rust // src/bin/main.rs fn main() { let bd = build_data::BuildData::new(include_str!( concat!(env!("OUT_DIR"), "/build-data.txt") )).unwrap(); // Built 2021-04-14T06:25:59+00:00 branch=release // commit=a5547bfb1edb9712588f0f85d3e2c8ba618ac51f // host=builder2 // rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) log!("{}", bd); }

Cargo Geiger Safety Report

```

Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate

Symbols: 🔒 = No unsafe usage found, declares #![forbid(unsafecode)] ❓ = No unsafe usage found, missing #![forbid(unsafecode)] ☢️ = unsafe usage found

Functions Expressions Impls Traits Methods Dependency

0/0 0/0 0/0 0/0 0/0 🔒 build-data 0.1.1

0/0 0/0 0/0 0/0 0/0

```

Changelog

To Do

Happy Contributors 🙂

Fixing bugs and adding features is easy and fast. Send us a pull request and we intend to: - Always respond within 24 hours - Provide clear & concrete feedback - Immediately make a new release for your accepted change

License: Apache-2.0