Skip to main content

Crate codewhale_build_support

Crate codewhale_build_support 

Source
Expand description

Shared build-script helpers for the codewhale-cli, codewhale-tui, and codewhale-telemetry build scripts: rerun-condition declarations, the embedded DEEPSEEK_BUILD_VERSION metadata, and the release-only build sha. Only call these functions from a build script — they emit cargo: directives on stdout.

Two different shas live here and they are not interchangeable. DEEPSEEK_BUILD_VERSION/CODEWHALE_BUILD_COMMIT describe the build the environment asked for (DEEPSEEK_BUILD_SHA/GITHUB_SHA); an unstamped local build renders a (dev) marker instead. CODEWHALE_RELEASE_BUILD_SHA describes a published binary and has no fallback at all, because it leaves the machine.

§Why the stamp never reads the local checkout (#5245)

These helpers used to watch .git/HEAD/refs and fall back to git rev-parse HEAD, so every local commit invalidated the two largest compile units in the workspace (a ~14-minute release rebuild with zero code changes). And the alternative — resolving the sha at runtime — would lie: the binary runs inside users’ repositories, and a stale binary would report whatever the checkout’s HEAD is now, which breaks the dogfood-receipt identity scripts/release/install-dogfood.sh verifies. So the contract is: a sha appears in the version string only when the build environment supplied one (DEEPSEEK_BUILD_SHA wins over GITHUB_SHA), the build script reruns only when those variables change, and a build nobody stamped says (dev). CI and release builds are byte-identical to the old behavior; dogfood builds pass the sha explicitly (the install script prints the exact command).

Functions§

declare_release_sha_rerun
Declare the rerun conditions for emit_release_build_sha alone: the two release-CI SHA variables, and nothing about the local checkout.
declare_rerun_conditions
Declare the rerun conditions for the build-metadata directives: the two SHA-override environment variables, and deliberately nothing about the local checkout — watching .git files is what made every local commit rebuild the whole crate (#5245).
emit_build_version
Emit cargo:rustc-env=DEEPSEEK_BUILD_VERSION=... — the package version, suffixed with the short build SHA when the environment supplied one (DEEPSEEK_BUILD_SHA, then GITHUB_SHA), or with the literal dev marker when it did not. CODEWHALE_BUILD_COMMIT is emitted only in the stamped case.
emit_release_build_sha
Emit cargo:rustc-env=CODEWHALE_RELEASE_BUILD_SHA=... — the first 12 hex characters of the build sha — only when the build environment supplied one.
release_build_sha
The decision behind emit_release_build_sha, with the environment injected so it can be tested without mutating the process.