Skip to content

Commit 5d9d415

Browse files
CurryKittenmhdawson
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent a41b41a commit 5d9d415

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

configure

+10
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',
@@ -857,6 +862,11 @@ def configure_node(o):
857862
if options.use_xcode and options.use_ninja:
858863
raise Exception('--xcode and --ninja cannot be used together.')
859864

865+
if options.coverage:
866+
o['variables']['coverage'] = 'true'
867+
else:
868+
o['variables']['coverage'] = 'false'
869+
860870
def configure_library(lib, output):
861871
shared_lib = 'shared_' + lib
862872
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))

node.gyp

+12-1
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,22 @@
549549
'NODE_PLATFORM="sunos"',
550550
],
551551
}],
552-
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false"', {
552+
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="false"', {
553553
'ldflags': [ '-Wl,-z,noexecstack',
554554
'-Wl,--whole-archive <(V8_BASE)',
555555
'-Wl,--no-whole-archive' ]
556556
}],
557+
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false" and coverage=="true"', {
558+
'ldflags': [ '-Wl,-z,noexecstack',
559+
'-Wl,--whole-archive <(V8_BASE)',
560+
'-Wl,--no-whole-archive',
561+
'--coverage',
562+
'-g',
563+
'-O0' ],
564+
'cflags': [ '--coverage',
565+
'-g',
566+
'-O0' ]
567+
}],
557568
[ 'OS=="sunos"', {
558569
'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
559570
}],

0 commit comments

Comments
 (0)