-
Notifications
You must be signed in to change notification settings - Fork 13
/
apphis.py
executable file
·62 lines (48 loc) · 1.8 KB
/
apphis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import sys
import os
from os import path
import argparse
import subprocess
import re
import time
import json
import frontend_server
if __name__ == "__main__":
# Define some command line args
p = argparse.ArgumentParser()
p.add_argument("appdir", default="../RIOT/examples/hello-world", nargs="?", help="Full path to application dir")
p.add_argument("-b", action="store_true", help="Rebuild all for boards")
args = p.parse_args()
base = path.normpath(args.appdir)
app = path.basename(base);
data = {'app': app, 'boards': []}
if not path.isdir(base):
sys.exit("Error: target application folder '" + app + "' not found")
# collect information on available boards
boards = subprocess.check_output(('make', 'info-boards-supported'), cwd=base).replace('\n', '').split(' ')
for board in boards:
elffile = base + "/bin/" + board + "/" + app + ".elf"
if args.b:
os.environ['BOARD'] = board
start = time.time() * 1000
subprocess.call(('make', '-B', 'clean', 'all'), cwd=base, )
buildtime = (time.time() * 1000) - start
else:
buildtime = 0
if path.isfile(elffile):
size = subprocess.check_output(('size', elffile))
m = re.search("^ *(\d+)[ \t]+(\d+)[ \t]+(\d+)", size, re.MULTILINE)
if m:
data['boards'].append({
'board': board,
'buildtime': buildtime,
't': m.group(1),
'd': m.group(2),
'b':m.group(3)
})
# export results to json file
with open("root/sizes.json", 'w') as f:
json.dump(data, f, indent = 4)
frontend_server.run('root', 12345, 'apphis.html')