Date 1 - 1 of 1
Fixes for Scons scan-build tool
Just a quick fix to tidy up a few small issues I noticed with the scan-build tool I implemented in SCons. Basically, because of the way SCons sets up the environment, it wasn't passing all the environment variables required by the analyzers, which meant they were falling back to defaults and occasionally mis-behaving. This change resolves that issue.
There are also a few changes which make scons more robust when not run within scan-build - if you're attempting a scons -c, it will proceed, and will throw up an error otherwise.
Let me know if anyone has any questions/thoughts.
From 258eeb8037b955a70f27509f5e705fd063f31473 Mon Sep 17 00:00:00 2001
From: Damian Maguire <damian@...>
Date: Sun, 6 Apr 2014 15:04:11 +0100
Subject: [PATCH] SCONS: Resolve issues with scan-build tool.
There are a couple of issues with the current scan-build tool
within our scons framework, where it doesn't pass the full set of
environment variables to the underlying compiler (in this case
ccc-analyze and cxx-analyze).
In order to resolve, the tool now sets the SCons env['ENV']
variables, which forces them to be passed to the environment
under which the analyzers run.
Also added some additional logic which ensures that the
clang-analyzer cannot be invoked except when run within scan-build,
and to fix issues with compiler specification when running the clean
command (clean should proceed regardless of the compiler specified).
Signed-off-by: Damian Maguire <damian@...>
site_scons/community/linux.py | 5 +++++
site_scons/site_tools/scan-build.py | 14 ++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/site_scons/community/linux.py b/site_scons/community/linux.py
index b2a4f55..1d4b482 100644
@@ -36,6 +36,11 @@ class Linux:
tools.append( 'clang' )
tools.append( 'clang++' )
if compiler == 'clang-analyzer':
+ if 'scan-build' not in os.environ['_'] and not GetOption('clean'):
+ print 'If you wish to run with the static analyzer, please ensure ' \
+ 'you execute scons within the scan-build tool.'
+ print '\tscan-build <scan-build-arguments> scons <scons-arguments>'
+ exit (1)
if optsEnv['with_docs'] == True:
diff --git a/site_scons/site_tools/scan-build.py b/site_scons/site_tools/scan-build.py
index f60b820..0c201c8 100644
@@ -21,19 +21,29 @@ def generate(env):
- """Add Builders and construction variables for gcc to an Environment."""
+ if env.GetOption('clean'):
env['CC'] = os.environ['CC'] or 'ccc-analyzer'
env['CXX'] = os.environ['CXX'] or 'c++-analyzer'
env['CLANG'] = os.environ['CLANG']
env['CLANG_CXX'] = os.environ['CLANG_CXX']
+ env['ENV']['CC'] = env['CC']
+ env['ENV']['CXX'] = env['CXX']
+ env['ENV']['CLANG'] = env['CLANG']
+ env['ENV']['CLANG_CXX'] = env['CLANG_CXX']
for item in os.environ.items():
- print item
env[item] = item
+ env['ENV'][item] = item
+ env['ENV']['CXXFLAGS'] = env['CXXFLAGS']
+ env['ENV']['CFLAGS'] = env['CFLAGS']
|1 - 1 of 1|