[Scons-users] [c++] Automatically choosing sources for linking

Scott Davies scottd at gmail.com
Sat Mar 29 17:10:54 EDT 2014


I'm playing with the dependency calculation stuff in SCons using
http://www.scons.org/wiki/ExplicitlyCallCppScanner as a starting point, and
have immediately hit two problems.

1) I'm having trouble getting the scanner to pay any attention to
CPPPATH...as far as I can tell it's behaving as if the path is always set
to '.'.

Simple example (note how c.h doesn't show up as a dependency despite
CPPPATH being set in the environment):


glint:scons-test> pwd

/Users/scott/scons-test

glint:scons-test> ls

SConstruct a.cpp b.h c.h

glint:scons-test> cat a.cpp

#include "b.h"


#include "scons-test/c.h"


void test()

{

;

}

glint:scons-test> cat SConstruct

import SCons.Scanner


env = Environment(CPPPATH=['/Users/scott/','..','.'])


f = env.File("a.cpp")


scanner = SCons.Scanner.C.CScanner()

includes = scanner(f, env)

print "\na.cpp includes:"

for i in includes:

print " + %s" % str(i)


glint:scons-test> scons

scons: Reading SConscript files ...


a.cpp includes:

+ b.h

scons: done reading SConscript files.

scons: Building targets ...

scons: `.' is up to date.

scons: done building targets.

glint:scons-test> !g

g++ -I /Users/scott -c a.cpp

glint:scons-test> ls

SConstruct a.cpp a.o b.h c.h



Any idea what might be going on here? (I'm a newbie at both SCons and
Python, so I'm probably doing something stupid.)



2) In another test on my actual codebase, if I use
SCons.Scanner.C.SConsCPPScannerWrapper('prescanner','.') rather
than SCons.Scanner.C.CScanner(), the scanner crashes (causing scons to
terminate) on one of my source files thusly:

pony_jsc/jsc_agg.cpp:

File "<string>", line 1


USE(TEXTURE_MAPPER) and USE(3D_GRAPHICS) and not
"WTF_USE_TEXTURE_MAPPER_GL" in __dict__


^

where the source code in question looks like this:

#if USE(TEXTURE_MAPPER) && USE(3D_GRAPHICS) &&
!defined(WTF_USE_TEXTURE_MAPPER_GL)
#define WTF_USE_TEXTURE_MAPPER_GL 1
#endif

and USE is defined as

#define USE(WTF_FEATURE) (defined WTF_USE_##WTF_FEATURE &&
WTF_USE_##WTF_FEATURE).

Is this worth filing as a bug, or is the answer basically "Yeah, well,
don't use that scanner on code with moderately gnarly macros"?


Thanks,
-- Scott




On Fri, Mar 28, 2014 at 4:09 PM, Dirk Bächle <tshortik at gmx.de> wrote:


> On 28.03.2014 20:51, Scott Davies wrote:

>

>> Hi Dirk --

>>

>> I know that SCons can handle the header dependencies. I'm interested in

>> also automatically determining what object files need to be linked into

>> what executables (of which I have many with very different sets of

>> dependencies, because of unit tests) in order to come up with a generic

>> build system that will work on all my projects without my having it to tell

>> it anything manually (other than external library dependencies) or mess

>> around with internally created libraries (which fundamentally handicap

>> build systems by making dependencies more coarse-grained).

>>

>> Okay, since you wrote that you just started with SCons and are still in

> the evaluation phase, I was unsure about how much you already know.

>

> Thanks a lot for your clarifications, this use case scenario would

> definitely be a good example of what SCons can do, that other build systems

> can't. Now someone just has to implement it... ;)

>

> For all my personal projects so far, I got away with a simple

>

> env.Program('main', Glob('*.cpp'))

>

> . The "Glob"bing also helps for building libraries, that's how I usually

> avoid having to list each single source file.

>

>

> Regards,

>

> Dirk

>

> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

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

>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140329/5b404e26/attachment.htm


More information about the Scons-users mailing list