diff options
author | lloyd <[email protected]> | 2015-04-12 03:49:44 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-04-12 03:49:44 +0000 |
commit | 6e2bf7b795a0f1a9731f23ec4fa69a3e4e716cdb (patch) | |
tree | 9d3acb25a35d106d41d8d2867c9aa3ddc71d1563 | |
parent | 62947773cedb0c9534c5df91271db9a9414e6e2a (diff) |
Add coverage checking with gcov/lcov
-rwxr-xr-x | configure.py | 67 | ||||
-rw-r--r-- | src/build-data/cc/clang.txt | 1 | ||||
-rw-r--r-- | src/build-data/cc/gcc.txt | 1 | ||||
-rw-r--r-- | src/build-data/makefile/coverage.in | 4 | ||||
-rw-r--r-- | src/build-data/makefile/gmake.in | 5 |
5 files changed, 42 insertions, 36 deletions
diff --git a/configure.py b/configure.py index 107511de1..135addbd4 100755 --- a/configure.py +++ b/configure.py @@ -53,12 +53,14 @@ def is_official_release(): # Assume a release date implies official release return (botan_version.release_datestamp > 20130000) -def maintainer_mode_default(): +def default_build_mode(): + if os.getenv('CONTINUOUS_INTEGRATION') == 'true' or \ + os.getenv('GO_ENVIRONMENT_NAME') == 'Botan': + return 'maintainer' + if is_official_release(): - return False - if os.getenv('GO_ENVIRONMENT_NAME') == 'Botan': - return True # running under CI - return False + return 'release' + return 'debug' def get_vc_revision(): @@ -285,6 +287,10 @@ def process_command_line(args): build_group = optparse.OptionGroup(parser, 'Build options') + modes = ['release', 'debug', 'coverage'] + build_group.add_option('--build-mode', default='release', metavar='MODE', + help="Build type (one of %s; default %%default)" % (', '.join(modes))) + build_group.add_option('--enable-shared', dest='build_shared_lib', action='store_true', default=True, help=optparse.SUPPRESS_HELP) @@ -299,12 +305,6 @@ def process_command_line(args): action='store_false', help='disallow use of assembler') - build_group.add_option('--enable-debug', dest='debug_build', - action='store_true', default=False, - help='enable debug build') - build_group.add_option('--disable-debug', dest='debug_build', - action='store_false', help=optparse.SUPPRESS_HELP) - build_group.add_option('--no-optimizations', dest='no_optimizations', action='store_true', default=False, help=optparse.SUPPRESS_HELP) @@ -317,16 +317,14 @@ def process_command_line(args): default=False, action='store_true', help='build via amalgamation') - build_group.add_option('--single-amalgamation-file', default=False, action='store_true', + build_group.add_option('--single-amalgamation-file', + default=False, action='store_true', help='build single file instead of splitting on ABI') - build_group.add_option('--with-build-dir', - metavar='DIR', default='', + build_group.add_option('--with-build-dir', metavar='DIR', default='', help='setup the build in DIR') - build_group.add_option('--link-method', - default=None, - metavar='METHOD', + build_group.add_option('--link-method', default=None, metavar='METHOD', help='choose how links are created') build_group.add_option('--makefile-style', metavar='STYLE', default=None, @@ -359,14 +357,8 @@ def process_command_line(args): dest='with_doxygen', help=optparse.SUPPRESS_HELP) build_group.add_option('--maintainer-mode', dest='maintainer_mode', - action='store_true', - default=maintainer_mode_default(), - help="Maintainer mode build") - - build_group.add_option('--release-mode', dest='maintainer_mode', - action='store_false', - help=optparse.SUPPRESS_HELP) - + action='store_true', default=False, + help="Enable extra warnings") build_group.add_option('--dirty-tree', dest='clean_build_tree', action='store_false', default=True, help=optparse.SUPPRESS_HELP) @@ -808,6 +800,7 @@ class CompilerInfo(object): 'app_opt_flags': '', 'debug_flags': '', 'no_debug_flags': '', + 'coverage_flags': '', 'shared_flags': '', 'lang_flags': '', 'warning_flags': '', @@ -870,7 +863,7 @@ class CompilerInfo(object): """ def mach_abi_link_flags(self, options): def all(): - if options.debug_build and 'all-debug' in self.mach_abi_linking: + if 'all-debug' in self.mach_abi_linking and options.build_mode == 'debug': return 'all-debug' return 'all' @@ -886,20 +879,26 @@ class CompilerInfo(object): if len(abi_link) == 0: return '' - return ' ' + ' '.join(sorted(list(abi_link))) + abi_flags = ' '.join(sorted(list(abi_link))) + if options.build_mode == 'coverage': + if self.coverage_flags == '': + raise Exception('No coverage handling for %s' % (self.basename)) + return ' ' + self.coverage_flags + ' ' + abi_flags + + return ' ' + abi_flags """ - Return the optimization flags to use for the library + Return the optimization flags to use """ def opt_flags(self, who, options): def gen_flags(): - if options.debug_build: + if options.build_mode in ['debug', 'coverage']: yield self.debug_flags else: yield self.no_debug_flags - if options.no_optimizations: + if options.no_optimizations or options.build_mode == 'coverage': return if who != 'lib': @@ -1324,6 +1323,9 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo): vars["header_in"] = process_template('src/build-data/makefile/header.in', vars) vars["commands_in"] = process_template('src/build-data/makefile/commands.in', vars) + vars["coverage_in"] = process_template('src/build-data/makefile/coverage.in', vars) \ + if options.build_mode == 'coverage' else '' + if options.build_shared_lib: vars["dso_in"] = process_template('src/build-data/makefile/dso.in', vars) else: @@ -1763,7 +1765,7 @@ def main(argv = None): options = process_command_line(argv[1:]) def log_level(): - if options.verbose or options.maintainer_mode: + if options.verbose: return logging.DEBUG if options.quiet: return logging.WARNING @@ -1777,9 +1779,6 @@ def main(argv = None): logging.info('Platform: OS="%s" machine="%s" proc="%s"' % ( platform.system(), platform.machine(), platform.processor())) - if options.maintainer_mode: - logging.log(NOTICE_LOGLEVEL, 'Enabling maintainer mode build (use --release-mode to disable)') - if options.os == "java": raise Exception("Jython detected: need --os and --cpu to set target") diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt index 9216c12c9..195318291 100644 --- a/src/build-data/cc/clang.txt +++ b/src/build-data/cc/clang.txt @@ -20,6 +20,7 @@ app_opt_flags "-O2" shared_flags "-fPIC" debug_flags "-g" no_debug_flags "" +coverage_flags "--coverage" visibility_build_flags "-fvisibility=hidden" visibility_attribute '__attribute__((visibility("default")))' diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt index 324f51071..1e1eb2fb9 100644 --- a/src/build-data/cc/gcc.txt +++ b/src/build-data/cc/gcc.txt @@ -16,6 +16,7 @@ lib_opt_flags "-O2" app_opt_flags "-O2" shared_flags "-fPIC" debug_flags "-g" +coverage_flags "--coverage" visibility_build_flags "-fvisibility=hidden" visibility_attribute '__attribute__((visibility("default")))' diff --git a/src/build-data/makefile/coverage.in b/src/build-data/makefile/coverage.in new file mode 100644 index 000000000..9547c4151 --- /dev/null +++ b/src/build-data/makefile/coverage.in @@ -0,0 +1,4 @@ + +lcov: + lcov --directory build/obj/lib/ --directory src/lib --no-external --capture --output-file botan.info + genhtml botan.info -o coverage/ diff --git a/src/build-data/makefile/gmake.in b/src/build-data/makefile/gmake.in index c45cd2940..e8c480a21 100644 --- a/src/build-data/makefile/gmake.in +++ b/src/build-data/makefile/gmake.in @@ -37,8 +37,7 @@ $(STATIC_LIB): $(LIBOBJS) $(AR) $(STATIC_LIB) $(LIBOBJS) $(RANLIB) $(STATIC_LIB) -# Fake Targets -.PHONY = clean distclean docs website install valgrind +%{coverage_in} SPHINX_CONFIG = %{sphinx_config_dir} SPHINX_OPTS = -b html @@ -46,6 +45,8 @@ SPHINX_OPTS = -b html WEBSITE_DIR=%{doc_output_dir}/website WEBSITE_SRC_DIR=%{doc_output_dir}/website-src +.PHONY = clean distclean docs website install valgrind + clean: $(RM) %{libobj_dir}/* %{testobj_dir}/* %{appobj_dir}/* $(RM) $(LIBRARIES) $(SYMLINK) $(SONAME) $(APP) $(TEST) |