8000 py/makeversionhdr: Honor SOURCE_DATE_EPOCH if present. · micropython/micropython@4fb5f01 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4fb5f01

Browse files
committed
py/makeversionhdr: Honor SOURCE_DATE_EPOCH if present.
This environment variable, if defined during the build process, indicates a fixed time that should be used in place of "now" when such a time is explicitely referenced. This allows for reproducible builds of micropython. See https://reproducible-builds.org/specs/source-date-epoch/ Signed-off-by: iTitou <moiandme@gmail.com>
1 parent ef9fde7 commit 4fb5f01

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

py/makeversionhdr.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def make_version_header(filename):
8080

8181
git_tag, git_hash = info
8282

83+
build_date = datetime.date.today()
84+
if "SOURCE_DATE_EPOCH" in os.environ:
85+
build_date = datetime.datetime.utcfromtimestamp(
86+
int(os.environ["SOURCE_DATE_EPOCH"])
87+
).date()
88+
8389
# Generate the file with the git and version info
8490
file_data = """\
8591
// This file was generated by py/makeversionhdr.py
@@ -89,7 +95,7 @@ def make_version_header(filename):
8995
""" % (
9096
git_tag,
9197
git_hash,
92-
datetime.date.today().strftime("%Y-%m-%d"),
98+
build_date.strftime("%Y-%m-%d"),
9399
)
94100

95101
# Check if the file contents changed from last time

0 commit comments

Comments
 (0)
0