From fdf2e53ee237ce4168276c46f6e74c101b350df6 Mon Sep 17 00:00:00 2001 From: Wayne Andrews Date: Fri, 14 Oct 2016 13:33:25 +0100 Subject: [PATCH] Add --coverage option to configure to produce C based coverage reports --- configure | 10 ++++++++++ node.gyp | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 9b4fa94521a7f4..4cc5dcb0d2b3a8 100755 --- a/configure +++ b/configure @@ -59,6 +59,11 @@ parser.add_option('--prefix', default='/usr/local', help='select the install prefix [default: %default]') +parser.add_option('--coverage', + action='store_true', + dest='coverage', + help='Build node with code coverage enabled') + parser.add_option('--debug', action='store_true', dest='debug', @@ -858,6 +863,11 @@ def configure_node(o): if options.use_xcode and options.use_ninja: raise Exception('--xcode and --ninja cannot be used together.') + if options.coverage: + o['variables']['coverage'] = 'true' + else: + o['variables']['coverage'] = 'false' + def configure_library(lib, output): shared_lib = 'shared_' + lib output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib)) diff --git a/node.gyp b/node.gyp index fa98547e09b198..741cac97623ec7 100644 --- a/node.gyp +++ b/node.gyp @@ -550,11 +550,22 @@ 'NODE_PLATFORM="sunos"', ], }], - [ '(OS=="freebsd" or OS=="linux") and node_shared=="false"', { + [ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="false"', { 'ldflags': [ '-Wl,-z,noexecstack', '-Wl,--whole-archive <(V8_BASE)', '-Wl,--no-whole-archive' ] }], + [ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="true"', { + 'ldflags': [ '-Wl,-z,noexecstack', + '-Wl,--whole-archive <(V8_BASE)', + '-Wl,--no-whole-archive', + '--coverage', + '-g', + '-O0' ], + 'cflags': [ '--coverage', + '-g', + '-O0' ] + }], [ 'OS=="sunos"', { 'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ], }],