Add eventmask 'bb.event.BuildCompleted' for buildstats_summary handler to avoid running the codes in the handler everytime there's an event. The codes in buildstats_summary only need to run for bb.event.BuildCompleted. So add this event mask. Also, we remove the redundant isinstance() statement in the handler. (From OE-Core rev: 3b635d34d44ee65f8cf93bc180f1ccc1095f2174) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
38 lines
1.2 KiB
Text
38 lines
1.2 KiB
Text
# Summarize sstate usage at the end of the build
|
|
python buildstats_summary () {
|
|
import collections
|
|
import os.path
|
|
|
|
bn = get_bn(e)
|
|
bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
|
|
if not os.path.exists(bsdir):
|
|
return
|
|
|
|
sstatetasks = (e.data.getVar('SSTATETASKS', True) or '').split()
|
|
built = collections.defaultdict(lambda: [set(), set()])
|
|
for pf in os.listdir(bsdir):
|
|
taskdir = os.path.join(bsdir, pf)
|
|
if not os.path.isdir(taskdir):
|
|
continue
|
|
|
|
tasks = os.listdir(taskdir)
|
|
for t in sstatetasks:
|
|
no_sstate, sstate = built[t]
|
|
if t in tasks:
|
|
no_sstate.add(pf)
|
|
elif t + '_setscene' in tasks:
|
|
sstate.add(pf)
|
|
|
|
header_printed = False
|
|
for t in sstatetasks:
|
|
no_sstate, sstate = built[t]
|
|
if no_sstate | sstate:
|
|
if not header_printed:
|
|
header_printed = True
|
|
bb.note("Build completion summary:")
|
|
|
|
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)))
|
|
}
|
|
addhandler buildstats_summary
|
|
buildstats_summary[eventmask] = "bb.event.BuildCompleted"
|