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