In my Go builds, I usually include these lines:
buildInfo="`date -u '+%Y-%m-%dT%TZ'`|`git describe --always --long`|`git tag | tail -1`"
go build -ldflags "-X main.buildInfo=${buildInfo} -s -w" ./cmd/...
and then in main
, I parse buildInfo
into three separate values which can be displayed with the usage message. This allows me to see the compile timestamp, git hash, and semver number of the executable.
Is there any similar way to do this in the Rust compiler?