SConstruct update: Add coverage-target and add more gcc compiler flags

This commit is contained in:
Reijo Tomperi 2010-02-19 12:13:42 +02:00
parent 8411f449f8
commit 82f98ea296
1 changed files with 29 additions and 6 deletions

View File

@ -6,11 +6,15 @@ import os
libFiles = Glob('lib/*.cpp') libFiles = Glob('lib/*.cpp')
libEnv = Environment() libEnv = Environment()
if "gcc" in libEnv["TOOLS"]: if "gcc" in libEnv["TOOLS"]:
libEnv.Append(CCFLAGS = ['-Wall']) libEnv.Append(CCFLAGS = ['-Wall', '-Wextra'])
if 'release' in COMMAND_LINE_TARGETS: if 'release' in COMMAND_LINE_TARGETS:
libEnv.Append(CCFLAGS = ['-O3']) libEnv.Append(CCFLAGS = ['-O3'])
else: elif 'coverage' in COMMAND_LINE_TARGETS:
libEnv.Append(CCFLAGS = ['-g','-O0']) libEnv.Append(CCFLAGS = ['-g', '-fprofile-arcs', '-ftest-coverage'])
libEnv.Append(LINKFLAGS = ['-g', '-fprofile-arcs', '-ftest-coverage'])
else:
libEnv.Append(CCFLAGS = ['-g','-O0'])
libEnv.Append(CPPPATH = ['lib']) libEnv.Append(CPPPATH = ['lib'])
libObjects = libEnv.Object(libFiles) libObjects = libEnv.Object(libFiles)
@ -18,14 +22,20 @@ libObjects = libEnv.Object(libFiles)
cliFiles = Glob('cli/*.cpp')+libObjects cliFiles = Glob('cli/*.cpp')+libObjects
cliEnv = libEnv.Clone() cliEnv = libEnv.Clone()
cliEnv.Append(CPPPATH = ['cli']) cliEnv.Append(CPPPATH = ['cli'])
if "gcc" in libEnv["TOOLS"]:
cliEnv.Append(CCFLAGS = ['-pedantic'])
cppcheck = cliEnv.Program('cppcheck',cliFiles) cppcheck = cliEnv.Program('cppcheck',cliFiles)
Alias('cppcheck',[cppcheck])
Default(cppcheck) Default(cppcheck)
# Testrunner # Testrunner
testFiles = Glob('test/*.cpp')+libObjects testFiles = Glob('test/*.cpp')+libObjects
testEnv = libEnv.Clone() testEnv = libEnv.Clone()
testEnv.Append(CPPPATH = ['test']) testEnv.Append(CPPPATH = ['test'])
if "gcc" in libEnv["TOOLS"]:
testEnv.Append(CCFLAGS = ['-pedantic'])
testrunner = testEnv.Program('testrunner', testFiles) testrunner = testEnv.Program('testrunner', testFiles)
Alias('testrunner',[testrunner])
# GUI # GUI
QTDIR = os.popen('qmake -query QT_INSTALL_DATA').read() QTDIR = os.popen('qmake -query QT_INSTALL_DATA').read()
@ -41,12 +51,25 @@ uiFiles = Glob('gui/*.ui')
uis = [guiEnv.Uic4(ui) for ui in uiFiles] uis = [guiEnv.Uic4(ui) for ui in uiFiles]
guiFiles = Glob('gui/*.cpp')+libObjects guiFiles = Glob('gui/*.cpp')+libObjects
gui = guiEnv.Program(target="gui_cppcheck", source=[rccs, guiFiles]) gui = guiEnv.Program(target="gui_cppcheck", source=[rccs, guiFiles])
Alias('gui',[gui])
# Execute testrunner # Execute testrunner
AlwaysBuild(Alias("test", testrunner, "./$SOURCE")) test = AlwaysBuild(Alias("test", testrunner, "./$SOURCE"))
# All # All
Alias('all',[testrunner,cppcheck,gui]) Alias('all',[testrunner,cppcheck,gui])
# Release # Release
Alias('release',[cppcheck]) Alias('release',[cppcheck])
# Coverage
Alias('coverage',[test],[
'rm -r coverage_report',
'gcov lib/*.cpp -o lib/',
'lcov --directory ./ --capture --output-file lcov.info -b ./',
'genhtml lcov.info -o coverage_report',
'rm lib/*.gcda',
'rm lib/*.gcno',
'rm test/*.gcda',
'rm test/*.gcno',
'rm lcov.info'])