From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>,
"Flanagan, Elizabeth" <elizabeth.flanagan@intel.com>
Subject: [PATCH 2/7] buildstats: Drop get_bn/set_pn and just use BUILDNAME
Date: Thu, 17 Dec 2015 14:54:01 +0000 [thread overview]
Message-ID: <1450364041.13505.206.camel@linuxfoundation.org> (raw)
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>
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 04307d8..73e0b2a 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
reply other threads:[~2015-12-17 14:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450364041.13505.206.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=elizabeth.flanagan@intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox