Search code examples
c++cscons

SCons StaticLibrary not rebuilt after header change


In this example, foo.c includes foo.h. When foo.h is changed, foo.c is rebuild to foo.o, but libfoobar.a is not.

Import('env')

penv = env.Clone()
penv.Append(CPPPATH=['./'])

penv.StaticLibrary('foobar',[
        'foo.c',
        'bar.c',
    ],
)

Any hints?


Solution

  • In SCons, a decider is what determines if a target needs to be rebuilt. The default decider is MD5. This means that even if an object file is re-built, if its MD5 doesn't change, then nothing that includes / links against that object needs rebuilt. This is in contrast to Make, which uses filesystem timestamps to decide whether or not to rebuild a target.

    So, if your header file change was whitespace or otherwise insignificant, nothing above the object file in the dependency tree needs rebuilt.