Using VariantDir With an SConscript File

SCons User Guide 0.98.0
Prev | Chapter 15. Separating Source and Build Directories | Next

# 15.5. Using `VariantDir` With an `SConscript` File

Even when using the `VariantDir` 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 `SConstruct` file could look like:

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

Yielding the following output:

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

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

Prev | Home | Next
The `VariantDir` Function | Up | Variant Builds