aboutsummaryrefslogtreecommitdiffstats
path: root/classes/clean.bbclass
blob: 94b97e70ed699e0e1b9416ef17de09961dcf48c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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 remove_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 () {
	if bb.data.getVar("PSTAGING_ACTIVE", d, 1) == "1":
		removepkg = bb.data.expand("${PSTAGE_PKGPN}", d)
		pstage_cleanpackage(removepkg, d)

		stagepkg = bb.data.expand("${PSTAGE_PKG}", d)
		bb.note("Removing staging package %s" % base_path_out(stagepkg, d))
		os.system('rm -rf ' + stagepkg)
	clean_stamps(d)
	remove_workdir(d)
	clean_builddir(d)
	clean_make(d)
}