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

Viktor Dick viktordick86 at gmail.com
Fri Feb 28 11:48:35 EST 2014


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?

Regards,
Viktor


On 28.02.2014 16:57, Dirk Bächle wrote:

> Hi Viktor,

>

> On 28.02.2014 16:21, Viktor Dick wrote:

>> Hi.

>> I am trying to create a SConstruct file that does not have to name any

>> file explicitly. For this, I am restricting my project structure in the

>> following way: the implementation of each function or method that is

>> declared in somepath/somename.h can be found in somepath/somename.cpp

>> (or something included therein). And every file that implements a main

>> routine (I need to build multiple executables) starts with main_.

>>

>> The crucial point is to find the sources for the call to env.Program(),

>> i.e. for each main_*.cpp file I need to find the list of .h files that

>> are included there and I need to look if there is a .cpp file with the

>> same name (essentially).

>

> I'd do this in Python, right in your SConstruct/SConscript file.

>

> Create a list of all "main_*.cpp" files, scan each one of them with a

> simple regex for include statements and then compile the list of sources

> from that.

>

> Trying to map this process to SCons structures will probably not give

> you the desired result. Just put the nice feature of SConstructs being

> actual Python scripts to good use here...

>

> 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: 20952 bytes
Desc: not available
Url : http://four.pairlist.net/pipermail/scons-users/attachments/20140228/d41f8f55/attachment-0001.key


More information about the Scons-users mailing list