From dd3877b0ba0b7e67458107f2be1b957f373cb260 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Sun, 3 Nov 2024 14:37:04 +0500 Subject: [PATCH] Generating build time at startup --- build.py | 1 + settings.py | 27 ++++++++++----------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/build.py b/build.py index a02d77a69..d5c29f0ae 100755 --- a/build.py +++ b/build.py @@ -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' diff --git a/settings.py b/settings.py index 543c5be1e..b45b63a3b 100755 --- a/settings.py +++ b/settings.py @@ -8,26 +8,17 @@ 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 - -def build_date(): - """Dynamically generate current build date.""" - date, _ = get_current_timestamp() - return date + 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 load(build_name, localfile=None): @@ -61,6 +52,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