diff options
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/buildstats.bbclass | 37 |
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 @@ | |||
1 | BUILDSTATS_BASE = "${TMPDIR}/buildstats/" | 1 | BUILDSTATS_BASE = "${TMPDIR}/buildstats/" |
2 | BUILDSTATS_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 | ||
24 | def 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 | |||
33 | def get_bn(e): | ||
34 | with open(e.data.getVar('BUILDSTATS_BNFILE', True)) as f: | ||
35 | bn = f.readline() | ||
36 | return bn | ||
37 | |||
38 | def set_timedata(var, data, server_time=None): | 23 | def 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 | ||
67 | def write_task_data(status, logfile, e): | 52 | def 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 |