Skip to content

How to `make clean`

Paul M. Rodriguez edited this page Aug 20, 2019 · 10 revisions

The short answer: don’t. The whole idea of a build system deleting files is obsolete. This should be the responsibility of version control. E.g. Git can do it for you, with git-clean:

(deftask clean
  ;; Delete only explicitly ignored files.
  (cmd "git clean -Xdf"))

This way you minimize the damage if things go wrong: git-clean will only run in a Git repository, and it will refuse to delete the .git directory, even in a sub-repository. The worst that could happen is that you lose some work you forgot to check in.

If you absolutely must delete files manually, use overlord:delete-target. This is not safe, but safer than delete-file or uiop:delete-directory-tree. It will only delete files when the path is absolute; it will only delete directory trees when called on a target constructed with directory-ref; and it will only delete files that are relative to the base of the current package.

Clone this wiki locally