Using BuildDir With an SConscript File

Even when using the BuildDir function, it's much more natural to use it with a subsidiary SConscript file. For example, if the src/SConscript looks like this:

      env = Environment()
      env.Program('hello.c')
    

Then our SConscript file could look like:

      BuildDir('build', 'src')
      SConscript('build/SConscript')
    

Yielding the following output:

      % ls -1 src
      SConscript
      hello.c
      % scons
      cc -c build/hello.c -o build/hello.o
      cc -o build/hello build/hello.o
      % ls -1 build
      hello
      hello.c
      hello.o
    

Notice that this is completely equivalent to the use of SConscript that we learned about in the previous section.