summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2013-11-01 16:09:44 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-11-04 10:52:45 (GMT)
commit73293c64815f15fd671ebbfca9bea1b8df0d7f46 (patch)
treec27e6e107db9ef53fa56f9b9853de6a74f955f5c
parentd7b8f82a64c5fbdbe276e65c3965ffc41b7fbab6 (diff)
downloadpoky-73293c64815f15fd671ebbfca9bea1b8df0d7f46.tar.gz
toaster: add class to dump toaster-tracked data
Adding a new bbclass that will collect and send relevant data from the task context to the Toaster UI. This bbclass consists of postfuncs that get executed right after the main task func, and in the same context. This allows data gathering in a synchronous manner during the build, guaranteeing data integrity. This approach also preserves the task signatures. The data is moved to the UI through the event system. There is no performance impact if the class is disabled. License is MIT. (From OE-Core rev: 1d2d37d579492b63d20ff8aa890a43b9a1576cf0) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/toaster.bbclass110
1 files changed, 110 insertions, 0 deletions
diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass
new file mode 100644
index 0000000..7dbb384
--- /dev/null
+++ b/meta/classes/toaster.bbclass
@@ -0,0 +1,110 @@
1#
2# Toaster helper class
3#
4# Copyright (C) 2013 Intel Corporation
5#
6# Released under the MIT license (see COPYING.MIT)
7#
8# This bbclass is designed to extract data used by OE-Core during the build process,
9# for recording in the Toaster system.
10# The data access is synchronous, preserving the build data integrity across
11# different builds.
12#
13# The data is transferred through the event system, using the MetadataEvent objects.
14#
15# The model is to enable the datadump functions as postfuncs, and have the dump
16# executed after the real taskfunc has been executed. This prevents task signature changing
17# is toaster is enabled or not. Build performance is not affected if Toaster is not enabled.
18#
19# To enable, use INHERIT in local.conf:
20#
21# INHERIT += "toaster"
22#
23#
24#
25#
26
27# 1. Dump package file info data
28
29python toaster_package_dumpdata() {
30 """
31 Dumps the data created by emit_pkgdata
32 """
33 # replicate variables from the package.bbclass
34
35 packages = d.getVar('PACKAGES', True)
36 pkgdest = d.getVar('PKGDEST', True)
37
38 pkgdatadir = d.getVar('PKGDESTWORK', True)
39
40
41 # scan and send data for each package
42 import ast
43 import fnmatch
44
45 lpkgdata = {}
46 for pkg in packages.split():
47
48 subdata_file = pkgdatadir + "/runtime/%s" % pkg
49 lpkgdata = {}
50
51 sf = open(subdata_file, "r")
52 line = sf.readline()
53 while line:
54 (n, v) = line.rstrip().split(":", 1)
55 if pkg in n:
56 n = n.replace("_" + pkg, "")
57 lpkgdata[n] = v.strip()
58 line = sf.readline()
59 pkgsplitname = os.path.join(pkgdest, pkg)
60 # replace FILES_INFO data with a dictionary of file name - file size
61 if n == 'FILES_INFO':
62 filesizedata = {}
63 val = v.strip().replace('\\\'', '\'')
64 dictval = ast.literal_eval(val)
65 for parent, dirlist in dictval.items():
66 idx = parent.find(pkgsplitname)
67 if idx > -1:
68 parent = parent[idx+len(pkgsplitname):]
69 else:
70 bb.error("Invalid path while looking for file ", parent)
71 for basename in dirlist:
72 fullpath = os.path.join(parent, basename)
73 try:
74 filesizedata[fullpath] = os.stat(pkgsplitname + fullpath).st_size
75 except OSError:
76 # we may hit a symlink that is not pointing correctly over package-split
77 filesizedata[fullpath] = 0
78 lpkgdata[n] = filesizedata
79
80 # Fire an event containing the pkg data
81 bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d)
82}
83
84# 2. Dump output image files information
85
86python toaster_image_dumpdata() {
87 """
88 Image filename for output images is not standardized.
89 image_types.bbclass will spell out IMAGE_CMD_xxx variables that actually
90 have hardcoded ways to create image file names in them.
91 So we look for files starting with the set name.
92 """
93
94 deploy_dir_image = d.getVar('DEPLOY_DIR_IMAGE', True);
95 image_name = d.getVar('IMAGE_NAME', True);
96
97 image_info_data = {}
98
99 for dirpath, dirnames, filenames in os.walk(deploy_dir_image):
100 for fn in filenames:
101 if fn.startswith(image_name):
102 image_info_data[dirpath + fn] = os.stat(os.path.join(dirpath, fn)).st_size
103
104 bb.event.fire(bb.event.MetadataEvent("ImageFileSize",image_info_data), d)
105}
106
107
108do_package[postfuncs] += "toaster_package_dumpdata "
109
110do_rootfs[postfuncs] += "toaster_image_dumpdata "