Finding source files in repositories

The above example specifies that SCons will first search for files under the /usr/repository1 tree and next under the /usr/repository2 tree. SCons expects that any files it searches for will be found in the same position relative to the top-level directory. In the above example, if the hello.c file is not found in the local build tree, SCons will search first for a /usr/repository1/hello.c file and then for a /usr/repository2/hello.c file to use in its place.

So given the SConstruct file above, if the hello.c file exists in the local build directory, SCons will rebuild the hello program as normal:

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

If, however, there is no local hello.c file, but one exists in /usr/repository1, SCons will recompile the hello program from the source file it finds in the repository:

      % scons -Q
      cc -o hello.o -c /usr/repository1/hello.c
      cc -o hello hello.o
    

And similarly, if there is no local hello.c file and no /usr/repository1/hello.c, but one exists in /usr/repository2:

      % scons -Q
      cc -o hello.o -c /usr/repository2/hello.c
      cc -o hello hello.o