Today I am facing a strange SCons behaviour.
My problem is the following (in case there is a better workaround, I am pretty new to SCons) : My SCons script is building .cu cuda files and .cpp c++ files. For the c++ files, I need the -std=c++0x flag since we are doing c++11 but nvcc doesn't really like that flag.
So what I need to do is adding temporary the flag while I am compiling C++ files, and removing it while I am compiling cuda files.
I tried something like this :
def defaultLibConstructObjs(self,targetName,env,avoided=[]):
constructedObjects=[]
oldcppflags=env["CPPFLAGS"]
print(env["CPPFLAGS"])
for ext in ["cu","c","cpp"]:
if ext == "cu":
prefix = ext
else:
prefix = ""
if ext == "cpp":
env["CPPFLAGS"]+=env["CPPONLYFLAGS"]
constructedObjects.append(self.constructObjs(targetName,env,ext,prefix,avoided))
env["CPPFLAGS"]=oldcppflags
return constructedObjects
So I would expect env["CPPFLAGS"]
to be unchanged at each loop turn, but instead of this every time my cpponlyflags
(-std=c++0x
in this case) is appended so I end up with a list with number of times I call defaultLibConstructObjs -std=c++0x
.