summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-02-21 17:15:31 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-02-21 17:22:26 +0200
commitbfd5ad3220e7abe928daca98605012c1a12ae377 (patch)
tree1238c17671e7c069c87208b506fa092385fab13b
parent8219d72135c007c44b61a781c95c817a8618c478 (diff)
downloadqtlocation-mapboxgl-bfd5ad3220e7abe928daca98605012c1a12ae377.tar.gz
[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.
-rw-r--r--Makefile1
-rw-r--r--gyp/common.gypi75
-rw-r--r--platform/linux/mapboxgl-app.gypi26
-rw-r--r--scripts/main.mk6
-rw-r--r--test/test.gypi33
5 files changed, 70 insertions, 71 deletions
diff --git a/Makefile b/Makefile
index 5cada812d7..6e8eda4377 100644
--- a/Makefile
+++ b/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)
diff --git a/gyp/common.gypi b/gyp/common.gypi
index 13565b04e6..118c75000e 100644
--- a/gyp/common.gypi
+++ b/gyp/common.gypi
@@ -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' ],
+ }],
+ ],
},
},
}
diff --git a/platform/linux/mapboxgl-app.gypi b/platform/linux/mapboxgl-app.gypi
index 19c17f6249..a2c61e9d3b 100644
--- a/platform/linux/mapboxgl-app.gypi
+++ b/platform/linux/mapboxgl-app.gypi
@@ -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)' ],
+ }]
+ ],
+ },
},
],
}
diff --git a/scripts/main.mk b/scripts/main.mk
index a215be635f..0891734543 100644
--- a/scripts/main.mk
+++ b/scripts/main.mk
@@ -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
diff --git a/test/test.gypi b/test/test.gypi
index 1842a807fb..f12588890a 100644
--- a/test/test.gypi
+++ b/test/test.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)' ],
+ }]
+ ],
+ },
},
]
}