The AlwaysBuild Method

How SCons handles dependencies can also be affected by the AlwaysBuild method. When a file is passed to the AlwaysBuild method, like so:

      hello = Program('hello.c')
      AlwaysBuild(hello)
    

Then the specified target file (hello in our example) will always be considered out-of-date and rebuilt whenever that target file is evaluated while walking the dependency graph:

      % scons -Q
      cc -o hello.o -c hello.c
      cc -o hello hello.o
      % scons -Q
      cc -o hello hello.o
    

The AlwaysBuild function has a somewhat misleading name, because it does not actually mean the target file will be rebuilt every single time SCons is invoked. Instead, it means that the target will, in fact, be rebuilt whenever the target file is encountered while evaluating the targets specified on the command line (and their dependencies). So specifying some other target on the command line, a target that does not itself depend on the AlwaysBuild target, will still be rebuilt only if it's out-of-date with respect to its dependencies:

      % scons -Q
      cc -o hello.o -c hello.c
      cc -o hello hello.o
      % scons -Q hello.o
      scons: `hello.o' is up to date.