diff --git a/build-buildroot b/build-buildroot index 8f7e54c..2842390 100755 --- a/build-buildroot +++ b/build-buildroot @@ -6,6 +6,7 @@ import pathlib import shutil import subprocess import sys +import time import re import common @@ -321,4 +322,8 @@ def write_configs(buildroot_configs, buildroot_config_fragments=None): if __name__ == '__main__': parser = get_argparse() args = common.setup(parser) - sys.exit(main(args)) + start_time = time.time() + exit_status = main(args) + end_time = time.time() + common.print_time(end_time - start_time) + sys.exit(exit_status) diff --git a/common.py b/common.py index 4e11559..26a85bd 100644 --- a/common.py +++ b/common.py @@ -3,6 +3,7 @@ import argparse import base64 import copy +import datetime import glob import imp import os @@ -13,6 +14,7 @@ import signal import stat import subprocess import sys +import time this = sys.modules[__name__] @@ -45,6 +47,13 @@ if os.path.exists(config_file): config = imp.load_source('config', config_file) configs = {x:getattr(config, x) for x in dir(config) if not x.startswith('__')} +def add_build_arguments(parser): + parser.add_argument( + '--clean', + help='Clean the build instead of building.', + action='store_true', + ) + def base64_encode(string): return base64.b64encode(string.encode()).decode() @@ -144,13 +153,6 @@ Default: the run ID (-n) if that is an integer, otherwise 0. parser.set_defaults(**defaults) return parser -def add_build_arguments(parser): - parser.add_argument( - '--clean', - help='Clean the build instead of building.', - action='store_true', - ) - def get_elf_entry(elf_file_path): global this readelf_header = subprocess.check_output([ @@ -211,6 +213,11 @@ def print_cmd(cmd, cmd_file=None, extra_env=None): st = os.stat(cmd_file) os.chmod(cmd_file, st.st_mode | stat.S_IXUSR) +def print_time(ellapsed_seconds): + hours, rem = divmod(ellapsed_seconds, 3600) + minutes, seconds = divmod(rem, 60) + print("time {:02}:{:02}:{:02}".format(int(hours), int(minutes), int(seconds))) + def resolve_args(defaults, args, extra_args): if extra_args is None: extra_args = {}