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>
This commit is contained in:
parent
ef9fde7339
commit
4fb5f012c3
|
@ -80,6 +80,12 @@ def make_version_header(filename):
|
||||||
|
|
||||||
git_tag, git_hash = info
|
git_tag, git_hash = info
|
||||||
|
|
||||||
|
build_date = datetime.date.today()
|
||||||
|
if "SOURCE_DATE_EPOCH" in os.environ:
|
||||||
|
build_date = datetime.datetime.utcfromtimestamp(
|
||||||
|
int(os.environ["SOURCE_DATE_EPOCH"])
|
||||||
|
).date()
|
||||||
|
|
||||||
# Generate the file with the git and version info
|
# Generate the file with the git and version info
|
||||||
file_data = """\
|
file_data = """\
|
||||||
// This file was generated by py/makeversionhdr.py
|
// This file was generated by py/makeversionhdr.py
|
||||||
|
@ -89,7 +95,7 @@ def make_version_header(filename):
|
||||||
""" % (
|
""" % (
|
||||||
git_tag,
|
git_tag,
|
||||||
git_hash,
|
git_hash,
|
||||||
datetime.date.today().strftime("%Y-%m-%d"),
|
build_date.strftime("%Y-%m-%d"),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if the file contents changed from last time
|
# Check if the file contents changed from last time
|
||||||
|
|
Loading…
Reference in New Issue