Expand description
Compile-time build provenance shared by every Waratah binary and process.
build.rs runs vergen-gitcl at compile time and emits VERGEN_* cargo
instructions; this crate surfaces them as consts plus the version surfaces
used across the cluster:
PKG_VERSION: the workspace semver (clap--versionone-liner).version_string(): what Describe RPCs and/waratah/clustercarry — semver plus thegit describe --longoutput, e.g.0.2.0+v0.2.0-3-g1a2b3c4-dirty.build_info(): the multi-line provenance block for--build-info.
Every git field tolerates absence. vergen runs with fail_on_error off,
so a source tarball (no .git) or a repository without tags still builds.
Note vergen’s failure mode: it still emits the variable, set to the
sentinel VERGEN_IDEMPOTENT_OUTPUT (plus a cargo:warning) — option_env!
therefore never returns None for build-script-fed keys, and the consts
map the sentinel to their per-field fallback ("untagged" / "unknown")
via [real_or] below. The hand-rolled WARATAH_GIT_DESCRIBE genuinely is
unset on a tarball and falls back to "untagged".
Container/CI builds without .git can instead pin every git field from
the environment: WARATAH_GIT_DESCRIBE, VERGEN_GIT_SHA,
VERGEN_GIT_BRANCH, VERGEN_GIT_COMMIT_TIMESTAMP, and VERGEN_GIT_DIRTY.
A non-empty value wins over git discovery (and over vergen’s placeholder
emission — the overridden field is withheld from vergen and hand-emitted
verbatim; see provenance_override in build.rs). Docker builds feed
these from --build-arg / ARG plumbing.
Constants§
- BUILD_
TIMESTAMP - Wall-clock time the build script ran (UTC).
- GIT_
BRANCH - Branch checked out at compile time (
"unknown"without git). - GIT_
COMMIT_ TIMESTAMP - Committer timestamp of HEAD at compile time, RFC 3339 with the commit’s
own UTC offset (
"unknown"without git). - GIT_
DESCRIBE git describe --long --tags --dirtyfor the checked-out commit (e.g.v0.2.0-3-g1a2b3c4-dirty), degrading to the abbreviated SHA on a repository without tags and-dirtyappended when the tree had uncommitted changes at compile time."untagged"only when the build had no git at all (source tarball) — or when the variable was present but empty, which is what a container build exports for an unset build-arg (ENV WARATAH_GIT_DESCRIBE=); an empty string is no more provenance than absence.- GIT_
DIRTY "true"when the working tree had uncommitted changes at compile time.- GIT_SHA
- Abbreviated commit hash at compile time (
"unknown"without git). - PKG_
VERSION - Workspace package version (
version.workspace = truein every member). - RUSTC_
SEMVER - rustc semver that produced the binary.
- TARGET
- Target triple the binary was compiled for (plain
TARGETbuild-script env, hand-emitted asWARATAH_TARGET).
Functions§
- build_
info - Multi-line provenance block printed by the binaries’
--build-infoflag. - version_
string - Version string for Describe RPCs and
/waratah/cluster: semver plus the git describe as semver build metadata (0.2.0+v0.2.0-3-g1a2b3c4-dirty), or the bare semver when no git info was baked in. The metadata is only semver-valid when the tag name is (a+in a tag would break it); the string is opaque provenance, not something the cluster parses as semver.