Skip to content

Commit 5bdf258

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 b1c3908 commit 5bdf258

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',
@@ -863,6 +868,11 @@ def configure_node(o):
863868
if options.use_xcode and options.use_ninja:
864869
raise Exception('--xcode and --ninja cannot be used together.')
865870

871+
if options.coverage:
872+
o['variables']['coverage'] = 'true'
873+
else:
874+
o['variables']['coverage'] = 'false'
875+
866876
def configure_library(lib, output):
867877
shared_lib = 'shared_' + lib
868878
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
@@ -547,11 +547,22 @@
547547
'NODE_PLATFORM="sunos"',
548548
],
549549
}],
550-
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false"', {
550+
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="false"', {
551551
'ldflags': [ '-Wl,-z,noexecstack',
552552
'-Wl,--whole-archive <(V8_BASE)',
553553
'-Wl,--no-whole-archive' ]
554554
}],
555+
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="true"', {
556+
'ldflags': [ '-Wl,-z,noexecstack',
557+
'-Wl,--whole-archive <(V8_BASE)',
558+
'-Wl,--no-whole-archive',
559+
'--coverage',
560+
'-g',
561+
'-O0' ],
562+
'cflags': [ '--coverage',
563+
'-g',
564+
'-O0' ]
565+
}],
555566
[ 'OS=="sunos"', {
556567
'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
557568
}],

0 commit comments

Comments
 (0)