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

Viktor Dick viktordick86 at gmail.com
Fri Feb 28 10:21:57 EST 2014


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).
At the moment I do this by an external script that creates this database
by repeated calls to "g++ -MM" and saves it into a file which is then
read from my SConstruct file. Building this database inside the
SConstruct file takes too much time. I would, however, prefer some
method which works within scons and automatically sees what parts of the
database have to be rebuild.

I could probably somehow create a .dep file for each .cpp file (inside a
mirrored tree in some hidden dir) which contains the list of other .cpp
files whose objects have to be also linked whenever the object of the
.cpp in question is to be linked. I could make these dependent on the
.cpp, so they only get rebuild when necessary. I could also create
second-stage .dep2-files only for the main_*.cpp files, which are build
out of the corresponding .dep-files by recursively going through them
and collecting any sources that have to be linked for this executable.
But can I at this stage (because any such building is done after reading
the scons file if I understand correctly) collect these to give then as
source parameter to the Program()-Builder?

Any thanks appreciated.
-------------- 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/20140228/99e06394/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/20140228/99e06394/attachment-0001.pgp


More information about the Scons-users mailing list