summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-17 14:54:01 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-18 12:18:13 +0000
commit918d83460639df273f38ae079ffeebd6a79b3373 (patch)
tree73213fcc73b03c15fd2a79b8b086b95593343c69
parentf9fb02909f332365cad329352956a29cff6eba77 (diff)
downloadopenembedded-core-918d83460639df273f38ae079ffeebd6a79b3373.tar.gz
openembedded-core-918d83460639df273f38ae079ffeebd6a79b3373.tar.bz2
openembedded-core-918d83460639df273f38ae079ffeebd6a79b3373.zip
buildstats: Drop get_bn/set_pn and just use BUILDNAME
The current setting and getting of the "name" to use for buildstats is convoluted and not particularly interesting. We only need this for the e.getPkgs()[0] component of the path which is the first target listed on the commandline. This is pretty arbitrary. If we drop that piece, we can assume BUILDNAME is common for all events and simply use this and query it. If BUILDNAME did change, that would be a bug and it should be fixed elsewhere. Also take the opportunity to share some common code since the function now has the eventmask. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/buildstats.bbclass37
1 files changed, 5 insertions, 32 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 04307d8812..73e0b2ab64 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -1,5 +1,4 @@
BUILDSTATS_BASE = "${TMPDIR}/buildstats/"
-BUILDSTATS_BNFILE = "${BUILDSTATS_BASE}/.buildname"
################################################################################
# Build statistics gathering.
@@ -21,20 +20,6 @@ def get_cputime():
fields = f.readline().rstrip().split()[1:]
return sum(int(field) for field in fields)
-def set_bn(e):
- bn = e.getPkgs()[0] + "-" + e.data.getVar('MACHINE', True)
- try:
- os.remove(e.data.getVar('BUILDSTATS_BNFILE', True))
- except:
- pass
- with open(e.data.getVar('BUILDSTATS_BNFILE', True), "w") as f:
- f.write(os.path.join(bn, e.data.getVar('BUILDNAME', True)))
-
-def get_bn(e):
- with open(e.data.getVar('BUILDSTATS_BNFILE', True)) as f:
- bn = f.readline()
- return bn
-
def set_timedata(var, data, server_time=None):
import time
if server_time:
@@ -65,7 +50,7 @@ def get_timedata(var, data, server_time=None):
return timediff, cpuperc
def write_task_data(status, logfile, e):
- bn = get_bn(e)
+ bn = e.data.getVar('BUILDNAME', True)
bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
with open(os.path.join(logfile), "a") as f:
timedata = get_timedata("__timedata_task", e.data, e.time)
@@ -87,16 +72,15 @@ python run_buildstats () {
import bb.data
import time, subprocess, platform
+ bn = e.data.getVar('BUILDNAME', True)
+ bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
+ taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
+
if isinstance(e, bb.event.BuildStarted):
########################################################################
# at first pass make the buildstats heriarchy and then
# set the buildname
########################################################################
- bb.utils.mkdirhier(e.data.getVar('BUILDSTATS_BASE', True))
- set_bn(e)
- bn = get_bn(e)
-
- bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
bb.utils.mkdirhier(bsdir)
set_timedata("__timedata_build", e.data)
build_time = os.path.join(bsdir, "build_stats")
@@ -111,8 +95,6 @@ python run_buildstats () {
f.write("Build Started: %0.2f \n" % time.time())
elif isinstance(e, bb.event.BuildCompleted):
- bn = get_bn(e)
- bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
build_time = os.path.join(bsdir, "build_stats")
with open(build_time, "a") as f:
########################################################################
@@ -127,9 +109,6 @@ python run_buildstats () {
f.write("CPU usage: %0.1f%% \n" % cpu)
if isinstance(e, bb.build.TaskStarted):
- bn = get_bn(e)
- bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
- taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
set_timedata("__timedata_task", e.data, e.time)
bb.utils.mkdirhier(taskdir)
# write into the task event file the name and start time
@@ -138,9 +117,6 @@ python run_buildstats () {
f.write("Started: %0.2f \n" % e.time)
elif isinstance(e, bb.build.TaskSucceeded):
- bn = get_bn(e)
- bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
- taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
write_task_data("passed", os.path.join(taskdir, e.task), e)
if e.task == "do_rootfs":
bs = os.path.join(bsdir, "build_stats")
@@ -150,9 +126,6 @@ python run_buildstats () {
f.write("Uncompressed Rootfs size: %s" % rootfs_size)
elif isinstance(e, bb.build.TaskFailed):
- bn = get_bn(e)
- bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
- taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
write_task_data("failed", os.path.join(taskdir, e.task), e)
########################################################################
# Lets make things easier and tell people where the build failed in