Mesa (master): scons: Add an analyze option.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Apr 16 10:45:56 UTC 2014


Module: Mesa
Branch: master
Commit: d3c0e236f23e66cb2b4a75f5161282b2d15ff73f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3c0e236f23e66cb2b4a75f5161282b2d15ff73f

Author: José Fonseca <jfonseca at vmware.com>
Date:   Mon Apr 14 14:31:02 2014 +0100

scons: Add an analyze option.

For Clang static code analyzer, the scan-build script will produce more
comprehensive output.  Nevertheless you can invoke it as

  CC=clang CXX=clang++ scons analyze=1

For MSVC this is the best way to use its static code analysis.  Simply
invoke as

  scons analyze=1

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 common.py        |    1 +
 scons/gallium.py |   12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/common.py b/common.py
index 22c1725..d6e6215 100644
--- a/common.py
+++ b/common.py
@@ -91,6 +91,7 @@ def AddOptions(opts):
 	opts.Add(EnumOption('platform', 'target platform', host_platform,
 											 allowed_values=('cygwin', 'darwin', 'freebsd', 'haiku', 'linux', 'sunos', 'windows')))
 	opts.Add(BoolOption('embedded', 'embedded build', 'no'))
+	opts.Add(BoolOption('analyze', 'enable static code analysis where available', 'no'))
 	opts.Add('toolchain', 'compiler toolchain', default_toolchain)
 	opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no'))
 	opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
diff --git a/scons/gallium.py b/scons/gallium.py
index 42e8f7c..e873c65 100755
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -467,6 +467,18 @@ def generate(env):
             env.Append(CCFLAGS = ['/MT'])
             env.Append(SHCCFLAGS = ['/LD'])
     
+    # Static code analysis
+    if env['analyze']:
+        if env['msvc']:
+            # http://msdn.microsoft.com/en-us/library/ms173498.aspx
+            env.Append(CCFLAGS = [
+                '/analyze',
+                #'/analyze:log', '${TARGET.base}.xml',
+            ])
+        if env['clang']:
+            # scan-build will produce more comprehensive output
+            env.Append(CCFLAGS = ['--analyze'])
+
     # Assembler options
     if gcc_compat:
         if env['machine'] == 'x86':




More information about the mesa-commit mailing list