Skip to content

Commit

Permalink
fbt: Respect SOURCE_DATE_EPOCH when setting build date (#1421)
Browse files Browse the repository at this point in the history
* fbt: using SOURCE_DATE_EPOCH from environment for build timestamp (if set)

Co-authored-by: hedger <hedger@users.noreply.github.com>
  • Loading branch information
adisbladis and hedger authored Jul 20, 2022
1 parent e3c7201 commit ec57dd3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
import os
import json
from datetime import date
from datetime import date, datetime


class GitVersion:
Expand Down Expand Up @@ -77,9 +77,15 @@ def init(self):

def generate(self):
current_info = GitVersion(self.args.sourcedir).get_version_info()

if "SOURCE_DATE_EPOCH" in os.environ:
build_date = datetime.utcfromtimestamp(int(os.environ["SOURCE_DATE_EPOCH"]))
else:
build_date = date.today()

current_info.update(
{
"BUILD_DATE": date.today().strftime("%d-%m-%Y"),
"BUILD_DATE": build_date.strftime("%d-%m-%Y"),
"TARGET": self.args.target,
}
)
Expand Down

0 comments on commit ec57dd3

Please sign in to comment.