[Scons-users] Identical file names in VariantDir and source dir

William Deegan bill at baddogconsulting.com
Wed Nov 14 23:42:54 EST 2012


Dmitry,

On 11/14/2012 07:27 PM, Dmitry Mikhin wrote:

> Hello everyone,

>

> Got badly bitten today.

>

> Context: a test suite is driven by SCons. The original, reference

> result for one of the problems is stored in the source directory under

> the name "sml_bd_1.txt". The same file is re-generated in the

> VariantDir build directory. The two are compared to verify that the

> project is still working.

>

> Today noticed a problem ("run_rms_scons" below is a custom builder for

> comparing files):

>

> run_rms_scons(["build/tests/Benchmarks/ASA/small_bd.passed"],

> ["build/tests/Benchmarks/ASA/sml_bd_1.txt",

> "build/tests/Benchmarks/ASA/sml_bd_1.txt", "build/util/rms"])

> "build/util/rms" build/tests/Benchmarks/ASA/sml_bd_1.txt

> build/tests/Benchmarks/ASA/sml_bd_1.txt

>

> I.e., the builder compares the built file to itself. Obviously, it

> always works fine and passes the comparison. The original reference

> file is different. Many cases all over the test base, some over a year

> old, may be more, and still digging.

>

> Although the problem is obvious, it's pretty hard to notice in a mess

> of scons run output, and the whole idea of hiding in plain sight

> worked great, once again.

>

> Now, questions:

>

> 1. Is it possible to enforce that some files are from the source

> directory, never from the Variant build directory?

You can enforce that all files aren't copied via the duplicate=0
argument to VariantDir()
(See http://scons.org/doc/production/HTML/scons-man.html and
http://scons.org/doc/production/HTML/scons-user/x3420.html)
Though that may not be what you are looking for.
You can have your builder use ${SOURCE.srcpath} instead of $SOURCE (see
manpage and search for ${SOURCE.srcpath}), which is likely your best
choice if you don't want to disable duplication.

You could also use the --duplicate command line flag or use SetOption()
to tell SCons to copy instead of soft or hard linking the files.


>

> 2. Can SCons warn about this behavior? IMO, the presence of two files

> with identical names suggests that the same node can be "created" by

> two methods, and generally SCons would catch it.


Good point. Can you file a bug with a sample SConstruct to replicate the
issue?

>

> 3. Also, I have a feeling that the "least astonishment" idea somehow

> got lost in this case. At least on me.


Understandably. That said, when working with VariantDirs it's important
to understand duplicate,etc..


>

> My scons version is:

>

> $ scons --version

> SCons by Steven Knight et al.:

> script: v2.1.0.r5357[MODIFIED], 2011/09/09 21:31:03, by bdeegan on ubuntu

> engine: v2.1.0.r5357[MODIFIED], 2011/09/09 21:31:03, by bdeegan on ubuntu

> engine path: ['/usr/lib/scons/SCons']

> Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,

> 2010, 2011 The SCons Foundation

>

>


Hope that helps!
-Bill



More information about the Scons-users mailing list