Check for supported GCC CCFLAGS when building tests.
This commit is contained in:
@@ -33,7 +33,17 @@ env.Append(PROTOCPATH = '#../generator')
|
|||||||
|
|
||||||
# Check the compilation environment, unless we are just cleaning up.
|
# Check the compilation environment, unless we are just cleaning up.
|
||||||
if not env.GetOption('clean'):
|
if not env.GetOption('clean'):
|
||||||
conf = Configure(env)
|
def check_ccflags(context, flags):
|
||||||
|
'''Check if given CCFLAGS are supported'''
|
||||||
|
context.Message('Checking support for CCFLAGS="%s"...' % flags)
|
||||||
|
oldflags = context.env['CCFLAGS']
|
||||||
|
context.env.Append(CCFLAGS = flags)
|
||||||
|
result = context.TryCompile("int main() {return 0;}", '.c')
|
||||||
|
context.env.Replace(CCFLAGS = oldflags)
|
||||||
|
context.Result(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
conf = Configure(env, custom_tests = {'CheckCCFLAGS': check_ccflags})
|
||||||
|
|
||||||
# If the platform doesn't support C99, use our own header file instead.
|
# If the platform doesn't support C99, use our own header file instead.
|
||||||
stdbool = conf.CheckCHeader('stdbool.h')
|
stdbool = conf.CheckCHeader('stdbool.h')
|
||||||
@@ -62,6 +72,14 @@ if not env.GetOption('clean'):
|
|||||||
conf.env.Append(CCFLAGS = '-fmudflap')
|
conf.env.Append(CCFLAGS = '-fmudflap')
|
||||||
conf.env.Append(LINKFLAGS = '-lmudflap -fmudflap')
|
conf.env.Append(LINKFLAGS = '-lmudflap -fmudflap')
|
||||||
|
|
||||||
|
# Check if we can use extra strict warning flags (only with GCC)
|
||||||
|
extra = '-Wcast-qual -Wlogical-op -Wconversion'
|
||||||
|
extra += ' -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls'
|
||||||
|
extra += ' -Wstack-protector'
|
||||||
|
if 'gcc' in env['CC']:
|
||||||
|
if conf.CheckCCFLAGS(extra):
|
||||||
|
conf.env.Append(CORECFLAGS = extra)
|
||||||
|
|
||||||
# End the config stuff
|
# End the config stuff
|
||||||
env = conf.Finish()
|
env = conf.Finish()
|
||||||
|
|
||||||
@@ -71,15 +89,11 @@ if 'gcc' in env['CC']:
|
|||||||
|
|
||||||
# Debug info, warnings as errors
|
# Debug info, warnings as errors
|
||||||
env.Append(CFLAGS = '-ansi -pedantic -g -O0 -Wall -Werror --coverage -fstack-protector-all')
|
env.Append(CFLAGS = '-ansi -pedantic -g -O0 -Wall -Werror --coverage -fstack-protector-all')
|
||||||
|
env.Append(CORECFLAGS = '-Wextra')
|
||||||
env.Append(LINKFLAGS = '--coverage')
|
env.Append(LINKFLAGS = '--coverage')
|
||||||
|
|
||||||
# We currently need uint64_t anyway, even though ANSI C90 otherwise..
|
# We currently need uint64_t anyway, even though ANSI C90 otherwise..
|
||||||
env.Append(CFLAGS = '-Wno-long-long')
|
env.Append(CFLAGS = '-Wno-long-long')
|
||||||
|
|
||||||
# More strict checks on the nanopb core
|
|
||||||
env.Append(CORECFLAGS = '-Wextra -Wcast-qual -Wlogical-op -Wconversion')
|
|
||||||
env.Append(CORECFLAGS = ' -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls')
|
|
||||||
env.Append(CORECFLAGS = ' -Wstack-protector')
|
|
||||||
elif 'clang' in env['CC']:
|
elif 'clang' in env['CC']:
|
||||||
# CLang
|
# CLang
|
||||||
env.Append(CFLAGS = '-ansi -g -O0 -Wall -Werror')
|
env.Append(CFLAGS = '-ansi -g -O0 -Wall -Werror')
|
||||||
|
|||||||
Reference in New Issue
Block a user