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

独自空忆成欢 提交于 2019-11-30 08:13:13

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_"))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!