summaryrefslogtreecommitdiff
path: root/meta/classes/toaster.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/toaster.bbclass')
-rw-r--r--meta/classes/toaster.bbclass188
1 files changed, 73 insertions, 115 deletions
diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass
index 1c0703c680..296e4764f0 100644
--- a/meta/classes/toaster.bbclass
+++ b/meta/classes/toaster.bbclass
@@ -33,6 +33,7 @@ python toaster_layerinfo_dumpdata() {
def _get_git_branch(layer_path):
branch = subprocess.Popen("git symbolic-ref HEAD 2>/dev/null ", cwd=layer_path, shell=True, stdout=subprocess.PIPE).communicate()[0]
+ branch = branch.decode('utf-8')
branch = branch.replace('refs/heads/', '').rstrip()
return branch
@@ -79,7 +80,7 @@ python toaster_layerinfo_dumpdata() {
return layer_info
- bblayers = e.data.getVar("BBLAYERS", True)
+ bblayers = e.data.getVar("BBLAYERS")
llayerinfo = {}
@@ -112,103 +113,39 @@ def _toaster_load_pkgdatafile(dirpath, filepath):
pass # ignore lines without valid key: value pairs
return pkgdata
-python toaster_package_dumpdata_setscene() {
- """
- Dumps the data created by package_setscene
- """
- # replicate variables from the package.bbclass
- packages = d.getVar('PACKAGES', True)
- pkgdatadir = d.getVar('PKGDATA_DIR', True)
- # scan and send data for each package
- lpkgdata = {}
- for pkg in packages.split():
- try:
- lpkgdata = _toaster_load_pkgdatafile(pkgdatadir + "/runtime/", pkg)
- except:
- # these are typically foo-locale which actually point into foo-locale-<language> in runtime-rprovides
- bb.note("toaster_package_dumpdata_setscene: failed to load pkg information for: %s:%s"%(pkg,sys.exc_info()[0]))
- # Fire an event containing the pkg data
- bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d)
-
-}
-
-
python toaster_package_dumpdata() {
"""
- Dumps the data created by emit_pkgdata
+ Dumps the data about the packages created by a recipe
"""
- # replicate variables from the package.bbclass
- packages = d.getVar('PACKAGES', True)
- pkgdatadir = d.getVar('PKGDESTWORK', True)
-
- # scan and send data for each package
+ # No need to try and dumpdata if the recipe isn't generating packages
+ if not d.getVar('PACKAGES'):
+ return
+ pkgdatadir = d.getVar('PKGDESTWORK')
lpkgdata = {}
- for pkg in packages.split():
-
- lpkgdata = _toaster_load_pkgdatafile(pkgdatadir + "/runtime/", pkg)
-
- # Fire an event containing the pkg data
- bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d)
+ datadir = os.path.join(pkgdatadir, 'runtime')
+
+ # scan and send data for each generated package
+ for datafile in os.listdir(datadir):
+ if not datafile.endswith('.packaged'):
+ lpkgdata = _toaster_load_pkgdatafile(datadir, datafile)
+ # Fire an event containing the pkg data
+ bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d)
}
# 2. Dump output image files information
-python toaster_image_dumpdata() {
- """
- Image filename for output images is not standardized.
- image_types.bbclass will spell out IMAGE_CMD_xxx variables that actually
- have hardcoded ways to create image file names in them.
- So we look for files starting with the set name.
-
- We also look for other files in the images/ directory which don't
- match IMAGE_NAME, such as the kernel bzImage, modules tarball etc.
- """
-
- dir_to_walk = d.getVar('DEPLOY_DIR_IMAGE', True);
- image_name = d.getVar('IMAGE_NAME', True);
- image_info_data = {}
- artifact_info_data = {}
-
- # collect all images and artifacts in the images directory
- for dirpath, dirnames, filenames in os.walk(dir_to_walk):
- for filename in filenames:
- full_path = os.path.join(dirpath, filename)
- try:
- if filename.startswith(image_name):
- # image
- image_info_data[full_path] = os.stat(full_path).st_size
- else:
- # other non-image artifact
- if not os.path.islink(full_path):
- artifact_info_data[full_path] = os.stat(full_path).st_size
- except OSError as e:
- bb.event.fire(bb.event.MetadataEvent("OSErrorException", e), d)
-
- bb.event.fire(bb.event.MetadataEvent("ImageFileSize", image_info_data), d)
- bb.event.fire(bb.event.MetadataEvent("ArtifactFileSize", artifact_info_data), d)
-}
-
python toaster_artifact_dumpdata() {
"""
- Dump data about artifacts in the SDK_DEPLOY directory
+ Dump data about SDK variables
"""
- dir_to_walk = d.getVar("SDK_DEPLOY", True)
- artifact_info_data = {}
+ event_data = {
+ "TOOLCHAIN_OUTPUTNAME": d.getVar("TOOLCHAIN_OUTPUTNAME")
+ }
- # collect all artifacts in the sdk directory
- for dirpath, dirnames, filenames in os.walk(dir_to_walk):
- for filename in filenames:
- full_path = os.path.join(dirpath, filename)
- try:
- if not os.path.islink(full_path):
- artifact_info_data[full_path] = os.stat(full_path).st_size
- except OSError as e:
- bb.event.fire(bb.event.MetadataEvent("OSErrorException", e), d)
-
- bb.event.fire(bb.event.MetadataEvent("ArtifactFileSize", artifact_info_data), d)
+ bb.event.fire(bb.event.MetadataEvent("SDKArtifactInfo", event_data), d)
}
# collect list of buildstats files based on fired events; when the build completes, collect all stats and fire an event with collected data
@@ -220,11 +157,11 @@ python toaster_collect_task_stats() {
import bb.utils
import os
- toaster_statlist_file = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), "toasterstatlist")
-
- if not e.data.getVar('BUILDSTATS_BASE', True):
+ if not e.data.getVar('BUILDSTATS_BASE'):
return # if we don't have buildstats, we cannot collect stats
+ toaster_statlist_file = os.path.join(e.data.getVar('BUILDSTATS_BASE'), "toasterstatlist")
+
def stat_to_float(value):
return float(value.strip('% \n\r'))
@@ -309,7 +246,7 @@ python toaster_buildhistory_dump() {
import re
BUILDHISTORY_DIR = e.data.expand("${TOPDIR}/buildhistory")
BUILDHISTORY_DIR_IMAGE_BASE = e.data.expand("%s/images/${MACHINE_ARCH}/${TCLIBC}/"% BUILDHISTORY_DIR)
- pkgdata_dir = e.data.getVar("PKGDATA_DIR", True)
+ pkgdata_dir = e.data.getVar("PKGDATA_DIR")
# scan the build targets for this build
@@ -317,6 +254,7 @@ python toaster_buildhistory_dump() {
allpkgs = {}
files = {}
for target in e._pkgs:
+ target = target.split(':')[0] # strip ':<task>' suffix from the target
installed_img_path = e.data.expand(os.path.join(BUILDHISTORY_DIR_IMAGE_BASE, target))
if os.path.exists(installed_img_path):
images[target] = {}
@@ -327,8 +265,7 @@ python toaster_buildhistory_dump() {
with open("%s/installed-package-sizes.txt" % installed_img_path, "r") as fin:
for line in fin:
line = line.rstrip(";")
- psize, px = line.split("\t")
- punit, pname = px.split(" ")
+ psize, punit, pname = line.split()
# this size is "installed-size" as it measures how much space it takes on disk
images[target][pname.strip()] = {'size':int(psize)*1024, 'depends' : []}
@@ -350,15 +287,22 @@ python toaster_buildhistory_dump() {
images[target][dependsname] = {'size': 0, 'depends' : []}
images[target][pname]['depends'].append((dependsname, deptype))
- with open("%s/files-in-image.txt" % installed_img_path, "r") as fin:
- for line in fin:
- lc = [ x for x in line.strip().split(" ") if len(x) > 0 ]
- if lc[0].startswith("l"):
- files[target]['syms'].append(lc)
- elif lc[0].startswith("d"):
- files[target]['dirs'].append(lc)
- else:
- files[target]['files'].append(lc)
+ # files-in-image.txt is only generated if an image file is created,
+ # so the file entries ('syms', 'dirs', 'files') for a target will be
+ # empty for rootfs builds and other "image" tasks which don't
+ # produce image files
+ # (e.g. "bitbake core-image-minimal -c populate_sdk")
+ files_in_image_path = "%s/files-in-image.txt" % installed_img_path
+ if os.path.exists(files_in_image_path):
+ with open(files_in_image_path, "r") as fin:
+ for line in fin:
+ lc = [ x for x in line.strip().split(" ") if len(x) > 0 ]
+ if lc[0].startswith("l"):
+ files[target]['syms'].append(lc)
+ elif lc[0].startswith("d"):
+ files[target]['dirs'].append(lc)
+ else:
+ files[target]['files'].append(lc)
for pname in images[target]:
if not pname in allpkgs:
@@ -379,15 +323,28 @@ python toaster_buildhistory_dump() {
}
-# dump information related to license manifest path
-
-python toaster_licensemanifest_dump() {
- deploy_dir = d.getVar('DEPLOY_DIR', True);
- image_name = d.getVar('IMAGE_NAME', True);
-
- data = { 'deploy_dir' : deploy_dir, 'image_name' : image_name }
-
- bb.event.fire(bb.event.MetadataEvent("LicenseManifestPath", data), d)
+# get list of artifacts from sstate manifest
+python toaster_artifacts() {
+ if e.taskname in ["do_deploy", "do_image_complete", "do_populate_sdk", "do_populate_sdk_ext"]:
+ d2 = d.createCopy()
+ d2.setVar('FILE', e.taskfile)
+ # Use 'stamp-extra-info' if present, else use workaround
+ # to determine 'SSTATE_MANMACH'
+ extrainf = d2.getVarFlag(e.taskname, 'stamp-extra-info')
+ if extrainf:
+ d2.setVar('SSTATE_MANMACH', extrainf)
+ else:
+ if "do_populate_sdk" == e.taskname:
+ d2.setVar('SSTATE_MANMACH', d2.expand("${MACHINE}${SDKMACHINE}"))
+ else:
+ d2.setVar('SSTATE_MANMACH', d2.expand("${MACHINE}"))
+ manifest = oe.sstatesig.sstate_get_manifest_filename(e.taskname[3:], d2)[0]
+
+ if os.access(manifest, os.R_OK):
+ with open(manifest) as fmanifest:
+ artifacts = [fname.strip() for fname in fmanifest]
+ data = {"task": e.taskid, "artifacts": artifacts}
+ bb.event.fire(bb.event.MetadataEvent("TaskArtifacts", data), d2)
}
# set event handlers
@@ -400,17 +357,18 @@ toaster_collect_task_stats[eventmask] = "bb.event.BuildCompleted bb.build.TaskSu
addhandler toaster_buildhistory_dump
toaster_buildhistory_dump[eventmask] = "bb.event.BuildCompleted"
-do_packagedata_setscene[postfuncs] += "toaster_package_dumpdata_setscene "
-do_packagedata_setscene[vardepsexclude] += "toaster_package_dumpdata_setscene "
+addhandler toaster_artifacts
+toaster_artifacts[eventmask] = "bb.runqueue.runQueueTaskSkipped bb.runqueue.runQueueTaskCompleted"
+
+do_packagedata_setscene[postfuncs] += "toaster_package_dumpdata "
+do_packagedata_setscene[vardepsexclude] += "toaster_package_dumpdata "
do_package[postfuncs] += "toaster_package_dumpdata "
do_package[vardepsexclude] += "toaster_package_dumpdata "
-do_image_complete[postfuncs] += "toaster_image_dumpdata "
-do_image_complete[vardepsexclude] += "toaster_image_dumpdata "
+#do_populate_sdk[postfuncs] += "toaster_artifact_dumpdata "
+#do_populate_sdk[vardepsexclude] += "toaster_artifact_dumpdata "
-do_rootfs[postfuncs] += "toaster_licensemanifest_dump "
-do_rootfs[vardepsexclude] += "toaster_licensemanifest_dump "
+#do_populate_sdk_ext[postfuncs] += "toaster_artifact_dumpdata "
+#do_populate_sdk_ext[vardepsexclude] += "toaster_artifact_dumpdata "
-do_populate_sdk[postfuncs] += "toaster_artifact_dumpdata "
-do_populate_sdk[vardepsexclude] += "toaster_artifact_dumpdata "