我如何使Clang的“扫描构建”与SCons合作? [英] How can I make Clang's "scan-build" work with SCons?

查看:323
本文介绍了我如何使Clang的“扫描构建”与SCons合作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 SCons 构建的项目,我想使用 Clang Static Analyzer 来分析代码。但是,当运行

  scan-build scons 

SCons似乎忽略了由 scan-build 引入的设置。 c> scan-build

$

工作是设置构建系统通常使用的各种环境变量(例如 make )来控制构建的发生情况。其中有些是:




  • CC - 用作C编译器的程序名称

  • CXX - 用作C ++编译器的程序名称

  • CCC _ * - 控制Clang静态分析器行为的各种环境变量



SCons通常会清除环境(运行构建之前)(这是一个功能)。为了使上述环境变量生效,在 SConstruct 中执行类似的操作:

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


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

SCons seems to ignore the settings introduced by scan-build. How can I make this work?

解决方案

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_"))

这篇关于我如何使Clang的“扫描构建”与SCons合作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆