mirror of
https://git.yoctoproject.org/poky
synced 2026-09-14 21:49:33 +02:00
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. (From OE-Core rev: 918d83460639df273f38ae079ffeebd6a79b3373) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
BUILDSTATS_BASE = "${TMPDIR}/buildstats/"
|
BUILDSTATS_BASE = "${TMPDIR}/buildstats/"
|
||||||
BUILDSTATS_BNFILE = "${BUILDSTATS_BASE}/.buildname"
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Build statistics gathering.
|
# Build statistics gathering.
|
||||||
@@ -21,20 +20,6 @@ def get_cputime():
|
|||||||
fields = f.readline().rstrip().split()[1:]
|
fields = f.readline().rstrip().split()[1:]
|
||||||
return sum(int(field) for field in fields)
|
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):
|
def set_timedata(var, data, server_time=None):
|
||||||
import time
|
import time
|
||||||
if server_time:
|
if server_time:
|
||||||
@@ -65,7 +50,7 @@ def get_timedata(var, data, server_time=None):
|
|||||||
return timediff, cpuperc
|
return timediff, cpuperc
|
||||||
|
|
||||||
def write_task_data(status, logfile, e):
|
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)
|
bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
|
||||||
with open(os.path.join(logfile), "a") as f:
|
with open(os.path.join(logfile), "a") as f:
|
||||||
timedata = get_timedata("__timedata_task", e.data, e.time)
|
timedata = get_timedata("__timedata_task", e.data, e.time)
|
||||||
@@ -87,16 +72,15 @@ python run_buildstats () {
|
|||||||
import bb.data
|
import bb.data
|
||||||
import time, subprocess, platform
|
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):
|
if isinstance(e, bb.event.BuildStarted):
|
||||||
########################################################################
|
########################################################################
|
||||||
# at first pass make the buildstats heriarchy and then
|
# at first pass make the buildstats heriarchy and then
|
||||||
# set the buildname
|
# 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)
|
bb.utils.mkdirhier(bsdir)
|
||||||
set_timedata("__timedata_build", e.data)
|
set_timedata("__timedata_build", e.data)
|
||||||
build_time = os.path.join(bsdir, "build_stats")
|
build_time = os.path.join(bsdir, "build_stats")
|
||||||
@@ -111,8 +95,6 @@ python run_buildstats () {
|
|||||||
f.write("Build Started: %0.2f \n" % time.time())
|
f.write("Build Started: %0.2f \n" % time.time())
|
||||||
|
|
||||||
elif isinstance(e, bb.event.BuildCompleted):
|
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")
|
build_time = os.path.join(bsdir, "build_stats")
|
||||||
with open(build_time, "a") as f:
|
with open(build_time, "a") as f:
|
||||||
########################################################################
|
########################################################################
|
||||||
@@ -127,9 +109,6 @@ python run_buildstats () {
|
|||||||
f.write("CPU usage: %0.1f%% \n" % cpu)
|
f.write("CPU usage: %0.1f%% \n" % cpu)
|
||||||
|
|
||||||
if isinstance(e, bb.build.TaskStarted):
|
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)
|
set_timedata("__timedata_task", e.data, e.time)
|
||||||
bb.utils.mkdirhier(taskdir)
|
bb.utils.mkdirhier(taskdir)
|
||||||
# write into the task event file the name and start time
|
# 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)
|
f.write("Started: %0.2f \n" % e.time)
|
||||||
|
|
||||||
elif isinstance(e, bb.build.TaskSucceeded):
|
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)
|
write_task_data("passed", os.path.join(taskdir, e.task), e)
|
||||||
if e.task == "do_rootfs":
|
if e.task == "do_rootfs":
|
||||||
bs = os.path.join(bsdir, "build_stats")
|
bs = os.path.join(bsdir, "build_stats")
|
||||||
@@ -150,9 +126,6 @@ python run_buildstats () {
|
|||||||
f.write("Uncompressed Rootfs size: %s" % rootfs_size)
|
f.write("Uncompressed Rootfs size: %s" % rootfs_size)
|
||||||
|
|
||||||
elif isinstance(e, bb.build.TaskFailed):
|
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)
|
write_task_data("failed", os.path.join(taskdir, e.task), e)
|
||||||
########################################################################
|
########################################################################
|
||||||
# Lets make things easier and tell people where the build failed in
|
# Lets make things easier and tell people where the build failed in
|
||||||
|
|||||||
Reference in New Issue
Block a user