diff options
author | marha <marha@users.sourceforge.net> | 2014-04-23 22:47:55 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2014-04-23 22:47:55 +0200 |
commit | 24fb0da18f1c44dfa1f76d8cde8efbb958aa7659 (patch) | |
tree | 76157bb2f88c9383b0824476a9e3a9f9a1bff9fa /mesalib/scons/gallium.py | |
parent | 6876c31f186414ce975180af79902314c8cdc82a (diff) | |
parent | d26ea2f474c48afa7d3c261572da5d85b7b62bd8 (diff) | |
download | vcxsrv-24fb0da18f1c44dfa1f76d8cde8efbb958aa7659.tar.gz vcxsrv-24fb0da18f1c44dfa1f76d8cde8efbb958aa7659.tar.bz2 vcxsrv-24fb0da18f1c44dfa1f76d8cde8efbb958aa7659.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
mesalib/include/GL/glext.h
xorg-server/.gitignore
xorg-server/glx/glxext.c
Diffstat (limited to 'mesalib/scons/gallium.py')
-rw-r--r-- | mesalib/scons/gallium.py | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py index e11d4dba3..d13d0e67b 100644 --- a/mesalib/scons/gallium.py +++ b/mesalib/scons/gallium.py @@ -36,6 +36,8 @@ import os.path import re import subprocess import platform as _platform +import sys +import tempfile import SCons.Action import SCons.Builder @@ -104,6 +106,28 @@ def num_jobs(): return 1 +def check_cc(env, cc, expr, cpp_opt = '-E'): + # Invoke C-preprocessor to determine whether the specified expression is + # true or not. + + sys.stdout.write('Checking for %s ... ' % cc) + + source = tempfile.NamedTemporaryFile(suffix='.c', delete=False) + source.write('#if !(%s)\n#error\n#endif\n' % expr) + source.close() + + pipe = SCons.Action._subproc(env, [env['CC'], cpp_opt, source.name], + stdin = 'devnull', + stderr = 'devnull', + stdout = 'devnull') + result = pipe.wait() == 0 + + os.unlink(source.name) + + sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))]) + return result + + def generate(env): """Common environment generation code""" @@ -137,10 +161,18 @@ def generate(env): if os.environ.has_key('LDFLAGS'): env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) - env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') - env['msvc'] = env['CC'] == 'cl' + # Detect gcc/clang not by executable name, but through pre-defined macros + # as autoconf does, to avoid drawing wrong conclusions when using tools + # that overrice CC/CXX like scan-build. + env['gcc'] = 0 + env['clang'] = 0 + env['msvc'] = 0 + if _platform.system() == 'Windows': + env['msvc'] = check_cc(env, 'MSVC', 'defined(_MSC_VER)', '/E') + if not env['msvc']: + env['gcc'] = check_cc(env, 'GCC', 'defined(__GNUC__) && !defined(__clang__)') + env['clang'] = check_cc(env, 'Clang', '__clang__') env['suncc'] = env['platform'] == 'sunos' and os.path.basename(env['CC']) == 'cc' - env['clang'] = env['CC'] == 'clang' env['icc'] = 'icc' == os.path.basename(env['CC']) if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64': @@ -452,6 +484,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': |