Skip to content

Commit e6c3fce

Browse files
CurryKittenMylesBorins
authored andcommitted
build: Add option to compile for coverage reports
Add --coverage option to configure to support compiling for generation of C based coverage reports PR-URL: #9463 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 2cd4a7f commit e6c3fce

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

configure

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ parser.add_option('--prefix',
5959
default='/usr/local',
6060
help='select the install prefix [default: %default]')
6161

62+
parser.add_option('--coverage',
63+
action='store_true',
64+
dest='coverage',
65+
help='Build node with code coverage enabled')
66+
6267
parser.add_option('--debug',
6368
action='store_true',
6469
dest='debug',
@@ -822,6 +827,11 @@ def configure_node(o):
822827
if options.use_xcode and options.use_ninja:
823828
raise Exception('--xcode and --ninja cannot be used together.')
824829

830+
if options.coverage:
831+
o['variables']['coverage'] = 'true'
832+
else:
833+
o['variables']['coverage'] = 'false'
834+
825835
def configure_library(lib, output):
826836
shared_lib = 'shared_' + lib
827837
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))

node.gyp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,22 @@
506506
'NODE_PLATFORM="sunos"',
507507
],
508508
}],
509-
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false"', {
509+
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="false"', {
510510
'ldflags': [ '-Wl,-z,noexecstack',
511511
'-Wl,--whole-archive <(V8_BASE)',
512512
'-Wl,--no-whole-archive' ]
513513
}],
514+
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="true"', {
515+
'ldflags': [ '-Wl,-z,noexecstack',
516+
'-Wl,--whole-archive <(V8_BASE)',
517+
'-Wl,--no-whole-archive',
518+
'--coverage',
519+
'-g',
520+
'-O0' ],
521+
'cflags': [ '--coverage',
522+
'-g',
523+
'-O0' ]
524+
}],
514525
[ 'OS=="sunos"', {
515526
'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
516527
}],

0 commit comments

Comments
 (0)