Crates.io | rbtag |
lib.rs | rbtag |
version | 0.3.0 |
source | src |
created_at | 2019-01-15 01:55:32.370095 |
updated_at | 2019-01-28 19:48:44.070677 |
description | A procedural macro to add build DateTime and git commit information at compile time |
homepage | |
repository | https://github.com/LivingInSyn/rbtag |
max_upload_size | |
id | 108592 |
size | 4,548 |
rbtag is a procedural macro designed to add build time information or git commit information to your crate or project.
To use the Git commit Info functionality just add #[derive(BuildInfo)]
to a struct and call .get_build_commit()
on it. The output looks like the following:
eaba6e2-dirty
OR
eaba6e2-clean
Where clean vs dirty indicates the presence of uncommited changes to tracked files in the repo.
NOTE If you have this code continue to return 'dirty', run git diff
to see what files are causing the issue.
To use the Git commit Info functionality just add #[derive(BuildDateTime)]
to a struct and call .get_build_timestamp()
on it. In order to comply with https://reproducible-builds.org/, two sources of time are possibly used the following precedence
SOURCE_DATE_EPOCH
is set, the value in this variable will be usedThe following is an example of running the below 'example' code with and without an environmental variable set
#$ cargo clean && env SOURCE_DATE_EPOCH='12345678909' cargo run
12345678901
90c2266-dirty
#? cargo clean && cargo run
1547647585
90c2266-dirty
use rbtag::{BuildDateTime, BuildInfo};
#[derive(BuildDateTime, BuildInfo)]
struct BuildTag;
fn main() {
println!("{}", BuildTag{}.get_build_timestamp());
println!("{}", BuildTag{}.get_build_commit());
}