[Scons-users] Code organization

Dirk Bächle tshortik at gmx.de
Thu Jan 16 16:00:03 EST 2014


Hi Russell,

On 16.01.2014 19:11, Russell, J.J. wrote:

> THE PROBLEM

> This is a request for some best practices advice on laying out directories for target specific code and not using the preprocessor (which SCONs does not run) within the code to select the proper target specific code.

>

> BACKGROUND

> In the cross-development environment we operate within, there is the issue of how to handle target specific C and C++ code. The two common tactics are

>

> 1) Using the preprocessor #ifdef’s

> 2) Using #include’s of the form

> #include “package/target-specific/xx.h”

>

> We discouraged #1, since it just litters the code, rendering it difficult to read and try to confine the target specific stuff to includes.

>

> For the #include’s we further discourage this construct

>

> #if defined (TARGET1)

> # include “package/TARGET1/xx.h”

> #elif defined (TARGET2)

> # include “package/TARGET2/xx.h”

> etc.


this looks like you try to "wink in" different trees of include files
for each target. The Repository() function might be what you're looking
for, UserGuide, chap. 22, "Building From Code Repositories":

http://www.scons.org/doc/production/HTML/scons-user/c4041.html

Best regards,

Dirk




More information about the Scons-users mailing list