build: add c++ coverage support on macOS
macOS requires passing the --coverage flag in OTHER_LDFLAGS and OTHER_CFLAGS in xcode_settings. PR-URL: https://github.com/nodejs/node/pull/16163 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
20b7805566
commit
a0785845bf
18
Makefile
18
Makefile
@ -13,6 +13,7 @@ OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]')
|
|||||||
COVTESTS ?= test-cov
|
COVTESTS ?= test-cov
|
||||||
GTEST_FILTER ?= "*"
|
GTEST_FILTER ?= "*"
|
||||||
GNUMAKEFLAGS += --no-print-directory
|
GNUMAKEFLAGS += --no-print-directory
|
||||||
|
GCOV ?= gcov
|
||||||
|
|
||||||
ifdef JOBS
|
ifdef JOBS
|
||||||
PARALLEL_ARGS = -j $(JOBS)
|
PARALLEL_ARGS = -j $(JOBS)
|
||||||
@ -34,6 +35,10 @@ ifdef DISABLE_V8_I18N
|
|||||||
V8_BUILD_OPTIONS += i18nsupport=off
|
V8_BUILD_OPTIONS += i18nsupport=off
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OSTYPE), darwin)
|
||||||
|
GCOV = xcrun llvm-cov gcov
|
||||||
|
endif
|
||||||
|
|
||||||
BUILDTYPE_LOWER := $(shell echo $(BUILDTYPE) | tr '[A-Z]' '[a-z]')
|
BUILDTYPE_LOWER := $(shell echo $(BUILDTYPE) | tr '[A-Z]' '[a-z]')
|
||||||
|
|
||||||
# Determine EXEEXT
|
# Determine EXEEXT
|
||||||
@ -124,10 +129,12 @@ coverage-clean:
|
|||||||
$(RM) -r gcovr testing
|
$(RM) -r gcovr testing
|
||||||
$(RM) -r out/$(BUILDTYPE)/.coverage
|
$(RM) -r out/$(BUILDTYPE)/.coverage
|
||||||
$(RM) -r .cov_tmp coverage
|
$(RM) -r .cov_tmp coverage
|
||||||
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
|
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcda
|
||||||
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
|
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
|
||||||
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcno
|
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcno
|
||||||
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing*.gcno
|
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcno
|
||||||
|
$(RM) out/$(BUILDTYPE)/obj.target/cctest/src/*.gcno
|
||||||
|
$(RM) out/$(BUILDTYPE)/obj.target/cctest/test/cctest/*.gcno
|
||||||
|
|
||||||
# Build and test with code coverage reporting. Leave the lib directory
|
# Build and test with code coverage reporting. Leave the lib directory
|
||||||
# instrumented for any additional runs the user may want to make.
|
# instrumented for any additional runs the user may want to make.
|
||||||
@ -157,7 +164,7 @@ coverage-build: all
|
|||||||
coverage-test: coverage-build
|
coverage-test: coverage-build
|
||||||
$(RM) -r out/$(BUILDTYPE)/.coverage
|
$(RM) -r out/$(BUILDTYPE)/.coverage
|
||||||
$(RM) -r .cov_tmp
|
$(RM) -r .cov_tmp
|
||||||
$(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
|
$(RM) out/$(BUILDTYPE)/obj.target/node/{src,gen}/*.gcda
|
||||||
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
|
$(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
|
||||||
-$(MAKE) $(COVTESTS)
|
-$(MAKE) $(COVTESTS)
|
||||||
mv lib lib__
|
mv lib lib__
|
||||||
@ -170,7 +177,8 @@ coverage-test: coverage-build
|
|||||||
--report-dir "../coverage")
|
--report-dir "../coverage")
|
||||||
-(cd out && "../gcovr/scripts/gcovr" --gcov-exclude='.*deps' \
|
-(cd out && "../gcovr/scripts/gcovr" --gcov-exclude='.*deps' \
|
||||||
--gcov-exclude='.*usr' -v -r Release/obj.target/node \
|
--gcov-exclude='.*usr' -v -r Release/obj.target/node \
|
||||||
--html --html-detail -o ../coverage/cxxcoverage.html)
|
--html --html-detail -o ../coverage/cxxcoverage.html \
|
||||||
|
--gcov-executable="$(GCOV)")
|
||||||
mv lib lib_
|
mv lib lib_
|
||||||
mv lib__ lib
|
mv lib__ lib
|
||||||
@echo -n "Javascript coverage %: "
|
@echo -n "Javascript coverage %: "
|
||||||
|
12
node.gypi
12
node.gypi
@ -333,6 +333,18 @@
|
|||||||
'-O0' ],
|
'-O0' ],
|
||||||
'cflags!': [ '-O3' ]
|
'cflags!': [ '-O3' ]
|
||||||
}],
|
}],
|
||||||
|
[ 'OS=="mac" and node_shared=="false" and coverage=="true"', {
|
||||||
|
'xcode_settings': {
|
||||||
|
'OTHER_LDFLAGS': [
|
||||||
|
'--coverage',
|
||||||
|
],
|
||||||
|
'OTHER_CFLAGS+': [
|
||||||
|
'--coverage',
|
||||||
|
'-g',
|
||||||
|
'-O0'
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}],
|
||||||
[ 'OS=="sunos"', {
|
[ 'OS=="sunos"', {
|
||||||
'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
|
'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
|
||||||
}],
|
}],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user