summaryrefslogtreecommitdiff
path: root/classes/clean.bbclass
diff options
context:
space:
mode:
authorChris Larson <clarson@mvista.com>2009-08-26 14:44:04 -0700
committerChris Larson <clarson@mvista.com>2009-08-26 14:45:02 -0700
commit2259a81628ac8bafb19e2b9ba9acca1c0dad341d (patch)
tree882d8973bd7e114c22e801aa044308307784034b /classes/clean.bbclass
parentd007a914d5e38dfefdeb7383b3be309b50aa36a9 (diff)
srctree, clean: cleanup & split out do_clean bits into clean.bbclass.
Signed-off-by: Chris Larson <clarson@mvista.com>
Diffstat (limited to 'classes/clean.bbclass')
-rw-r--r--classes/clean.bbclass53
1 files changed, 53 insertions, 0 deletions
diff --git a/classes/clean.bbclass b/classes/clean.bbclass
new file mode 100644
index 0000000000..65c1ab5d76
--- /dev/null
+++ b/classes/clean.bbclass
@@ -0,0 +1,53 @@
+def clean_builddir(d):
+ from shutil import rmtree
+
+ builddir = d.getVar("B", True)
+ srcdir = d.getVar("S", True)
+ if builddir != srcdir:
+ rmtree(builddir, ignore_errors=True)
+
+def clean_stamps(d):
+ from glob import glob
+ from bb import note
+ from bb.data import expand
+ from os import unlink
+
+ note("Removing stamps")
+ for stamp in glob(expand('${STAMP}.*', d)):
+ try:
+ unlink(stamp)
+ except OSError:
+ pass
+
+def clean_workdir(d):
+ from shutil import rmtree
+ from bb import note
+
+ workdir = d.getVar("WORKDIR", 1)
+ note("Removing %s" % workdir)
+ rmtree(workdir, ignore_errors=True)
+
+def clean_git(d):
+ from subprocess import call
+
+ call(["git", "clean", "-d", "-f", "-X"], cwd=d.getVar("S", True))
+
+def clean_make(d):
+ import bb
+
+ bb.note("Running make clean")
+ try:
+ bb.build.exec_func("__do_clean_make", d)
+ except bb.build.FuncFailed:
+ pass
+
+__do_clean_make () {
+ oe_runmake clean
+}
+
+python do_clean () {
+ clean_stamps(d)
+ clean_workdir(d)
+ clean_builddir(d)
+ clean_make(d)
+}