am-benchmarks: Add support for am387x-evm machine
[openembedded.git] / classes / clean.bbclass
blob94b97e70ed699e0e1b9416ef17de09961dcf48c6
1 def clean_builddir(d):
2         from shutil import rmtree
4         builddir = d.getVar("B", True)
5         srcdir = d.getVar("S", True)
6         if builddir != srcdir:
7                 rmtree(builddir, ignore_errors=True)
9 def clean_stamps(d):
10         from glob import glob
11         from bb import note
12         from bb.data import expand
13         from os import unlink
15         note("Removing stamps")
16         for stamp in glob(expand('${STAMP}.*', d)):
17                 try:
18                         unlink(stamp)
19                 except OSError:
20                         pass
22 def remove_workdir(d):
23         from shutil import rmtree
24         from bb import note
26         workdir = d.getVar("WORKDIR", 1)
27         note("Removing %s" % workdir)
28         rmtree(workdir, ignore_errors=True)
30 def clean_git(d):
31         from subprocess import call
33         call(["git", "clean", "-d", "-f", "-X"], cwd=d.getVar("S", True))
35 def clean_make(d):
36         import bb
38         bb.note("Running make clean")
39         try:
40                 bb.build.exec_func("__do_clean_make", d)
41         except bb.build.FuncFailed:
42                 pass
44 __do_clean_make () {
45         oe_runmake clean
48 python do_clean () {
49         if bb.data.getVar("PSTAGING_ACTIVE", d, 1) == "1":
50                 removepkg = bb.data.expand("${PSTAGE_PKGPN}", d)
51                 pstage_cleanpackage(removepkg, d)
53                 stagepkg = bb.data.expand("${PSTAGE_PKG}", d)
54                 bb.note("Removing staging package %s" % base_path_out(stagepkg, d))
55                 os.system('rm -rf ' + stagepkg)
56         clean_stamps(d)
57         remove_workdir(d)
58         clean_builddir(d)
59         clean_make(d)