Skip to content

Commit f75673e

Browse files
committed
build-buildroot: time the build
1 parent 98e32a5 commit f75673e

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

build-buildroot

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import pathlib
66
import shutil
77
import subprocess
88
import sys
9+
import time
910
import re
1011

1112
import common
@@ -321,4 +322,8 @@ def write_configs(buildroot_configs, buildroot_config_fragments=None):
321322
if __name__ == '__main__':
322323
parser = get_argparse()
323324
args = common.setup(parser)
324-
sys.exit(main(args))
325+
start_time = time.time()
326+
exit_status = main(args)
327+
end_time = time.time()
328+
common.print_time(end_time - start_time)
329+
sys.exit(exit_status)

common.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import argparse
44
import base64
55
import copy
6+
import datetime
67
import glob
78
import imp
89
import os
@@ -13,6 +14,7 @@
1314
import stat
1415
import subprocess
1516
import sys
17+
import time
1618

1719
this = sys.modules[__name__]
1820

@@ -45,6 +47,13 @@
4547
config = imp.load_source('config', config_file)
4648
configs = {x:getattr(config, x) for x in dir(config) if not x.startswith('__')}
4749

50+
def add_build_arguments(parser):
51+
parser.add_argument(
52+
'--clean',
53+
help='Clean the build instead of building.',
54+
action='store_true',
55+
)
56+
4857
def base64_encode(string):
4958
return base64.b64encode(string.encode()).decode()
5059

@@ -144,13 +153,6 @@ def get_argparse(default_args=None, argparse_args=None):
144153
parser.set_defaults(**defaults)
145154
return parser
146155

147-
def add_build_arguments(parser):
148-
parser.add_argument(
149-
'--clean',
150-
help='Clean the build instead of building.',
151-
action='store_true',
152-
)
153-
154156
def get_elf_entry(elf_file_path):
155157
global this
156158
readelf_header = subprocess.check_output([
@@ -211,6 +213,11 @@ def print_cmd(cmd, cmd_file=None, extra_env=None):
211213
st = os.stat(cmd_file)
212214
os.chmod(cmd_file, st.st_mode | stat.S_IXUSR)
213215

216+
def print_time(ellapsed_seconds):
217+
hours, rem = divmod(ellapsed_seconds, 3600)
218+
minutes, seconds = divmod(rem, 60)
219+
print("time {:02}:{:02}:{:02}".format(int(hours), int(minutes), int(seconds)))
220+
214221
def resolve_args(defaults, args, extra_args):
215222
if extra_args is None:
216223
extra_args = {}

0 commit comments

Comments
 (0)