Browse Source

waf: add cflags detection, make some warning flags optional

pull/2/head
mittorn 5 years ago
parent
commit
d633fe5deb
  1. 58
      wscript

58
wscript

@ -66,6 +66,26 @@ def options(opt):
opt.load('reconfigure') opt.load('reconfigure')
def filter_cflags(conf, flags, required_flags, cxx):
supported_flags = []
required_flags += ['-Werror']
conf.msg('Detecting supported flags for %s' % ('C++' if cxx else 'C'),'...')
for flag in flags:
conf.start_msg('Checking for %s' % flag)
try:
if cxx:
conf.check_cxx(cxxflags = [flag] + required_flags)
else:
conf.check_cc(cflags = [flag] + required_flags)
except conf.errors.ConfigurationError:
conf.end_msg('no', color='YELLOW')
else:
conf.end_msg('yes')
supported_flags.append(flag)
return supported_flags
def configure(conf): def configure(conf):
conf.load('fwgslib reconfigure') conf.load('fwgslib reconfigure')
conf.start_msg('Build type') conf.start_msg('Build type')
@ -133,24 +153,8 @@ def configure(conf):
'common': { 'common': {
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'], 'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'],
'clang': [ 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'],
'-g', 'gcc': ['-g', '-fvisibility=hidden']
'-gdwarf-2',
'-Werror=implicit-function-declaration',
'-Werror=return-type',
'-Werror=int-conversion',
'-Werror=parentheses',
'-fvisibility=hidden',
],
'gcc': [
'-g',
'-fdiagnostics-color=always',
'-Werror=implicit-function-declaration',
'-Werror=return-type',
'-Werror=int-conversion',
'-Werror=parentheses',
'-fvisibility=hidden',
]
}, },
'fast': { 'fast': {
'msvc': ['/O2', '/Oy'], #todo: check /GL /LTCG 'msvc': ['/O2', '/Oy'], #todo: check /GL /LTCG
@ -179,10 +183,20 @@ def configure(conf):
} }
} }
conf.env.append_unique('CFLAGS', conf.get_flags_by_type( compiler_optional_flags = [
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) '-fdiagnostics-color=always',
conf.env.append_unique('CXXFLAGS', conf.get_flags_by_type( '-Werror=implicit-function-declaration',
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) '-Werror=int-conversion',
'-Werror=return-type',
'-Werror=parentheses',
]
cflags = conf.get_flags_by_type(compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)
conf.check_cc(cflags=cflags, msg= 'Checking for required C flags')
conf.check_cxx(cxxflags=cflags, msg= 'Checking for required C++ flags')
conf.env.append_unique('CFLAGS', cflags + filter_cflags(conf, compiler_optional_flags, cflags, False))
conf.env.append_unique('CXXFLAGS', cflags + filter_cflags(conf, compiler_optional_flags, cflags, True))
conf.env.append_unique('LINKFLAGS', conf.get_flags_by_type( conf.env.append_unique('LINKFLAGS', conf.get_flags_by_type(
linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))

Loading…
Cancel
Save