From 99dfd88de60dd55bd3b5e7c0516b3882a8e56698 Mon Sep 17 00:00:00 2001
From: Liu Yiding <liuyd.fnst@fujitsu.com>
Date: Wed, 15 Apr 2026 06:09:37 +0000
Subject: [PATCH] Honor the SOURCE_DATE_EPOCH variable

Implement the SOURCE_DATE_EPOCH specification[1] for reproducible
builds. If SOURCE_DATE_EPOCH is set, use it as timestamp instead of the
current time.

[1] https://reproducible-builds.org/specs/source-date-epoch/

Upstream-Status: Submitted [https://github.com/mlcommons/inference/pull/2345]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>

Update for 6.0.14
Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
---
 version_generator.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/version_generator.py b/version_generator.py
index b88ae8e..b083eec 100644
--- a/version_generator.py
+++ b/version_generator.py
@@ -113,8 +113,13 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):
         # Write the version into the function definition
         ofile.write(func_def("Version", f"\"{version_contents}\""))
 
-        date_time_now_local = datetime.datetime.now().isoformat()
-        date_time_now_utc = datetime.datetime.utcnow().isoformat()
+        if os.environ.get('SOURCE_DATE_EPOCH', False):
+            source_date_epoch = int(os.environ['SOURCE_DATE_EPOCH'])
+            date_time_now_local = datetime.datetime.fromtimestamp(source_date_epoch).isoformat()
+            date_time_now_utc = datetime.datetime.fromtimestamp(source_date_epoch, tz=datetime.timezone.utc).isoformat()
+        else:
+            date_time_now_local = datetime.datetime.now().isoformat()
+            date_time_now_utc = datetime.datetime.utcnow().isoformat()
         ofile.write(
             func_def(
                 "BuildDateLocal",
-- 
2.43.0

