aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/buildstats-summary.bbclass
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@gmail.com>2014-06-13 09:45:05 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-06-14 08:43:40 +0100
commit0069c06cc9c929de7e7d29b0381fcb36049a4401 (patch)
tree1747f160702f16ac123ac51065ab1269009ce33e /meta/classes/buildstats-summary.bbclass
parent85ce11e7b5402cc443adb8007c0e5d01f914fa74 (diff)
downloadopenembedded-core-contrib-0069c06cc9c929de7e7d29b0381fcb36049a4401.tar.gz
buildstats-summary.bbclass: Import useful bbclass from meta-mentor
This class summarizes sstate reuse at the end of the build, so you know how much of your build was done from scratch. Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Christopher Larson <kergoth@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/buildstats-summary.bbclass')
-rw-r--r--meta/classes/buildstats-summary.bbclass39
1 files changed, 39 insertions, 0 deletions
diff --git a/meta/classes/buildstats-summary.bbclass b/meta/classes/buildstats-summary.bbclass
new file mode 100644
index 0000000000..c8fbb2f1a1
--- /dev/null
+++ b/meta/classes/buildstats-summary.bbclass
@@ -0,0 +1,39 @@
+# Summarize sstate usage at the end of the build
+python buildstats_summary () {
+ if not isinstance(e, bb.event.BuildCompleted):
+ return
+
+ 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