Skip to content

Commit

Permalink
Respect $SOURCE_DATE_EPOCH in generate_bram_types_sim.py
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
keszybz committed Oct 24, 2024
1 parent d1695ad commit ca688a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion techlibs/quicklogic/qlf_k6n10f/generate_bram_types_sim.py
Original file line number Diff line number Diff line change
@@ -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]:
Expand Down

0 comments on commit ca688a8

Please sign in to comment.