Enable stamping and use correct variables
In D487 stamping was introduced, but not actually enabled. This enables it.
Kubernetes also uses "volatile" stamping variables for things that logic
depends on. This is a terrible idea because
you cannot unbreak a build since volatile stamps don't trigger a rebuild.
The status variables which are not purely informational have been changed
to "stable" variables
(see https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command).
Test Plan:
By itself not really testable, but has been tested on an
upcoming revision that actually depends on stamping behaving correctly.
X-Origin-Diff: phab/D491
GitOrigin-RevId: 48dda066d56e29d10fb0f0a88a845d8caf527c98
diff --git a/.bazelrc b/.bazelrc
index 0953943..d1d18db 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -8,5 +8,5 @@
# Build with C++17.
build --cxxopt=-std=c++17
-# Set workspace status file
-build --workspace_status_command=./build/print-workspace-status.sh
+# Set workspace status file and stamp
+build --stamp --workspace_status_command=./build/print-workspace-status.sh
diff --git a/build/print-workspace-status.sh b/build/print-workspace-status.sh
index 65bcae8..bf098d0 100755
--- a/build/print-workspace-status.sh
+++ b/build/print-workspace-status.sh
@@ -20,9 +20,9 @@
cat <<EOF
KUBERNETES_gitCommit $(git rev-parse "HEAD^{commit}")
KUBERNETES_gitTreeState $KUBERNETES_gitTreeState
-KUBERNETES_gitVersion $KUBERNETES_gitVersion
-KUBERNETES_gitMajor $KUBERNETES_gitMajor
-KUBERNETES_gitMinor $KUBERNETES_gitMinor
+STABLE_KUBERNETES_gitVersion $KUBERNETES_gitVersion
+STABLE_KUBERNETES_gitMajor $KUBERNETES_gitMajor
+STABLE_KUBERNETES_gitMinor $KUBERNETES_gitMinor
KUBERNETES_buildDate $(date \
${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} \
-u +'%Y-%m-%dT%H:%M:%SZ')
diff --git a/third_party/go/kubernetes_version_def.bzl b/third_party/go/kubernetes_version_def.bzl
index bb409bf..ddd1347 100644
--- a/third_party/go/kubernetes_version_def.bzl
+++ b/third_party/go/kubernetes_version_def.bzl
@@ -28,9 +28,12 @@
stamp_vars = [
"buildDate",
"gitCommit",
+ "gitTreeState",
+ ]
+
+ stable_stamp_vars = [
"gitMajor",
"gitMinor",
- "gitTreeState",
"gitVersion",
]
@@ -39,4 +42,7 @@
for pkg in stamp_pkgs:
for var in stamp_vars:
x_defs["%s.%s" % (pkg, var)] = "{KUBERNETES_%s}" % var
+ for pkg in stamp_pkgs:
+ for var in stable_stamp_vars:
+ x_defs["%s.%s" % (pkg, var)] = "{STABLE_KUBERNETES_%s}" % var
return x_defs