blob: 05ead9fdbf133de04af9357ee6b43eb7ac8dd0b6 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Summarize sstate usage at the end of the build
2python buildstats_summary () {
3 import collections
4 import os.path
5
6 bn = get_bn(e)
7 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
8 if not os.path.exists(bsdir):
9 return
10
11 sstatetasks = (e.data.getVar('SSTATETASKS', True) or '').split()
12 built = collections.defaultdict(lambda: [set(), set()])
13 for pf in os.listdir(bsdir):
14 taskdir = os.path.join(bsdir, pf)
15 if not os.path.isdir(taskdir):
16 continue
17
18 tasks = os.listdir(taskdir)
19 for t in sstatetasks:
20 no_sstate, sstate = built[t]
21 if t in tasks:
22 no_sstate.add(pf)
23 elif t + '_setscene' in tasks:
24 sstate.add(pf)
25
26 header_printed = False
27 for t in sstatetasks:
28 no_sstate, sstate = built[t]
29 if no_sstate | sstate:
30 if not header_printed:
31 header_printed = True
32 bb.note("Build completion summary:")
33
34 bb.note(" {0}: {1}% sstate reuse ({2} setscene, {3} scratch)".format(t, 100*len(sstate)/(len(sstate)+len(no_sstate)), len(sstate), len(no_sstate)))
35}
36addhandler buildstats_summary
37buildstats_summary[eventmask] = "bb.event.BuildCompleted"