Skip to content

Commit

Permalink
build: Add option to compile for coverage reports
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
CurryKitten authored and MylesBorins committed Dec 13, 2016
1 parent f2b0098 commit f8d4577
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -822,6 +827,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))
Expand Down
13 changes: 12 additions & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,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' ],
}],
Expand Down

0 comments on commit f8d4577

Please sign in to comment.