[Scons-users] Export command and CPPPATH concatenation

Laurent laurent.belcour at inria.fr
Fri Jan 31 16:30:22 EST 2014


Hello,

I recently discover a rather strange behavior of scons using the Export/Import mechanism for sharing Environment between two SConstruct. I appears that the CPPPATH is appended with the build directory but as a string and not as an array resulting in incorrect include paths.

Here is an example:

The directory structure is like this:
laurent$ ls -R .
A SConstruct

./A:
B SConscript a.cpp

./A/B:
b.h

I have one cpp file ./A/a.cpp that needs the ./A/B/b.h file to compile as a shared library:
laurent$ cat ./A/a.cpp
#include <b.h>

int test_function(int a)
{
return a + A;
}

laurent$ cat ./A/B/b.h
#define A 10

The SConstruct and SConscript are respectively:

laurent$ cat SConstruct
env = Environment()
env.AppendUnique(CPPPATH = ['./A/B'])
Export('env')

env.SConscript('./A/SConscript'

laurent$ cat ./A/SConscript
Import('env')

env.StaticLibrary('a', 'a.cpp')

Now when running scons at the root of this toy project, I get the following error:

laurent$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o A/a.o -c -IA/A/B A/a.cpp
A/a.cpp:1:10: fatal error: 'b.h' file not found
#include <b.h>
^

Why is scons appending the CPPPATH defined in the SConstruct as a string (resulting in ‘./A/A/B’) in the SConscript and not as a list (resulting in [‘./A’, ‘./A/B’]) ? Is this the regular behavior of scons ?

My version of scons:
laurent$ scons -v
SCons by Steven Knight et al.:
script: v2.3.0, 2013/03/03 09:48:35, by garyo on reepicheep
engine: v2.3.0, 2013/03/03 09:48:35, by garyo on reepicheep
engine path: ['/usr/local/lib/scons-2.3.0/SCons']
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation

I did not find any documentation on the behavior of the Export/Import mechanism on variables such as CPPPATH. Any help or link on it would be welcomed !

Thanks,
—Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140131/216d9d47/attachment.html


More information about the Scons-users mailing list