Include build data in your program.
build.rs
.env!
to use them
in your program.forbid(unsafe_code)
CARGO_PKG_NAME
CARGO_PKG_VERSION
CARGO_BIN_NAME
vergen
env!
to retrieve valuesbuild-info
```toml // Cargo.toml [dependencies]
[build-dependencies] build-data = "0" ```
Add a build.rs
file next to your Cargo.toml
.
Call build_data::set_*
functions to
set variables.
```rust
// build.rs
fn main() { builddata::setGITBRANCH(); builddata::setGITCOMMIT(); builddata::setGITDIRTY(); builddata::setSOURCETIMESTAMP(); builddata::nodebug_rebuilds(); } ```
Use env!
to access the
variables in your program:
rust
// src/bin/main.rs
fn main() {
// Built from branch=release
// commit=a5547bfb1edb9712588f0f85d3e2c8ba618ac51f
// dirty=false
// source_timestamp=2021-04-14T06:25:59+00:00
println!("Built from branch={} commit={} dirty={} source_timestamp={}",
env!("GIT_BRANCH"),
env!("GIT_COMMIT"),
env!("GIT_DIRTY"),
env!("SOURCE_TIMESTAMP"),
);
}
```
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.3 1/1 44/90 2/2 0/0 0/0 ☢️ ├── chrono 0.4.19 0/19 10/311 0/0 0/0 5/27 ☢️ │ ├── libc 0.2.93 0/0 0/0 0/0 0/0 0/0 ❓ │ ├── num-integer 0.1.44 0/0 4/10 0/0 0/0 0/0 ☢️ │ │ └── num-traits 0.2.14 0/0 4/10 0/0 0/0 0/0 ☢️ │ ├── num-traits 0.2.14 0/0 0/7 0/0 0/0 0/0 ❓ │ ├── rustc-serialize 0.3.24 1/1 218/218 0/0 0/0 0/0 ☢️ │ └── time 0.1.44 0/19 10/311 0/0 0/0 5/27 ☢️ │ ├── libc 0.2.93 0/0 0/7 0/0 0/0 0/0 ❓ │ └── rustc-serialize 0.3.24 0/0 0/0 0/0 0/0 0/0 🔒 ├── safe-lock 0.1.3 0/0 0/0 0/0 0/0 0/0 🔒 └── safe-regex 0.2.3 0/0 0/0 0/0 0/0 0/0 🔒 └── safe-regex-macro 0.2.3 0/0 0/0 0/0 0/0 0/0 🔒 ├── safe-proc-macro2 1.0.24 0/0 0/0 0/0 0/0 0/0 🔒 │ └── unicode-xid 0.2.1 0/0 0/0 0/0 0/0 0/0 🔒 └── safe-regex-compiler 0.2.3 0/0 0/0 0/0 0/0 0/0 🔒 ├── safe-proc-macro2 1.0.24 0/0 0/0 0/0 0/0 0/0 🔒 └── safe-quote 1.0.9 0/0 0/0 0/0 0/0 0/0 🔒 └── safe-proc-macro2 1.0.24
2/21 276/636 2/2 0/0 5/27
```
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