SCons: add methods.using_clang
to check used compiler
Also rename `use_gcc` to `using_gcc` to make it clear that it returns a config but does not alter it.
This commit is contained in:
parent
6a33727cb1
commit
e4a96164b6
4 changed files with 8 additions and 6 deletions
|
@ -342,7 +342,7 @@ if selected_platform in platform_list:
|
||||||
shadow_local_warning = []
|
shadow_local_warning = []
|
||||||
all_plus_warnings = ['-Wwrite-strings']
|
all_plus_warnings = ['-Wwrite-strings']
|
||||||
|
|
||||||
if methods.use_gcc(env):
|
if methods.using_gcc(env):
|
||||||
version = methods.get_compiler_version(env)
|
version = methods.get_compiler_version(env)
|
||||||
if version != None and version[0] >= '7':
|
if version != None and version[0] >= '7':
|
||||||
shadow_local_warning = ['-Wshadow-local']
|
shadow_local_warning = ['-Wshadow-local']
|
||||||
|
@ -350,7 +350,7 @@ if selected_platform in platform_list:
|
||||||
# FIXME: enable -Wimplicit-fallthrough once #26135 is fixed
|
# FIXME: enable -Wimplicit-fallthrough once #26135 is fixed
|
||||||
# FIXME: enable -Wclobbered once #26351 is fixed
|
# FIXME: enable -Wclobbered once #26351 is fixed
|
||||||
env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-implicit-fallthrough', '-Wno-unused-parameter'] + all_plus_warnings + shadow_local_warning)
|
env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-implicit-fallthrough', '-Wno-unused-parameter'] + all_plus_warnings + shadow_local_warning)
|
||||||
if methods.use_gcc(env):
|
if methods.using_gcc(env):
|
||||||
env['CCFLAGS'] += ['-Wno-clobbered']
|
env['CCFLAGS'] += ['-Wno-clobbered']
|
||||||
|
|
||||||
elif (env["warnings"] == 'all'):
|
elif (env["warnings"] == 'all'):
|
||||||
|
|
|
@ -668,5 +668,8 @@ def get_compiler_version(env):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def use_gcc(env):
|
def using_gcc(env):
|
||||||
return 'gcc' in os.path.basename(env["CC"])
|
return 'gcc' in os.path.basename(env["CC"])
|
||||||
|
|
||||||
|
def using_clang(env):
|
||||||
|
return 'clang' in os.path.basename(env["CC"])
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
from methods import get_compiler_version, use_gcc
|
|
||||||
|
|
||||||
# This file is mostly based on platform/x11/detect.py.
|
# This file is mostly based on platform/x11/detect.py.
|
||||||
# If editing this file, make sure to apply relevant changes here too.
|
# If editing this file, make sure to apply relevant changes here too.
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
from compat import decode_utf8
|
from compat import decode_utf8
|
||||||
from methods import get_compiler_version, use_gcc
|
from methods import get_compiler_version, using_gcc
|
||||||
|
|
||||||
def is_active():
|
def is_active():
|
||||||
return True
|
return True
|
||||||
|
@ -160,7 +160,7 @@ def configure(env):
|
||||||
env.Append(LINKFLAGS=['-pipe'])
|
env.Append(LINKFLAGS=['-pipe'])
|
||||||
|
|
||||||
# Check for gcc version >= 6 before adding -no-pie
|
# Check for gcc version >= 6 before adding -no-pie
|
||||||
if use_gcc(env):
|
if using_gcc(env):
|
||||||
version = get_compiler_version(env)
|
version = get_compiler_version(env)
|
||||||
if version != None and version[0] >= '6':
|
if version != None and version[0] >= '6':
|
||||||
env.Append(CCFLAGS=['-fpie'])
|
env.Append(CCFLAGS=['-fpie'])
|
||||||
|
|
Loading…
Reference in a new issue