Reputation: 323
I've got a scons build using a simple, common directory setup:
project/
SConstruct
src/
file.cpp
SConscript
include/
namespace/
header.h
In file.cpp, I include header.h via #include "namespace/header.h" so what I want to do is simply add the include directory to the include path list. From the source (and SConscript) point of view, that path is "../include" but the build command always has an invalid path for the include in it. I've tried the following in the SConscript:
env.Append(CPPPATH = ["#include"])
env.Append(CPPPATH = [Dir("include")])
env.Append(CPPPATH = [os.getcwd() + os.sep + ".." + os.sep + "include"])
env.Append(CPPPATH = ["../include"])
env.Append(CPPPATH = ["#../include"])
none of which seem to work. The first four give "-Iinclude" while the last puts the include at the directory level above project! Here's the full SConscript
env = Environment()
import os
target_name = "device"
source_files = Split("""
file.cpp
""")
env.Append(CPPPATH = ["#include", os.environ.get("SYSTEMC_PATH"),
os.environ.get("SYSTEMC_TLM_PATH"), os.environ.get("BOOST_PATH")])
object_list = env.SharedObject(source = source_files)
targetobj = env.SharedLibrary(target = target_name, source = object_list )
Default(targetobj)
And the SConstruct is just:
import sys
SConscript('src/SConscript', variant_dir='Release-'+sys.platform, duplicate=0, exports={'MODE':'release'})
SConscript('src/SConscript', variant_dir='Debug-'+sys.platform, duplicate=0, exports={'MODE':'debug'})
I'm running scons from the directory where the SConstruct is located (i.e. the top level directory).
I've done some looking and according to the scons doco, the # is supposed to tell scons to generate the path from the current directory of the SConscript (which is the src directory) - I'm assuming this is instead of the SConstruct directory??? Further, I can't see any questions out there about this particular problem (on this site or via Google in general), usually I'm just hitting people asking for scons scripts for exactly the setup I've got already (which is to add "include" to the CPPPATH).
Any thoughts on where this is going awry?
Upvotes: 2
Views: 2231
Reputation: 11896
'#' is relative to the top-level SConstruct, as per the SCons manual http://scons.org/doc/HTML/scons-user/x3240.html
The scripts you provide above build successfully when I recreate the tree you specify. Here's the working output:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o Release-cygwin/file.os -c -Iinclude src/file.cpp
g++ -o Release-cygwin/device.dll -shared Release-cygwin/file.os
g++ -o Debug-cygwin/file.os -c -Iinclude src/file.cpp
g++ -o Debug-cygwin/device.dll -shared Debug-cygwin/file.os
scons: done building targets.
Upvotes: 4