Skip to content

Commit

Permalink
[gyp] Coverage only if BUILDTYPE=Debug and ENABLE_COVERAGE=1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brunoabinader committed Feb 21, 2016
1 parent 8219d72 commit bfd5ad3
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 71 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
75 changes: 42 additions & 33 deletions gyp/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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' ],
}],
],
},
},
}
Expand Down
26 changes: 11 additions & 15 deletions platform/linux/mapboxgl-app.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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)' ],
}]
],
},
},
],
}
6 changes: 1 addition & 5 deletions scripts/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 15 additions & 18 deletions test/test.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand All @@ -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)' ],
}]
],
},
},
]
}

0 comments on commit bfd5ad3

Please sign in to comment.