Skip to content

Commit f4e021c

Browse files
committed
build: fix coverage build
After adding the node_lib target in node.gyp, most of the node source files are moved to that target. When coverage option is enabled, corresponding cflags and ldflags are needed in that target as well. gcovr also needs to check .gcda data for both node and node_lib. Fixes: #18402 Signed-off-by: Yihong Wang <[email protected]>
1 parent 2ac6658 commit f4e021c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ coverage-test: coverage-build
191191
$(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda
192192
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
193193
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
194+
$(RM) out/$(BUILDTYPE)/obj.target/node_lib/gen/*.gcda
195+
$(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*.gcda
196+
$(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/tracing/*.gcda
194197
-$(MAKE) $(COVTESTS)
195198
mv lib lib__
196199
mv lib_ lib
@@ -201,7 +204,7 @@ coverage-test: coverage-build
201204
--temp-directory "$(CURDIR)/.cov_tmp" \
202205
--report-dir "../coverage")
203206
-(cd out && "../gcovr/scripts/gcovr" --gcov-exclude='.*deps' \
204-
--gcov-exclude='.*usr' -v -r Release/obj.target/node \
207+
--gcov-exclude='.*usr' -v -r Release/obj.target \
205208
--html --html-detail -o ../coverage/cxxcoverage.html \
206209
--gcov-executable="$(GCOV)")
207210
mv lib lib_

node.gypi

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,20 @@
184184
],
185185
}],
186186
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false"'
187-
' and coverage=="false" and force_load=="true"', {
187+
' and force_load=="true"', {
188188
'ldflags': [ '-Wl,-z,noexecstack',
189189
'-Wl,--whole-archive <(v8_base)',
190190
'-Wl,--no-whole-archive' ]
191191
}],
192-
[ '(OS=="freebsd" or OS=="linux") and node_shared=="false"'
193-
' and coverage=="true" and force_load=="true"', {
194-
'ldflags': [ '-Wl,-z,noexecstack',
195-
'-Wl,--whole-archive <(v8_base)',
196-
'-Wl,--no-whole-archive',
197-
'--coverage',
192+
[ 'OS in "mac freebsd linux" and node_shared=="false"'
193+
' and coverage=="true"', {
194+
'ldflags': [ '--coverage',
198195
'-g',
199196
'-O0' ],
200-
'cflags': [ '--coverage',
197+
'cflags': [ '--coverage',
201198
'-g',
202199
'-O0' ],
203-
'cflags!': [ '-O3' ]
204-
}],
205-
[ 'OS=="mac" and node_shared=="false" and coverage=="true"', {
200+
'cflags!': [ '-O3' ],
206201
'xcode_settings': {
207202
'OTHER_LDFLAGS': [
208203
'--coverage',

0 commit comments

Comments
 (0)