trouble using scons with scan-build


Im trying to get scan-build to ruin with 'scons', but am running into
some issues. 'scons' clears the environment on execution, so you have
to explicitly import them again, by explicitly importing them at the
top of 'SConstruct' :

import os

And then set the compiler in :

env['CC'] = os.getenv("CC")
env['CXX'] = os.getenv("CXX")

and then running

scan-build scons
(which overrides CC and CXX)

But in the screen output issues are reported, but they dont show up in
the dir specified by '-o', and at the end of the compilation it says :

scan-build: Removing directory '/tmp/foo' because it contains no reports.

Even though I saw it report issues in the screen output.

I dont understand what is going on here ? Why are issues reported in
the screen output, but are they not saved in the dir specified by -o ?


John Smith.

Hi, John. Unfortunately, there are a LOT more environment variables being set by scan-build besides just CC and CXX -- it's the only way scan-build has to communicate with the ccc-analyzer processes that get launched for each file that's built. Is there a way to disable this environment-clearing behavior for a certain build?

I think all of our environment variables start with "CCC_", so if you end up going the manual route you can just iterate through the whole environment and copy those over.



Thanks for the response.

Sadly, I really dont know anything about scons (im just copying n
pasting creatively from the web here), but it looks like you cant
disable this clearing the env business. However, would something like
this be sufficient ? :

env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_"))


John Smith.

I think you mean this:


but yes, that probably will do the trick.



env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_"))

Seems to solve the issue