From ca688a8793ac649ad3974aaaf73d2a385af2fac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 24 Oct 2024 11:33:53 +0200 Subject: [PATCH] Respect $SOURCE_DATE_EPOCH in generate_bram_types_sim.py The variable is set in build environments to allow the build to be reproducible (identical result in independent builds), see https://reproducible-builds.org/docs/source-date-epoch/. The code snippet is based on the sample from that page too. I'm working on build reproducibility of Fedora packages, and this patch fixes an issue observed in test rebuilds. --- .../quicklogic/qlf_k6n10f/generate_bram_types_sim.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/techlibs/quicklogic/qlf_k6n10f/generate_bram_types_sim.py b/techlibs/quicklogic/qlf_k6n10f/generate_bram_types_sim.py index e57c04a0887..97a1333bbce 100644 --- a/techlibs/quicklogic/qlf_k6n10f/generate_bram_types_sim.py +++ b/techlibs/quicklogic/qlf_k6n10f/generate_bram_types_sim.py @@ -1,10 +1,17 @@ +import os import sys +import time from datetime import datetime, timezone def generate(filename): + build_date = datetime.fromtimestamp( + int(os.environ.get('SOURCE_DATE_EPOCH', time.time())), + tz=timezone.utc, + ) + with open(filename, "w") as f: f.write("// **AUTOGENERATED FILE** **DO NOT EDIT**\n") - f.write(f"// Generated by {sys.argv[0]} at {datetime.now(timezone.utc)}\n") + f.write(f"// Generated by {sys.argv[0]} at {build_date}\n") f.write("`timescale 1ns /10ps\n") for a_width in [1,2,4,9,18,36]: