How can I make Clang's “scan-build” work with SCons?

后端 未结 1 728
南方客
南方客 2020-12-31 02:46

I\'ve got a project built with SCons and I\'m trying to use the Clang Static Analyzer to analyze the code. However, when running

scan-build scons
         


        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 03:11

    The way scan-build works is it sets up various environment variables that are usually used by build systems (such as make) to control how the build happens. Some of these are:

    • CC - name of program to use as C compiler
    • CXX - name of program to use as C++ compiler
    • CCC_* - various environment variables that control the behaviour of Clang's static analyzer

    SCons normally cleans out the environment before running a build (this is a feature). In order to make the above environment variables take effect, do something like this in SConstruct:

    env = Environment()
    env["CC"] = os.getenv("CC") or env["CC"]
    env["CXX"] = os.getenv("CXX") or env["CXX"]
    env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_"))
    

    0 讨论(0)
提交回复
热议问题