0
votes

Is there a way to specify a file, rather than a string when passing parameters?

env = Environment(LIBPATH = "include") # problem

Export("env")

SConscript("somepath")

...

# SConscript #

Import("env")

env.Program( ... )

The problem is it'll use the directory of the SConscript, which does not have the "include" folder. I've noticed that some of the objects returned (env.Program()) that don't have this problem. When doing a out = env.Program(...) in the SConscript print out it'll return one path, then in the SConstruct it'll return another path that is the correct one fixing the relative path.

1
In addition to my answer below, I suggest you take a look at the UserGuide of SCons scons.org/doc/production/HTML/scons-user.html . Just read a bit, to get a better feel for how things are supposed to work together. - dirkbaechle

1 Answers

1
votes

Don't specify variables like LIBPATH/CPPPATH, which change for every module (library/executable), in the top-level SConstruct. Setup the compiler/linker flags that should get used by every module, and then Export() the environment as before.

Then, in the SConscript, use:

Import('env')

localEnv = env.Clone()
localEnv.Append(LIBPATH=['include'])

localEnv.Program( ... )

, where "include" is the relative path to the lib folder from the directory of the current SConscript. This will make maintenance of single modules much easier, and also provides a better starting point for things like variant builds.