When using SCons, it is unnecessary to add special
commands or target names to clean up after a build.
Instead, you simply use the
-c or --clean
option when you invoke SCons,
and SCons removes the appropriate built files.
So if we build our 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 /nologo /c hello.c /Fohello.obj
link /nologo /OUT:hello.exe hello.obj
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.