Skip to main content

Crate waratah_buildinfo

Crate waratah_buildinfo 

Source
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 --version one-liner).
  • version_string(): what Describe RPCs and /waratah/cluster carry — semver plus the git describe --long output, 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 --dirty for the checked-out commit (e.g. v0.2.0-3-g1a2b3c4-dirty), degrading to the abbreviated SHA on a repository without tags and -dirty appended 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 = true in every member).
RUSTC_SEMVER
rustc semver that produced the binary.
TARGET
Target triple the binary was compiled for (plain TARGET build-script env, hand-emitted as WARATAH_TARGET).

Functions§

build_info
Multi-line provenance block printed by the binaries’ --build-info flag.
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.