[Scons-users] How to find the directory of the invoking SConstruct

Dirk Bächle tshortik at gmx.de
Sat Jul 13 19:25:09 EDT 2013


Hi,

On 13.07.2013 22:44, Russell, J.J. wrote:

> For a variety of reasons, we discourage folk from cd'ing into directory where the SConstruct file lives to invoke the build. They have a tendency to drop crud in the directory, or worse, of accidentally invoking "rm *" via careless command line recall actions.


putting the source files under version control (if you haven't already
done so) might be another option. When using Mercury for example, a
simple "hg purge --all" would clean your tree from all additional
clutter...and you could always restore accidentally deleted files.


> We would prefer that they invoke the command using the -f <file> command line option, where 'file' usually includes a directory path. However, when doing this relative paths within the SConstruct file are misinterpreted, e.g., SConscript ('src/Sconscript') fails. This is certainly consistent with SCons not 'cd'ing into the SConstruct directory ala 'make'.

>

> One way that works is -C<directory> followed by -f<file-name>. This seems a little clunky, but, if that's the way it is intended to work, then okay.


If your top-level file is named "SConstruct", shouldn't a simple "scons
-C<directory>" be sufficient?

Finally, if you still rather have the built files separated from the
sources, you should try to do an out-of-tree build via the variant dir
option (see UserGuide, chap. 15).

Best regards,

Dirk



More information about the Scons-users mailing list