2.4. Cleaning Up After a Build

For cleaning up your build tree, SCons provides a "clean" mode, selected by the -c or --clean option when you invoke SCons. SCons selects the same set of targets it would in build mode, but instead of building, removes them. That means you can control what is cleaned in exactly the same way as you control what gets built. If you build the C example above and then invoke scons -c afterwards, the output on POSIX looks like:

% scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cc -o hello.o -c hello.c
cc -o hello hello.o
scons: done building targets.
% scons -c
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
Removed hello.o
Removed hello
scons: done cleaning targets.

And the output on Windows looks like:

C:\>scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fohello.obj /c hello.c /nologo
link /nologo /OUT:hello.exe hello.obj
embedManifestExeCheck(target, source, env)
scons: done building targets.
C:\>scons -c
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
Removed hello.obj
Removed hello.exe
scons: done cleaning targets.

Notice that SCons changes its output to tell you that it is Cleaning targets ... and done cleaning targets.