[Scons-users] Error while refreshing build settings

Michael Potter michael at potter.name
Fri Feb 15 08:13:57 EST 2013


Dirk,

This is a _very_ important feature to me, so I want to get to the
bottom of this.

I did some more testing and It seems to work without the explicite
dependency (see below).
I added an additional line in the SConscript file for a header that is
never referenced with an include. It did not build (good).

Can you help me find a situation where the dependency would not be found?

I am a newbie and appreciate your guidance on getting the best
configuration possible.

[pottmi at CentOS6-3 sconstest]$ scons -c
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
Removed build/joker.h
Removed build/diamond.o
Removed build/queen.o
Removed build/diamond
Removed directory build
scons: done cleaning targets.

[pottmi at CentOS6-3 sconstest]$ rm .sconsign.dblite

[pottmi at CentOS6-3 sconstest]$ find . -type f
./.project
./SConstruct
./.cproject
./.in
./sconstest2.zip
./source/queen.h
./source/diamond.c
./source/joker.txt
./source/queen.c
./source/SConscript

[pottmi at CentOS6-3 sconstest]$ scons build/diamond
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
make_define(["build/joker.h"], ["source/joker.txt"])
gcc -o build/diamond.o -c -g -Ibuild -Isource source/diamond.c
gcc -o build/queen.o -c -g -Ibuild -Isource source/queen.c
gcc -o build/diamond build/diamond.o build/queen.o
scons: done building targets.

[pottmi at CentOS6-3 sconstest]$ cat SCon*
buildDirectory = 'build'
environment = Environment()
environment.Append(CPPPATH='#' + buildDirectory)
SConscript('source/SConscript', exports='environment',
variant_dir=buildDirectory, duplicate=0)
Clean('.', buildDirectory)

[pottmi at CentOS6-3 sconstest]$ cat source/SCon*
Import('environment')

environment['CCFLAGS'] = '-g'

def make_define(target, source, env):
assert len(target) == 1
assert len(source) == 1
srcf = str(source[0])
dstf = str(target[0])
with open(srcf, "r") as f:
contents = f.readline().rstrip()
with open( dstf, "w") as outf:
outf.write('#define joker "' + contents + '"')

#environment.Command('joker.h', 'joker.txt', make_define)

bld = Builder(action = make_define)
environment.Append(BUILDERS = {'make_define': bld})
environment.make_define('joker.h', 'joker.txt')
environment.make_define('jokerX.h', 'joker.txt')

#environment.Depends('diamond.o', 'joker.h')
environment.Program('diamond', ['diamond.c', 'queen.c'])




On Thu, Feb 14, 2013 at 6:43 PM, Dirk Bächle <tshortik at gmx.de> wrote:

> Hi Michael,

>

> just a few comments from my side that hopefully help you with the further

> setup of your project:

>

>

> On 14.02.2013 20:45, Michael Potter wrote:

>>

>> On Thu, Feb 14, 2013 at 1:34 PM, Russel Winder <russel at winder.org.uk>

>> wrote:

>>>

>>> On Wed, 2013-02-13 at 22:04 -0500, Michael Potter wrote:

>>> […]

>>>

>> I have a #include "gensrc/joker.h" in diamond.c, so that should signal

>> scons that it is a dependency. That dependency detection works if I

>> do in-source build, but does not work if I do a out-of-source build.

>

>

> Correct, for the in-source-tree build, SCons scans 'source/src/diamond.c' as

> a child of 'source/src/diamond.o'. This file exists already and contains the

> #include reference to 'joker.h', so SCons can pick the dependency up

> automatically.

> But for the out-of-source configuration it builds 'build/src/diamond.o' and

> therefore tries to scan 'build/src/diamond.c', which isn't there yet. :(

>

>

>> As a test, I removed this line from your proposed solution:

>> environment.Depends('diamond.o', 'joker.h')

>> Dependency detection still worked. So I think that line was redundant

>> with the automatic dependency detection. That is good.

>>

>

> My guess is, that so far you probably always did a full build (simply called

> "scons" without specifying any targets) and were extremely lucky that

> "joker.h" accidentally got built first in some cases.

> Please try a

>

> scons build/diamond

>

> (specifying 'build/diamond' as the only target) for your out-of-source-tree

> configuration, without an existing "joker.h". It can't work like that...you

> really need to set an explicit dependency:

>

> joker = env.make_define('gensrc/joker.h', 'src/joker.txt')

> env.Depends('src/diamond.c', joker)

>

> in order to provide enough info and get SCons started in all build cases.

>

> Best regards and "Happy SConsing",

>

> Dirk

>

>

> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

> http://four.pairlist.net/mailman/listinfo/scons-users




--
Michael Potter
Tapp Solutions, LLC
Replatform Technologies, LLC
+1 770 815 6142 ** Atlanta ** michael at potter.name **
www.linkedin.com/in/michaelpotter


More information about the Scons-users mailing list