Skip to content

Commit

Permalink
Generating build time at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
modos189 committed Nov 3, 2024
1 parent 344ea9c commit 3d53541
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def run_cmds(cmds, source, target):


def iitc_build(source, outdir, deps_list=None):
settings.generate_timestamps()
run_cmds(settings.pre_build, source, outdir)

iitc_script = 'core/total-conversion-build.js'
Expand Down
27 changes: 11 additions & 16 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,19 @@

import time


def get_current_timestamp():
"""Get current build date and timestamp in desired formats."""
utc = time.gmtime()
return (
time.strftime('%Y-%m-%d-%H%M%S', utc), # build_date
time.strftime('%Y%m%d.%H%M%S', utc) # build_timestamp
)
_build_date = None
_build_timestamp = None


def build_timestamp():
"""Dynamically generate current build timestamp."""
_, timestamp = get_current_timestamp()
return timestamp
def generate_timestamps():
"""Generate build date and timestamp in desired formats."""
global _build_date, _build_timestamp

utc = time.gmtime()
_build_date = time.strftime('%Y-%m-%d-%H%M%S', utc)
_build_timestamp = time.strftime('%Y%m%d.%H%M%S', utc)

def build_date():
"""Dynamically generate current build date."""
date, _ = get_current_timestamp()
return date
return _build_date, _build_timestamp


def load(build_name, localfile=None):
Expand Down Expand Up @@ -61,6 +54,8 @@ def load(build_name, localfile=None):
mod = vars(__import__(__name__))
mod.pop('load')
mod['build_name'] = build_name
mod['build_date'] = lambda: _build_date
mod['build_timestamp'] = lambda: _build_timestamp
base = Path(localfile or __file__).parent
mod['build_source_dir'] = base
mod['build_target_dir'] = base / 'build' / build_name
Expand Down

0 comments on commit 3d53541

Please sign in to comment.