diff --git a/Makefile b/Makefile index b2aa27b92..fd3a2add4 100755 --- a/Makefile +++ b/Makefile @@ -81,6 +81,8 @@ clean: @find ./src/ -name "*.so" -exec rm {} \; @find ./ -name "*.o" -exec rm {} \; @find ./src/ -name "*.a" -exec rm {} \; + @find ./ -name "*.gcda" -exec rm {} \; + @find ./ -name "*.gcno" -exec rm {} \; distclean: if test -e "config.py"; then mv "config.py" "config.py.backup"; fi diff --git a/SConstruct b/SConstruct index 2b851e42d..9bc152641 100644 --- a/SConstruct +++ b/SConstruct @@ -293,6 +293,7 @@ opts.AddVariables( EnumVariable('OPTIMIZATION','Set compiler optimization level','3', ['0','1','2','3','4','s']), # Note: setting DEBUG=True will override any custom OPTIMIZATION level BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'), + BoolVariable('COVERAGE', 'Compile a libmapnik and plugins with --coverage', 'False'), BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'), BoolVariable('DEBUG_SANITIZE', 'Compile a version of Mapnik using clang/llvm address sanitation', 'False'), ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()), @@ -1139,6 +1140,9 @@ if not preconfigured: else: mode = 'release mode' + if env['COVERAGE']: + mode += ' (with coverage)' + env['PLATFORM'] = platform.uname()[0] color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode)) @@ -1891,6 +1895,10 @@ if not HELP_REQUESTED: plugin_base = env.Clone() + if env['COVERAGE']: + plugin_base.Append(LINKFLAGS='--coverage') + plugin_base.Append(CXXFLAGS='--coverage') + Export('plugin_base') if env['FAST']: diff --git a/scripts/travis-common.sh b/scripts/travis-common.sh index cfdc57f59..edf90f619 100644 --- a/scripts/travis-common.sh +++ b/scripts/travis-common.sh @@ -82,8 +82,7 @@ config_override () { configure () { if enabled ${COVERAGE}; then ./configure "$@" PGSQL2SQLITE=False SVG2PNG=False SVG_RENDERER=False \ - CUSTOM_LDFLAGS='--coverage' CUSTOM_CXXFLAGS='--coverage' \ - CUSTOM_CFLAGS='--coverage' DEBUG=True + COVERAGE=True DEBUG=True elif enabled ${MASON_PUBLISH}; then export MASON_NAME=mapnik export MASON_VERSION=latest @@ -101,9 +100,10 @@ configure () { coverage () { ./mason_packages/.link/bin/cpp-coveralls \ - --build-root . --gcov-options '\-lp' --exclude mason_packages \ + --build-root . --gcov-options '\-lp' \ + --exclude mason_packages \ --exclude .sconf_temp --exclude benchmark --exclude deps \ --exclude scons --exclude test --exclude demo --exclude docs \ - --exclude fonts --exclude utils \ + --exclude fonts \ > /dev/null } diff --git a/src/build.py b/src/build.py index 1568e9c34..c586cf130 100644 --- a/src/build.py +++ b/src/build.py @@ -62,6 +62,10 @@ system = 'boost_system%s' % env['BOOST_APPEND'] lib_env['LIBS'] = [filesystem, regex] +if env['COVERAGE']: + lib_env.Append(LINKFLAGS='--coverage') + lib_env.Append(CXXFLAGS='--coverage') + if env['HAS_CAIRO']: lib_env.Append(LIBS=env['CAIRO_ALL_LIBS']) diff --git a/utils/mapnik-index/build.py b/utils/mapnik-index/build.py index 651075ae7..358ce5f88 100644 --- a/utils/mapnik-index/build.py +++ b/utils/mapnik-index/build.py @@ -24,8 +24,9 @@ import glob from copy import copy Import ('env') +Import ('plugin_base') -program_env = env.Clone() +program_env = plugin_base.Clone() source = Split( """ @@ -36,7 +37,6 @@ source = Split( """ ) -#headers = ['#plugins/input/shape'] + env['CPPPATH'] headers = env['CPPPATH'] boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] diff --git a/utils/shapeindex/build.py b/utils/shapeindex/build.py index 9f7de7445..2a4c2ab07 100644 --- a/utils/shapeindex/build.py +++ b/utils/shapeindex/build.py @@ -25,7 +25,9 @@ from copy import copy Import ('env') -program_env = env.Clone() +Import ('plugin_base') + +program_env = plugin_base.Clone() source = Split( """