[gyp] Coverage only if BUILDTYPE=Debug and ENABLE_COVERAGE=1
Coverage compiler and linker flags are used only when (1) in debug build and (2) with ENABLE_COVERAGE set to 1. Besides, because OS X's libtool is unable to understand '--coverage', this linker flag is only used genrating executable targets. Also, using 'link_settings' to specify linker options and separate instructions for OSX and Linux.
This commit is contained in:
1
Makefile
1
Makefile
@@ -2,6 +2,7 @@ export BUILDTYPE ?= Release
|
||||
export BUILD_TEST ?= 1
|
||||
export BUILD_RENDER ?= 1
|
||||
export BUILD_OFFLINE ?= 1
|
||||
export ENABLE_COVERAGE ?= 0
|
||||
|
||||
# Determine build platform
|
||||
ifeq ($(shell uname -s), Darwin)
|
||||
|
||||
@@ -88,47 +88,56 @@
|
||||
],
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'cflags_cc': [
|
||||
'-g',
|
||||
'-O0',
|
||||
'-fno-omit-frame-pointer',
|
||||
'-fwrapv',
|
||||
'-fstack-protector-all',
|
||||
'-fno-common',
|
||||
'--coverage',
|
||||
],
|
||||
'conditions': [
|
||||
['enable_coverage=="1"', {
|
||||
'cflags_cc': [ '<@(cflags_cc)', '--coverage' ],
|
||||
['OS=="mac"', {
|
||||
'xcode_settings': {
|
||||
'GCC_OPTIMIZATION_LEVEL': '0',
|
||||
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
|
||||
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
|
||||
'DEAD_CODE_STRIPPING': 'NO',
|
||||
'OTHER_CPLUSPLUSFLAGS': [ '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ],
|
||||
'conditions': [
|
||||
['coverage', {
|
||||
'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES',
|
||||
'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',
|
||||
'OTHER_CPLUSPLUSFLAGS': [ '--coverage' ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
}, {
|
||||
'ldflags': [ '--coverage' ],
|
||||
'cflags_cc': [ '-g', '-O0', '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ],
|
||||
'conditions': [
|
||||
['coverage', { 'cflags_cc': [ '--coverage' ] }],
|
||||
],
|
||||
}],
|
||||
],
|
||||
'defines': [ 'DEBUG' ],
|
||||
'xcode_settings': {
|
||||
'GCC_OPTIMIZATION_LEVEL': '0',
|
||||
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
|
||||
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
|
||||
'DEAD_CODE_STRIPPING': 'NO',
|
||||
'OTHER_CPLUSPLUSFLAGS': [ '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ],
|
||||
'conditions': [
|
||||
['enable_coverage=="1"', {
|
||||
'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES',
|
||||
'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES',
|
||||
'OTHER_CPLUSPLUSFLAGS': [ '<@(OTHER_CPLUSPLUSFLAGS)', '-fprofile-arcs', '-ftest-coverage' ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
'target_conditions': [
|
||||
['_type == "executable"', {
|
||||
'conditions': [
|
||||
['OS=="mac" and coverage', {
|
||||
'xcode_settings': { 'OTHER_LDFLAGS': [ '--coverage' ] },
|
||||
}, {
|
||||
'ldflags': [ '--coverage' ],
|
||||
}],
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
'Release': {
|
||||
'cflags_cc': [ '-g', '-O3' ],
|
||||
'defines': [ 'NDEBUG' ],
|
||||
'xcode_settings': {
|
||||
'GCC_OPTIMIZATION_LEVEL': '3',
|
||||
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
|
||||
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
|
||||
'DEAD_CODE_STRIPPING': 'NO',
|
||||
}
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'xcode_settings': {
|
||||
'GCC_OPTIMIZATION_LEVEL': '3',
|
||||
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
|
||||
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
|
||||
'DEAD_CODE_STRIPPING': 'NO',
|
||||
},
|
||||
}, {
|
||||
'cflags_cc': [ '-g', '-O3' ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -39,31 +39,27 @@
|
||||
|
||||
'conditions': [
|
||||
['OS == "mac"', {
|
||||
'libraries': [ '<@(libraries)' ],
|
||||
'xcode_settings': {
|
||||
'SDKROOT': 'macosx',
|
||||
'SUPPORTED_PLATFORMS':'macosx',
|
||||
'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
|
||||
'OTHER_LDFLAGS': [ '<@(ldflags)' ],
|
||||
'SDKROOT': 'macosx',
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.10',
|
||||
},
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'xcode_settings': {
|
||||
'conditions': [
|
||||
['enable_coverage=="1"', {
|
||||
'OTHER_LDFLAGS': [ '--coverage' ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
'cflags_cc': [ '<@(cflags_cc)' ],
|
||||
'libraries': [ '<@(libraries)', '<@(ldflags)' ],
|
||||
}]
|
||||
],
|
||||
|
||||
'link_settings': {
|
||||
'conditions': [
|
||||
['OS == "mac"', {
|
||||
'libraries': [ '<@(libraries)' ],
|
||||
'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] }
|
||||
}, {
|
||||
'libraries': [ '<@(libraries)', '<@(ldflags)' ],
|
||||
}]
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -79,15 +79,11 @@ GYP_FLAGS += -Dheadless_lib=$(HEADLESS)
|
||||
GYP_FLAGS += -Dtest=$(BUILD_TEST)
|
||||
GYP_FLAGS += -Drender=$(BUILD_RENDER)
|
||||
GYP_FLAGS += -Doffline=$(BUILD_OFFLINE)
|
||||
GYP_FLAGS += -Dcoverage=$(ENABLE_COVERAGE)
|
||||
GYP_FLAGS += -Dcxx_host=$(CXX_HOST)
|
||||
GYP_FLAGS += --depth=.
|
||||
GYP_FLAGS += -Goutput_dir=.
|
||||
GYP_FLAGS += --generator-output=./build/$(HOST_SLUG)
|
||||
ifeq ($(ENABLE_COVERAGE),1)
|
||||
GYP_FLAGS += -Denable_coverage=1
|
||||
else ifneq ($(ENABLE_COVERAGE),1)
|
||||
GYP_FLAGS += -Denable_coverage=0
|
||||
endif
|
||||
|
||||
.PHONY: Makefile/__project__
|
||||
Makefile/__project__: print-env $(SUBMODULES) config/$(HOST_SLUG).gypi
|
||||
|
||||
@@ -100,11 +100,6 @@
|
||||
'sprite/sprite_parser.cpp',
|
||||
'sprite/sprite_store.cpp',
|
||||
],
|
||||
'libraries': [
|
||||
'<@(gtest_static_libs)',
|
||||
'<@(sqlite_static_libs)',
|
||||
'<@(geojsonvt_static_libs)',
|
||||
],
|
||||
'variables': {
|
||||
'cflags_cc': [
|
||||
'<@(gtest_cflags)',
|
||||
@@ -119,29 +114,31 @@
|
||||
'<@(gtest_ldflags)',
|
||||
'<@(sqlite_ldflags)',
|
||||
],
|
||||
'libraries': [
|
||||
'<@(gtest_static_libs)',
|
||||
'<@(sqlite_static_libs)',
|
||||
'<@(geojsonvt_static_libs)',
|
||||
],
|
||||
},
|
||||
'conditions': [
|
||||
['OS == "mac"', {
|
||||
'xcode_settings': {
|
||||
'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
|
||||
'OTHER_LDFLAGS': [ '<@(ldflags)' ],
|
||||
},
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'xcode_settings': {
|
||||
'conditions': [
|
||||
['enable_coverage=="1"', {
|
||||
'OTHER_LDFLAGS': [ '--coverage' ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
'cflags_cc': [ '<@(cflags_cc)' ],
|
||||
'libraries': [ '<@(ldflags)' ],
|
||||
}],
|
||||
],
|
||||
'link_settings': {
|
||||
'conditions': [
|
||||
['OS == "mac"', {
|
||||
'libraries': [ '<@(libraries)' ],
|
||||
'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] }
|
||||
}, {
|
||||
'libraries': [ '<@(libraries)', '<@(ldflags)' ],
|
||||
}]
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user