summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-03 19:27:08 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-29 20:26:58 +0200
commit6d0e0695d01bf1823a8aae2b3ec1d488e5215b76 (patch)
tree56e8abcbe96ed8eb60ec1a6cbc5ba28e2deeb9a9 /tests
parentdde71cb426addb6e847c2443ee1bd551d9eb0637 (diff)
Check for supported GCC CCFLAGS when building tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/SConstruct26
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/SConstruct b/tests/SConstruct
index a44ee55..9480c82 100644
--- a/tests/SConstruct
+++ b/tests/SConstruct
@@ -33,7 +33,17 @@ env.Append(PROTOCPATH = '#../generator')
# Check the compilation environment, unless we are just cleaning up.
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.
stdbool = conf.CheckCHeader('stdbool.h')
@@ -62,6 +72,14 @@ if not env.GetOption('clean'):
conf.env.Append(CCFLAGS = '-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
env = conf.Finish()
@@ -71,15 +89,11 @@ if 'gcc' in env['CC']:
# Debug info, warnings as errors
env.Append(CFLAGS = '-ansi -pedantic -g -O0 -Wall -Werror --coverage -fstack-protector-all')
+ env.Append(CORECFLAGS = '-Wextra')
env.Append(LINKFLAGS = '--coverage')
# We currently need uint64_t anyway, even though ANSI C90 otherwise..
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']:
# CLang
env.Append(CFLAGS = '-ansi -g -O0 -Wall -Werror')