2005-08-31 10:45:47 +00:00
|
|
|
#
|
|
|
|
# Removes source after build
|
|
|
|
#
|
|
|
|
# To use it add that line to conf/local.conf:
|
|
|
|
#
|
|
|
|
# INHERIT += "rm_work"
|
|
|
|
#
|
2013-03-26 17:47:26 +00:00
|
|
|
# To inhibit rm_work for some recipes, specify them in RM_WORK_EXCLUDE.
|
2013-03-13 07:01:33 +00:00
|
|
|
# For example, in conf/local.conf:
|
|
|
|
#
|
2013-03-26 17:47:26 +00:00
|
|
|
# RM_WORK_EXCLUDE += "icu-native icu busybox"
|
2013-03-13 07:01:33 +00:00
|
|
|
#
|
2017-01-13 14:23:56 +00:00
|
|
|
# Recipes can also configure which entries in their ${WORKDIR}
|
|
|
|
# are preserved besides temp, which already gets excluded by default
|
|
|
|
# because it contains logs:
|
|
|
|
# do_install_append () {
|
|
|
|
# echo "bar" >${WORKDIR}/foo
|
|
|
|
# }
|
|
|
|
# RM_WORK_EXCLUDE_ITEMS += "foo"
|
|
|
|
RM_WORK_EXCLUDE_ITEMS = "temp"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2012-03-25 11:46:15 +00:00
|
|
|
# Use the completion scheduler by default when rm_work is active
|
2010-11-28 14:59:37 +00:00
|
|
|
# to try and reduce disk usage
|
|
|
|
BB_SCHEDULER ?= "completion"
|
|
|
|
|
2016-06-14 15:17:46 +00:00
|
|
|
# Run the rm_work task in the idle scheduling class
|
|
|
|
BB_TASK_IONICE_LEVEL_task-rm_work = "3.0"
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
do_rm_work () {
|
2013-03-26 17:47:26 +00:00
|
|
|
# If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe.
|
|
|
|
for p in ${RM_WORK_EXCLUDE}; do
|
2013-03-13 07:01:33 +00:00
|
|
|
if [ "$p" = "${PN}" ]; then
|
2013-03-26 17:47:26 +00:00
|
|
|
bbnote "rm_work: Skipping ${PN} since it is in RM_WORK_EXCLUDE"
|
2013-03-13 07:01:33 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
cd ${WORKDIR}
|
|
|
|
for dir in *
|
|
|
|
do
|
2013-05-23 07:33:43 +00:00
|
|
|
# Retain only logs and other files in temp, safely ignore
|
|
|
|
# failures of removing pseudo folers on NFS2/3 server.
|
|
|
|
if [ $dir = 'pseudo' ]; then
|
|
|
|
rm -rf $dir 2> /dev/null || true
|
2017-01-13 14:23:56 +00:00
|
|
|
elif ! echo '${RM_WORK_EXCLUDE_ITEMS}' | grep -q -w "$dir"; then
|
2005-08-31 10:45:47 +00:00
|
|
|
rm -rf $dir
|
|
|
|
fi
|
|
|
|
done
|
2013-03-02 00:02:17 +00:00
|
|
|
|
2010-10-12 14:52:07 +00:00
|
|
|
# Need to add pseudo back or subsqeuent work in this workdir
|
|
|
|
# might fail since setscene may not rerun to recreate it
|
2013-05-23 07:33:43 +00:00
|
|
|
mkdir -p ${WORKDIR}/pseudo/
|
2011-01-27 11:05:14 +00:00
|
|
|
|
|
|
|
# Change normal stamps into setscene stamps as they better reflect the
|
|
|
|
# fact WORKDIR is now empty
|
2011-02-21 12:58:06 +00:00
|
|
|
# Also leave noexec stamps since setscene stamps don't cover them
|
2011-01-27 11:05:14 +00:00
|
|
|
cd `dirname ${STAMP}`
|
|
|
|
for i in `basename ${STAMP}`*
|
|
|
|
do
|
2015-05-14 09:31:51 +00:00
|
|
|
for j in ${SSTATETASKS} do_shared_workdir
|
2011-01-27 11:05:14 +00:00
|
|
|
do
|
|
|
|
case $i in
|
|
|
|
*do_setscene*)
|
|
|
|
break
|
|
|
|
;;
|
2016-11-02 15:05:17 +00:00
|
|
|
*sigdata*|*sigbasedata*)
|
2011-05-26 09:31:35 +00:00
|
|
|
i=dummy
|
|
|
|
break
|
|
|
|
;;
|
2011-02-21 12:58:06 +00:00
|
|
|
*do_package_write*)
|
|
|
|
i=dummy
|
|
|
|
break
|
|
|
|
;;
|
2016-12-09 17:17:37 +00:00
|
|
|
*do_rootfs*|*do_image*|*do_bootimg*|*do_bootdirectdisk*|*do_vmimg*|*do_write_qemuboot_conf*)
|
2016-08-22 09:17:28 +00:00
|
|
|
i=dummy
|
|
|
|
break
|
|
|
|
;;
|
2011-02-21 12:58:06 +00:00
|
|
|
*do_build*)
|
|
|
|
i=dummy
|
|
|
|
break
|
|
|
|
;;
|
2013-03-02 00:02:17 +00:00
|
|
|
# We remove do_package entirely, including any
|
|
|
|
# sstate version since otherwise we'd need to leave 'plaindirs' around
|
|
|
|
# such as 'packages' and 'packages-split' and these can be large. No end
|
|
|
|
# of chain tasks depend directly on do_package anymore.
|
|
|
|
*do_package|*do_package.*|*do_package_setscene.*)
|
|
|
|
rm -f $i;
|
|
|
|
i=dummy
|
|
|
|
break
|
|
|
|
;;
|
2011-01-27 11:05:14 +00:00
|
|
|
*_setscene*)
|
|
|
|
i=dummy
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*$j|*$j.*)
|
|
|
|
mv $i `echo $i | sed -e "s#${j}#${j}_setscene#"`
|
|
|
|
i=dummy
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
rm -f $i
|
|
|
|
done
|
2005-08-31 10:45:47 +00:00
|
|
|
}
|
rm_work.bbclass: re-enable recursive do_rm_work_all
When rewriting the do_rm_work injection, do_rm_work_all had been
removed because it seemed obsolete, as do_build now always triggers
do_rm_work.
However, do_build does not get triggered for all recipes and thus
do_rm_work was not called for recipes that got built only
partially. For example, zlib depends indirectly on
zlib-native:do_populate_sysroot. Because of that dependency,
zlib-native got compiled, but do_rm_work was never called for it.
Re-introducing do_rm_work_all fixes that by making do_build depend on
do_rm_work_all, which then recursively depends on do_rm_work of all
dependencies. This has the unintended side-effect that do_rm_work then
also triggers additional work (like do_populate_lic) that normally
doesn't need to be done for a build. This seems like the lesser evil,
compared to an incomplete cleanup because it mostly enables the
lighter tasks after do_populate_sysroot.
The real solution would be to have two kinds of relationships: a weak
ordering relationship ("if A and B are enabled, A must run before B,
but B can also run without A") and hard dependencies ("B cannot run
unless A has run before").
(From OE-Core rev: b3de5d5795767a4b8c331fa5040166e7e410eeec)
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-03-14 15:29:32 +00:00
|
|
|
do_rm_work_all () {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
do_rm_work_all[recrdeptask] = "do_rm_work"
|
|
|
|
do_rm_work_all[noexec] = "1"
|
|
|
|
addtask rm_work_all after before do_build
|
2014-10-24 14:14:31 +00:00
|
|
|
|
|
|
|
do_populate_sdk[postfuncs] += "rm_work_populatesdk"
|
|
|
|
rm_work_populatesdk () {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
rm_work_populatesdk[cleandirs] = "${WORKDIR}/sdk"
|
|
|
|
|
2016-01-06 22:57:49 +00:00
|
|
|
do_image_complete[postfuncs] += "rm_work_rootfs"
|
2014-10-24 14:14:31 +00:00
|
|
|
rm_work_rootfs () {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
rm_work_rootfs[cleandirs] = "${WORKDIR}/rootfs"
|
|
|
|
|
2017-03-29 11:29:49 +00:00
|
|
|
# This task can be used instead of do_build to trigger building
|
|
|
|
# without also invoking do_rm_work. It only exists when rm_work.bbclass
|
|
|
|
# is active, otherwise do_build needs to be used.
|
|
|
|
#
|
|
|
|
# The intended usage is
|
|
|
|
# ${@ d.getVar('RM_WORK_BUILD_WITHOUT') or 'do_build'}
|
|
|
|
# in places that previously used just 'do_build'.
|
|
|
|
RM_WORK_BUILD_WITHOUT = "do_build_without_rm_work"
|
|
|
|
do_build_without_rm_work () {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
do_build_without_rm_work[noexec] = "1"
|
|
|
|
|
|
|
|
# We have to add these tasks already now, because all tasks are
|
2017-01-13 14:52:33 +00:00
|
|
|
# meant to be defined before the RecipeTaskPreProcess event triggers.
|
|
|
|
# The inject_rm_work event handler then merely changes task dependencies.
|
|
|
|
addtask do_rm_work
|
2017-03-29 11:29:49 +00:00
|
|
|
addtask do_build_without_rm_work
|
2017-01-13 14:52:33 +00:00
|
|
|
addhandler inject_rm_work
|
|
|
|
inject_rm_work[eventmask] = "bb.event.RecipeTaskPreProcess"
|
|
|
|
python inject_rm_work() {
|
2016-06-06 13:31:07 +00:00
|
|
|
if bb.data.inherits_class('kernel', d):
|
2016-12-14 21:13:04 +00:00
|
|
|
d.appendVar("RM_WORK_EXCLUDE", ' ' + d.getVar("PN"))
|
2015-01-07 23:45:08 +00:00
|
|
|
# If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe.
|
2016-12-14 21:13:04 +00:00
|
|
|
excludes = (d.getVar("RM_WORK_EXCLUDE") or "").split()
|
|
|
|
pn = d.getVar("PN")
|
2017-03-29 11:29:49 +00:00
|
|
|
|
|
|
|
# Determine what do_build depends upon, without including do_build
|
|
|
|
# itself or our own special do_rm_work_all.
|
|
|
|
deps = set(bb.build.preceedtask('do_build', True, d))
|
|
|
|
deps.difference_update(('do_build', 'do_rm_work_all'))
|
|
|
|
|
2015-01-07 23:45:08 +00:00
|
|
|
if pn in excludes:
|
|
|
|
d.delVarFlag('rm_work_rootfs', 'cleandirs')
|
|
|
|
d.delVarFlag('rm_work_populatesdk', 'cleandirs')
|
2017-01-13 14:52:33 +00:00
|
|
|
else:
|
|
|
|
# Inject do_rm_work into the tasks of the current recipe such that do_build
|
|
|
|
# depends on it and that it runs after all other tasks that block do_build,
|
|
|
|
# i.e. after all work on the current recipe is done. The reason for taking
|
|
|
|
# this approach instead of making do_rm_work depend on do_build is that
|
|
|
|
# do_build inherits additional runtime dependencies on
|
|
|
|
# other recipes and thus will typically run much later than completion of
|
|
|
|
# work in the recipe itself.
|
|
|
|
# In practice, addtask() here merely updates the dependencies.
|
|
|
|
bb.build.addtask('do_rm_work', 'do_build', ' '.join(deps), d)
|
2017-03-29 11:29:49 +00:00
|
|
|
|
|
|
|
# Always update do_build_without_rm_work dependencies.
|
|
|
|
bb.build.addtask('do_build_without_rm_work', '', ' '.join(deps), d)
|
2015-01-07 23:45:08 +00:00
|
|
|
}
|