SCons User Guide 0.96.90 | ||
---|---|---|
<<< Previous | Separating Source and Build Directories | Next >>> |
SCons duplicates source files in build directories because it's the most straightforward way to guarantee a correct build regardless of include-file directory paths, relative references between files, or tool support for putting files in different locations, and the SCons philosophy is to, by default, guarantee a correct build in all cases.
The most direct reason to duplicate source files in build directories is simply that some tools (mostly older vesions) are written to only build their output files in the same directory as the source files. In this case, the choices are either to build the output file in the source directory and move it to the build directory, or to duplicate the source files in the build directory.
Additionally, relative references between files can cause problems if we don't just duplicate the hierarchy of source files in the build directory. You can see this at work in use of the C preprocessor #include mechanism with double quotes, not angle brackets:
#include "file.h" |
The de facto standard behavior for most C compilers in this case is to first look in the same directory as the source file that contains the #include line, then to look in the directories in the preprocessor search path. Add to this that the SCons implementation of support for code repositories (described below) means not all of the files will be found in the same directory hierarchy, and the simplest way to make sure that the right include file is found is to duplicate the source files into the build directory, which provides a correct build regardless of the original location(s) of the source files.
Although source-file duplication guarantees a correct build even in these end-cases, it can usually be safely disabled. The next section describes how you can disable the duplication of source files in the build directory.
<<< Previous | Home | Next >>> |
Separating Source and Build Directories | Up | Telling SCons to Not Duplicate Source Files in the Build Directory |