2 Commits

Author SHA1 Message Date
Andreas Müller
fa22dbf4d3 instant-remote-debug.bbclass: fix sstate / multi-machine
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
2018-12-06 00:22:34 +01:00
Andreas Müller
5f0b014af3 instant-remote-debug: add sstate support
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
2018-12-05 19:26:34 +01:00

View File

@@ -6,10 +6,7 @@
# dropping helpful information. In these situations one wants to debug NOW
# without further waiting or quirky activities.
#
# To achieve, a debug sysroot is build with low cost:
#
# * All files are hard-linked to recipe's ${WORKDIR}/package
# * Additional build time for task do_copysourcestosysroot for most recipes is < 1s
# To achieve, a machine specific debug sysroot is build
#
# to enable debug sysroot build set:
# 'INHERIT += "instant-remote-debug"'
@@ -30,10 +27,10 @@
# -> Dialog 'Start Debugger' opens
# * At the first session a so called 'Kit' has to be set up (1st line -> 'Manage').
# The settings are kept so 1.-6. have to be done once only.
# 1. Create a Kit by 'Add' -> further dilaog opens
# 1. Create a Kit by 'Add' -> further dialog opens
# 2. Select an name for the Kit e.g 'OE'
# 3. Set sysroot (see INSTANT_REMOTE_PATH below):
# ${TMPDIR}/sysroot-instant-remote-${MACHINE}
# ${TMPDIR}/sysroot-instant-remote-${MACHINE_ARCH}
# 4. Select compilers (it is not necessary for debug but without QTCreator won't enable Kit) for C and C++ e.g:
# C: '<TMDIR>/sysroot-instant-native/usr/bin/arm-mortsgna-linux-gnueabi/arm-mortsgna-linux-gnueabi-gcc'
# C++: '<TMDIR>/sysroot-instant-native/usr/bin/arm-mortsgna-linux-gnueabi/arm-mortsgna-linux-gnueabi-g++'
@@ -47,43 +44,33 @@
#
# Happy debugging!!
#
# TODO:
# * Class won't work with rm_work.bbclass / rm_work_and_downloads.bbclass
# -> Implement error message
# * Class does not work properly when package data is taken from sstate cache
# -> Help appreciated
# * Class does not work properly for when changing machine
#------------------------------------------------------------------------------
# ensure necessary gdb recipes are build
EXTRA_IMAGEDEPENDS += "gdb-cross-${TARGET_ARCH} gdb"
# This is where instant sysroot is installed into
INSTANT_REMOTE_PATH = "${TMPDIR}/sysroot-instant-remote-${MACHINE}"
INSTANT_REMOTE_PATH = "${TMPDIR}/sysroot-instant-remote-${MACHINE_ARCH}"
WORK_REMOTE_PATH = "${WORKDIR}/sysroot-instant-remote"
addtask copysourcestosysroot before do_packagedata after do_package
python __anonymous () {
if d.getVar('CLASSOVERRIDE') != 'class-target':
bb.build.deltask('do_copysourcestosysroot', d)
}
do_copysourcestosysroot() {
# remove old source code / files in old manifest
rm -rf ${INSTANT_REMOTE_PATH}/usr/src/debug/${PN}
if [ -f ${INSTANT_REMOTE_PATH}/manifests/${PN} ] ; then
# remove old files from sysroot
for file in `cat ${INSTANT_REMOTE_PATH}/manifests/${PN}` ; do
rm -f ${INSTANT_REMOTE_PATH}/$file
done
# remove old manifest
rm ${INSTANT_REMOTE_PATH}/manifests/${PN}
if [ ! -d "${WORKDIR}/packages-split" -o ! -d ${WORKDIR}/package ]; then
exit 0
fi
# ---------- link source code files ----------
if [ -d ${WORKDIR}/package/usr/src/debug/${PN} ] ; then
mkdir -p ${INSTANT_REMOTE_PATH}/usr/src/debug/${PN}
mkdir -p ${WORK_REMOTE_PATH}/usr/src/debug/${PN}
cd ${WORKDIR}/package/usr/src/debug/${PN}
find . -print0 | cpio --null -pdlu ${INSTANT_REMOTE_PATH}/usr/src/debug/${PN}
find . -print0 | cpio --null -pdlu ${WORK_REMOTE_PATH}/usr/src/debug/${PN}
fi
# ---------- names of binaries and debuginfo -> manifest ----------
mkdir -p ${INSTANT_REMOTE_PATH}/manifests
mkdir -p ${WORK_REMOTE_PATH}/manifests
# get path to library-link once only
if [ "${PN}" = "glibc-locale" ] ; then
PACK_SPLIT_LIB_LINK_SEARCH_PATH=`find ${WORKDIR}/packages-split -mindepth 1 -maxdepth 1 -type d ! -name '*-dbg' ! -name '*-dev' ! -name '*-staticdev' ! -name '*-doc' ! -name 'glibc*-localedata-*' ! -name 'glibc-charmap-*' ! -name 'locale-base-*'`
@@ -115,8 +102,8 @@ do_copysourcestosysroot() {
filestripped=`echo $file | sed -e 's:\.debug/::'`
fi
# keep files in manifest
echo $file >> ${INSTANT_REMOTE_PATH}/manifests/${PN}
echo $filestripped >> ${INSTANT_REMOTE_PATH}/manifests/${PN}
echo $file >> ${WORK_REMOTE_PATH}/manifests/${PN}
echo $filestripped >> ${WORK_REMOTE_PATH}/manifests/${PN}
# check for so-file links
if echo $filestripped | grep -q '\.so'; then
soname=`basename $filestripped`
@@ -124,7 +111,7 @@ do_copysourcestosysroot() {
for link in `find $packsplit -lname $soname` ; do
# do 'root' path
link=`echo $link | sed -e 's:'$packsplit'::'`
echo $link >> ${INSTANT_REMOTE_PATH}/manifests/${PN}
echo $link >> ${WORK_REMOTE_PATH}/manifests/${PN}
done
done
fi
@@ -135,37 +122,37 @@ do_copysourcestosysroot() {
for include in `find ${WORKDIR}/packages-split/${PN}-dev/${includedir} -type f` ; do
# do 'root' path
include=`echo $include | sed -e 's:'${WORKDIR}/packages-split/${PN}-dev/'::'`
echo $include >> ${INSTANT_REMOTE_PATH}/manifests/${PN}
echo $include >> ${WORK_REMOTE_PATH}/manifests/${PN}
done
fi
# ---------- link to files in package folder from manifest ----------
if [ -f ${INSTANT_REMOTE_PATH}/manifests/${PN} ] ; then
if [ -f ${WORK_REMOTE_PATH}/manifests/${PN} ] ; then
cd ${WORKDIR}/package
for file in `cat ${INSTANT_REMOTE_PATH}/manifests/${PN}` ; do
for file in `cat ${WORK_REMOTE_PATH}/manifests/${PN}` ; do
file=`echo $file | cut -c 2-`
if [ -e $file ] ; then
echo -n $file | cpio --null -pdlu ${INSTANT_REMOTE_PATH}
echo -n $file | cpio --null -pdlu ${WORK_REMOTE_PATH}
fi
done
fi
}
# remove source code links
do_clean[cleandirs] += "${INSTANT_REMOTE_PATH}/usr/src/debug/${PN}"
addtask copysourcestosysroot after do_package before do_build
SSTATETASKS += "do_copysourcestosysroot"
do_clean_append() {
# remove binaries from mainfest
manifest = "%s/manifests/%s" % (d.expand("${INSTANT_REMOTE_PATH}"), d.expand("${PN}"))
if os.path.isfile(manifest):
bb.note("Removing all files from manifest " + manifest)
manifestfile = open(manifest, "r")
for filetoremove in manifestfile:
filetoremove = filetoremove.rstrip()
filetoremove = d.expand("${INSTANT_REMOTE_PATH}") + filetoremove
if os.path.isfile(filetoremove):
os.remove(filetoremove)
manifestfile.close()
do_copysourcestosysroot[sstate-inputdirs] = "${WORK_REMOTE_PATH}"
do_copysourcestosysroot[sstate-outputdirs] = "${INSTANT_REMOTE_PATH}"
os.remove(manifest)
# same as do package
do_copysourcestosysroot[vardeps] = "${PACKAGEBUILDPKGD} ${PACKAGESPLITFUNCS} ${PACKAGEFUNCS} ${@gen_packagevar(d)}"
do_copysourcestosysroot[stamp-extra-info] = "${MACHINE_ARCH}"
do_copysourcestosysroot[cleandirs] = "${WORK_REMOTE_PATH}"
python do_copysourcestosysroot_setscene () {
sstate_setscene(d)
}
addtask do_copysourcestosysroot_setscene
do_build[recrdeptask] += "do_copysourcestosysroot"