13 from SCons
import Node
18 Autoclean directory, deleting all files which are not known to the build
19 system, like obsolete header files
23 directory = env.Dir(dirname)
28 for node
in dirnode.all_children():
29 if isinstance(node, Node.FS.Dir):
31 elif node.is_derived():
32 targets.add(str(node))
35 for (dirname, dirs, files)
in os.walk(str(directory)):
36 if "__pycache__" in dirs:
37 dirs.remove(
"__pycache__")
38 for filename
in files:
39 fullname = os.path.join(dirname, filename)
40 if fullname
not in targets
and not filename.startswith(
'.')
and not \
41 (fullname.endswith(
'.pyc')
and fullname[:-1]
in targets):
42 print(env[
'CLEANUPCOMSTR'] % fullname)
47 env.AddMethod(autoclean_dir,
'RemoveNonTargets')