Build: stamp the real commit into the version string

Builds were reporting whichever commit cmake last configured against, not the
one being built. rpcs3/git-version.h is generated at CONFIGURE time, and
build-variants.sh deliberately skips reconfiguring an already-correct build
dir because re-running cmake regenerates LLVM's headers and costs a full
rebuild. So the stamp froze, and every build after that lied about itself.

The gap was wide. HEAD is 20120-da26a455; the header on disk still said
19985-91952ae4, a commit from before 0.9.2.

This is not cosmetic. A tester running 0.9.3 reported that older commit in
their log, which sent an investigation hunting for a regression among upstream
ISO changes their build did not contain, and very nearly had a fix built and
sent for a version they were not running. A build that misreports itself makes
every report from it ambiguous.

stamp-git-version.sh writes the header from HEAD and is called by both build
entry points before anything compiles. It only writes when the contents differ,
so an unchanged HEAD does not force a rebuild, and ninja rebuilds just the
translation units that include it.
This commit is contained in:
jpolo1224
2026-08-20 12:43:45 -04:00
parent da26a45548
commit eaba425972
3 changed files with 47 additions and 0 deletions
+3
View File
@@ -88,6 +88,9 @@ NDK_DIR="$(ls -d "$ANDROID_HOME/ndk/"*/ 2>/dev/null | sort -V | tail -1)"
STRIP="${NDK_DIR}toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip"
[ -x "$STRIP" ] || { echo "FAIL: llvm-strip not found under $ANDROID_HOME/ndk" >&2; exit 1; }
# Same reason as build-variants.sh: cmake only regenerates this at configure time.
bash "$HERE/stamp-git-version.sh"
echo "==> Staging the legacy core"
mkdir -p "$JNI"
"$STRIP" --strip-unneeded -o "$JNI/libarmsx3-core.so" "$CORE_SRC"
+4
View File
@@ -188,6 +188,10 @@ build_variant() {
echo "==> $name: $out"
}
# Stamp the version before anything builds, or every APK reports whichever commit cmake
# last configured against rather than the one being built.
bash "$ROOT/android/stamp-git-version.sh"
for v in $VARIANTS; do
build_variant "$v"
done
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# Refresh rpcs3/git-version.h from the current HEAD.
#
# cmake generates this header, but only when it CONFIGURES, and build-variants.sh deliberately
# skips reconfiguring an already-correct build dir because re-running cmake regenerates LLVM's
# generated headers and costs a full rebuild. So the version stamp froze at whenever cmake last
# ran, and every build after that reported an old commit.
#
# That is not cosmetic. A tester on 0.9.3 reported a 0.9.1-era commit in their log, which sent
# an investigation looking for a regression in commits their build did not contain. A build that
# misreports itself makes every bug report ambiguous.
#
# Writing the header directly is enough: ninja sees it change and rebuilds only what includes it.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUT="$ROOT/rpcs3/git-version.h"
cd "$ROOT"
COUNT="$(git rev-list HEAD --count)"
SHA="$(git rev-parse --short=8 HEAD)"
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
NEW="// This is a generated file.
#define RPCS3_GIT_VERSION \"${COUNT}-${SHA}\"
#define RPCS3_GIT_BRANCH \"${BRANCH}\"
#define RPCS3_GIT_FULL_BRANCH \"local_build\"
// If you don't want this file to update/recompile, change to 1.
#define RPCS3_GIT_VERSION_NO_UPDATE 0"
# Only write when it differs, so an unchanged HEAD does not force a rebuild.
if [ ! -f "$OUT" ] || [ "$(cat "$OUT")" != "$NEW" ]; then
printf '%s' "$NEW" > "$OUT"
echo "==> git-version.h: ${COUNT}-${SHA} (${BRANCH})"
else
echo "==> git-version.h already current: ${COUNT}-${SHA}"
fi