summaryrefslogtreecommitdiffstats
path: root/meta/classes/buildstats.bbclass
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:18 +0000
commit7b1e48f9c7d5c2f62eefbb0bf67d158c72c82757 (patch)
tree7e24f4fc4fc386a70ca0af6ed8438d0fec623d7b /meta/classes/buildstats.bbclass
parent78371629b84dcd5c9fae39a8b454c9c9f071b6ff (diff)
downloadpoky-7b1e48f9c7d5c2f62eefbb0bf67d158c72c82757.tar.gz
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>
Diffstat (limited to 'meta/classes/buildstats.bbclass')
-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 @@
1BUILDSTATS_BASE = "${TMPDIR}/buildstats/" 1BUILDSTATS_BASE = "${TMPDIR}/buildstats/"
2BUILDSTATS_BNFILE = "${BUILDSTATS_BASE}/.buildname"
3 2
4################################################################################ 3################################################################################
5# Build statistics gathering. 4# Build statistics gathering.
@@ -21,20 +20,6 @@ def get_cputime():
21 fields = f.readline().rstrip().split()[1:] 20 fields = f.readline().rstrip().split()[1:]
22 return sum(int(field) for field in fields) 21 return sum(int(field) for field in fields)
23 22
24def set_bn(e):
25 bn = e.getPkgs()[0] + "-" + e.data.getVar('MACHINE', True)
26 try:
27 os.remove(e.data.getVar('BUILDSTATS_BNFILE', True))
28 except:
29 pass
30 with open(e.data.getVar('BUILDSTATS_BNFILE', True), "w") as f:
31 f.write(os.path.join(bn, e.data.getVar('BUILDNAME', True)))
32
33def get_bn(e):
34 with open(e.data.getVar('BUILDSTATS_BNFILE', True)) as f:
35 bn = f.readline()
36 return bn
37
38def set_timedata(var, data, server_time=None): 23def set_timedata(var, data, server_time=None):
39 import time 24 import time
40 if server_time: 25 if server_time:
@@ -65,7 +50,7 @@ def get_timedata(var, data, server_time=None):
65 return timediff, cpuperc 50 return timediff, cpuperc
66 51
67def write_task_data(status, logfile, e): 52def write_task_data(status, logfile, e):
68 bn = get_bn(e) 53 bn = e.data.getVar('BUILDNAME', True)
69 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn) 54 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
70 with open(os.path.join(logfile), "a") as f: 55 with open(os.path.join(logfile), "a") as f:
71 timedata = get_timedata("__timedata_task", e.data, e.time) 56 timedata = get_timedata("__timedata_task", e.data, e.time)
@@ -87,16 +72,15 @@ python run_buildstats () {
87 import bb.data 72 import bb.data
88 import time, subprocess, platform 73 import time, subprocess, platform
89 74
75 bn = e.data.getVar('BUILDNAME', True)
76 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
77 taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
78
90 if isinstance(e, bb.event.BuildStarted): 79 if isinstance(e, bb.event.BuildStarted):
91 ######################################################################## 80 ########################################################################
92 # at first pass make the buildstats heriarchy and then 81 # at first pass make the buildstats heriarchy and then
93 # set the buildname 82 # set the buildname
94 ######################################################################## 83 ########################################################################
95 bb.utils.mkdirhier(e.data.getVar('BUILDSTATS_BASE', True))
96 set_bn(e)
97 bn = get_bn(e)
98
99 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
100 bb.utils.mkdirhier(bsdir) 84 bb.utils.mkdirhier(bsdir)
101 set_timedata("__timedata_build", e.data) 85 set_timedata("__timedata_build", e.data)
102 build_time = os.path.join(bsdir, "build_stats") 86 build_time = os.path.join(bsdir, "build_stats")
@@ -111,8 +95,6 @@ python run_buildstats () {
111 f.write("Build Started: %0.2f \n" % time.time()) 95 f.write("Build Started: %0.2f \n" % time.time())
112 96
113 elif isinstance(e, bb.event.BuildCompleted): 97 elif isinstance(e, bb.event.BuildCompleted):
114 bn = get_bn(e)
115 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
116 build_time = os.path.join(bsdir, "build_stats") 98 build_time = os.path.join(bsdir, "build_stats")
117 with open(build_time, "a") as f: 99 with open(build_time, "a") as f:
118 ######################################################################## 100 ########################################################################
@@ -127,9 +109,6 @@ python run_buildstats () {
127 f.write("CPU usage: %0.1f%% \n" % cpu) 109 f.write("CPU usage: %0.1f%% \n" % cpu)
128 110
129 if isinstance(e, bb.build.TaskStarted): 111 if isinstance(e, bb.build.TaskStarted):
130 bn = get_bn(e)
131 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
132 taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
133 set_timedata("__timedata_task", e.data, e.time) 112 set_timedata("__timedata_task", e.data, e.time)
134 bb.utils.mkdirhier(taskdir) 113 bb.utils.mkdirhier(taskdir)
135 # write into the task event file the name and start time 114 # write into the task event file the name and start time
@@ -138,9 +117,6 @@ python run_buildstats () {
138 f.write("Started: %0.2f \n" % e.time) 117 f.write("Started: %0.2f \n" % e.time)
139 118
140 elif isinstance(e, bb.build.TaskSucceeded): 119 elif isinstance(e, bb.build.TaskSucceeded):
141 bn = get_bn(e)
142 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
143 taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
144 write_task_data("passed", os.path.join(taskdir, e.task), e) 120 write_task_data("passed", os.path.join(taskdir, e.task), e)
145 if e.task == "do_rootfs": 121 if e.task == "do_rootfs":
146 bs = os.path.join(bsdir, "build_stats") 122 bs = os.path.join(bsdir, "build_stats")
@@ -150,9 +126,6 @@ python run_buildstats () {
150 f.write("Uncompressed Rootfs size: %s" % rootfs_size) 126 f.write("Uncompressed Rootfs size: %s" % rootfs_size)
151 127
152 elif isinstance(e, bb.build.TaskFailed): 128 elif isinstance(e, bb.build.TaskFailed):
153 bn = get_bn(e)
154 bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
155 taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
156 write_task_data("failed", os.path.join(taskdir, e.task), e) 129 write_task_data("failed", os.path.join(taskdir, e.task), e)
157 ######################################################################## 130 ########################################################################
158 # Lets make things easier and tell people where the build failed in 131 # Lets make things easier and tell people where the build failed in