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

Viktor Dick viktordick86 at gmail.com
Sat Mar 1 05:29:00 EST 2014


Hi,
I found the solution by further going through the source code of the
scanner:

includes = scanner(node,env,env.Dir(env["CPPPATH"]))

This also works with VariantDir, so I have a working solution now and it
is significantly faster than delegating the work to g++. I guess I will
create an account on the wiki page sometime in the next days and write
down the recipe there.

Thanks for your help,
Viktor

On 2014-03-01 10:37, Viktor Dick wrote:

> Hi,

> thanks for the help. Somehow the scanner returns an empty list, which

> seems to be due to the fact that the files are not in the same folder

> but in some folder that is found in env["CPPPATH"]. How do I get the

> scanner to recognize these settings? A minimal example follows:

>

> === a.cpp ===

> #include "b.h"

>

> === dir/b.h ===

>

> === SConstruct ===

> import SCons.Scanner

> env = Environment(CPPPATH=['.', "dir"])

> scanner = SCons.Scanner.C.SConsCPPScannerWrapper("prescanner",".")

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

> print scanner(f, env)

>

> If instead b.h is found in the same folder as a.cpp, it works. I also

> tried to change the second argument of SConsCPPScannerWrapper() to "dir"

> since I could not find any helpful documentation about this argument,

> but it still didn't work.

>

> Does anyone have any idea how to do a full search that also respects

> CPPPATH settings (and, for that matter VariandDir settings)?

>

> Regards,

> Viktor

>

>

>

>

> On 2014-02-28 20:10, Dirk Bächle wrote:

>> On 28.02.2014 17:48, Viktor Dick wrote:

>>> Hi,

>>> thanks for the quick answer. One problem with this solution is that

>>> there are compiler flags (mostly in src/define.h) that, among other

>>> things, control the inclusion of files, so the parsing would be more

>>> complicated that just grepping for #include (it's not even only #ifdef

>>> or #ifndef, sometimes it is "#if defined ... and #defined ..." or

>>> something alike). Delegating this task to gcc -MM (the dependency

>>> generator of gcc), which should be able to ignore the rest of the file

>>> and only look at the relevant parts, was quite slow, so I am not sure if

>>> this will work. I even managed to reduce the number of times that gcc is

>>> called to about 3 or 4 in order to reduce overhead from the call itself,

>>> but then the argument list became long and it still took a lot of time.

>>> Is it maybe possible to call the scons dependency scanner so it can find

>>> the correct includes, respecting compiler switches?

>>

>> I have added a first draft of a recipe for this to our Wiki at

>>

>> http://www.scons.org/wiki/ExplicitlyCallCppScanner

>>

>> . Please check it out, and see if you can take it from there.

>>

>> Best regards,

>>

>> Dirk

>>

>> _______________________________________________

>> Scons-users mailing list

>> Scons-users at scons.org

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0xE3CD1E09.asc
Type: application/pgp-keys
Size: 34881 bytes
Desc: not available
Url : http://four.pairlist.net/pipermail/scons-users/attachments/20140301/714d7433/attachment-0001.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
Url : http://four.pairlist.net/pipermail/scons-users/attachments/20140301/714d7433/attachment-0001.pgp


More information about the Scons-users mailing list