Search code examples
scons

How to prevent scons from cleaning parent and sibling directories?


I'm working on implementing a build system using scons for a somewhat large software project. There is a directory structure which separates the code for individual libraries and programs into their own directories. With our existing make system, I can do a "make clean" in a single program directory and it will only clean the files associated with the source in that directory. If I do an "scons -c" though, it recognizes that the program depends on a slew of libraries that are in sibling (or cousin) directories and cleans all of the files for those as well. This is not what I want since I then have to rebuild all of these libraries which can take several minutes.

I have tried playing with the "NoClean()" command, but have not gotten it to work in the way I need. Given the size of the code base and complexity of the directory structure, I can't realistically have a NoClean() line for every file in every library.

Is there any way to tell scons to ignore any dependencies above the current directory when doing a clean (i.e. scons -c) ?


Solution

  • I'd love to have a good answer to this myself.

    The only solution that I can offer for now is that you get Noclean working. So in your library, you should have something like this

    lib_objs = SharedObject(source_list)
    mylib = SharedLibrary('libname', lib_objs)
    

    So for this we want to protect the library and the sources from being cleaned.

    NoClean([mylib, lib_objs])
    

    Notice that I had to split the building of the object files from the library because I want to be able to pass them to NoClean as well.