1 unstable release
Uses old Rust 2015
0.1.0 | Aug 28, 2017 |
---|
#114 in #embed
6KB
64 lines
Build metadata
use this crate to embed repository and build metadata at compile time
This project uses procedural macros to provide you with this metadata, exposing three macros:
head!()
: the name of the current git branch or tag you are incommit!()
: short git commit idtime!()
: UTC build time. This value is cached, so it will stay the same for every call in one crate. Note that using this makes the build non reproducible (since the resulting binary will change depending on build time)
Usage
Import it with cargo from crates.io
by adding this to you Cargo.toml` file:
[dependencies]
build_metadata = "^0.1"
#![feature(plugin)]
#![plugin(build_metadata)]
fn main() {
println!("build time: {}", time!());
println!("head: {}", head!());
println!("commit id: {}", commit!());
}
lib.rs
:
use this crate to embed repository and build metadata at compile time
This project uses procedural macros to provide you with this metadata, exposing three macros:
head!()
: the name of the current git branch or tag you are incommit!()
: short git commit idtime!()
: UTC build time. This value is cached, so it will stay the same for every call in one crate. Note that using this makes the build non reproducible (since the resulting binary will change depending on build time)
Example
#![feature(plugin)]
#![plugin(build_metadata)]
fn main() {
println!("build time: {}", time!());
println!("head: {}", head!());
println!("commit id: {}", commit!());
}
Dependencies
~11MB
~280K SLoC