diff options
Diffstat (limited to 'scons/gallium.py')
-rw-r--r-- | scons/gallium.py | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/scons/gallium.py b/scons/gallium.py index 69a356908f..a40a957191 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -30,9 +30,11 @@ Frontend-tool for Gallium3D architecture. # +import distutils.version import os import os.path import re +import subprocess import SCons.Action import SCons.Builder @@ -108,6 +110,22 @@ def generate(env): env['toolchain'] = 'wcesdk' env.Tool(env['toolchain']) + if env['platform'] == 'embedded': + # Allow overriding compiler from environment + if os.environ.has_key('CC'): + env['CC'] = os.environ['CC'] + # Update CCVERSION to match + pipe = SCons.Action._subproc(env, [env['CC'], '--version'], + stdin = 'devnull', + stderr = 'devnull', + stdout = subprocess.PIPE) + if pipe.wait() == 0: + line = pipe.stdout.readline() + match = re.search(r'[0-9]+(\.[0-9]+)+', line) + if match: + env['CCVERSION'] = match.group(0) + + env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') env['msvc'] = env['CC'] == 'cl' @@ -224,6 +242,8 @@ def generate(env): if platform == 'wince': cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL'] + if platform == 'embedded': + cppdefines += ['PIPE_OS_EMBEDDED'] env.Append(CPPDEFINES = cppdefines) # C compiler options @@ -231,9 +251,10 @@ def generate(env): cxxflags = [] # C++ ccflags = [] # C & C++ if gcc: + ccversion = env['CCVERSION'] if debug: ccflags += ['-O0', '-g3'] - elif env['CCVERSION'].startswith('4.2.'): + elif ccversion.startswith('4.2.'): # gcc 4.2.x optimizer is broken print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations" ccflags += ['-O0', '-g3'] @@ -259,6 +280,9 @@ def generate(env): # instead. ccflags += [ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): + ccflags += [ '-mstackrealign', # ensure stack is aligned ] if env['machine'] == 'x86_64': @@ -268,16 +292,21 @@ def generate(env): ccflags += [ '-Wall', '-Wmissing-field-initializers', - '-Werror=pointer-arith', '-Wno-long-long', '-ffast-math', '-fmessage-length=0', # be nice to Eclipse ] cflags += [ - '-Werror=declaration-after-statement', '-Wmissing-prototypes', '-std=gnu99', ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): + ccflags += [ + '-Werror=pointer-arith', + ] + cflags += [ + '-Werror=declaration-after-statement', + ] if msvc: # See also: # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx @@ -373,11 +402,15 @@ def generate(env): linkflags += ['-m32'] if env['machine'] == 'x86_64': linkflags += ['-m64'] - shlinkflags += [ - '-Wl,-Bsymbolic', - ] + if env['platform'] not in ('darwin'): + shlinkflags += [ + '-Wl,-Bsymbolic', + ] # Handle circular dependencies in the libraries - env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' + if env['platform'] in ('darwin'): + pass + else: + env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' if msvc: if not env['debug']: # enable Link-time Code Generation |