Skip to content

Commit

Permalink
Merge pull request #118 from Kixunil/document-source-date-epoch
Browse files Browse the repository at this point in the history
Document `SOURCE_DATE_EPOCH`
  • Loading branch information
baoyachi committed Oct 24, 2022
2 parents 89e1907 + 7f28404 commit 398044f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ fn main() {
println!("{}", build::CARGO_TREE); // e.g. the output of '$ cargo tree'

println!("{}", build::PROJECT_NAME); // your project name, e.g. 'shadow-rs'
// Time respects SOURCE_DATE_EPOCH environment variable - see below
println!("{}", build::BUILD_TIME); // time when start build occurred, e.g. '2020-08-16 14:50:25'
println!("{}", build::BUILD_TIME_2822); // time when start build occurred by rfc2822, e.g. 'Thu, 24 Jun 2021 21:33:59 +0800'
println!("{}", build::BUILD_TIME_3339); // time when start build occurred by rfc3339, e.g. '2021-06-24T21:33:59.972494+08:00'
Expand All @@ -136,6 +137,11 @@ fn main() {
}
```

#### Reproducibility

This tool includes the current time in the binary which would normally make it non-reproducible.
However, it respects the [`SOURCE_DATE_EPOCH` variable](https://reproducible-builds.org/docs/source-date-epoch/) - if set to a Unix timestamp it will override the value of build time.

## Clap Example

You also can use shadow-rs with [`clap`](https://github.com/baoyachi/shadow-rs/blob/master/example_shadow/src/main.rs).
Expand Down

0 comments on commit 398044f

Please sign in to comment.