Skip to content

Commit bf016b8

Browse files
authored
Merge pull request #127 from Morwenn/develop
Release 1.1.0
2 parents 4c7ef49 + a5f4ff6 commit bf016b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2679
-1234
lines changed

.travis.yml

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,75 @@ addons:
88
packages:
99
- clang-3.8
1010
- g++-5
11+
- lcov
1112
- valgrind
1213

1314
cache:
14-
apt: true
1515
ccache: true
1616

1717
matrix:
1818
include:
1919

2020
# Linux clang
2121
- os: linux
22-
sudo: false
23-
env: BUILD_TYPE=Debug VALGRIND=true SANITIZE='' CMAKE_GENERATOR="Unix Makefiles"
22+
sudo: required
23+
env: BUILD_TYPE=Debug USE_VALGRIND=true CMAKE_GENERATOR="Unix Makefiles"
2424
compiler: clang
2525

2626
- os: linux
27-
sudo: false
28-
env: BUILD_TYPE=Debug VALGRIND=false SANITIZE=undefined CMAKE_GENERATOR="Unix Makefiles"
27+
sudo: required
28+
env: BUILD_TYPE=Debug SANITIZE=undefined CMAKE_GENERATOR="Unix Makefiles"
2929
compiler: clang
3030

3131
- os: linux
32-
sudo: false
33-
env: BUILD_TYPE=Debug VALGRIND=false SANITIZE=address CMAKE_GENERATOR="Unix Makefiles"
32+
sudo: required
33+
env: BUILD_TYPE=Debug SANITIZE=address CMAKE_GENERATOR="Unix Makefiles"
3434
compiler: clang
3535

3636
- os: linux
37-
sudo: false
38-
env: BUILD_TYPE=Release VALGRIND=false SANITIZE='' CMAKE_GENERATOR="Unix Makefiles"
37+
sudo: required
38+
env: BUILD_TYPE=Release CMAKE_GENERATOR="Unix Makefiles"
3939
compiler: clang
4040

4141
# Linux gcc
4242
- os: linux
4343
sudo: false
44-
env: BUILD_TYPE=Debug VALGRIND=true SANITIZE='' CMAKE_GENERATOR="Unix Makefiles"
44+
env: BUILD_TYPE=Debug USE_VALGRIND=true CMAKE_GENERATOR="Unix Makefiles"
4545
compiler: gcc
4646

4747
- os: linux
4848
sudo: false
49-
env: BUILD_TYPE=Debug VALGRIND=false SANITIZE=undefined CMAKE_GENERATOR="Unix Makefiles"
49+
env: BUILD_TYPE=Debug SANITIZE=undefined CMAKE_GENERATOR="Unix Makefiles"
5050
compiler: gcc
5151

5252
- os: linux
5353
sudo: false
54-
env: BUILD_TYPE=Debug VALGRIND=false SANITIZE=address CMAKE_GENERATOR="Unix Makefiles"
54+
env: BUILD_TYPE=Debug SANITIZE=address CMAKE_GENERATOR="Unix Makefiles"
5555
compiler: gcc
5656

5757
- os: linux
5858
sudo: false
59-
env: BUILD_TYPE=Release VALGRIND=false SANITIZE='' CMAKE_GENERATOR="Unix Makefiles"
59+
env: BUILD_TYPE=Release CMAKE_GENERATOR="Unix Makefiles"
6060
compiler: gcc
6161

6262
# OSX clang
6363
- os: osx
6464
osx_image: xcode8
65-
env: BUILD_TYPE=Debug VALGRIND=true SANITIZE='' CMAKE_GENERATOR="Xcode"
65+
env: BUILD_TYPE=Debug USE_VALGRIND=true CMAKE_GENERATOR="Xcode"
6666
compiler: clang
6767

6868
- os: osx
6969
osx_image: xcode8
70-
env: BUILD_TYPE=Release VALGRIND=false SANITIZE='' CMAKE_GENERATOR="Xcode"
70+
env: BUILD_TYPE=Release CMAKE_GENERATOR="Xcode"
7171
compiler: clang
7272

73+
# Code coverage
74+
- os: linux
75+
sudo: false
76+
if: branch in (master, develop)
77+
env: BUILD_TYPE=Debug CMAKE_GENERATOR="Unix Makefiles" ENABLE_COVERAGE=true
78+
compiler: gcc
79+
7380
# Conan
7481
- os: linux
7582
sudo: required
@@ -84,33 +91,45 @@ matrix:
8491
after_success:
8592
- conan remote add bintray https://api.bintray.com/conan/morwenn/cpp-sort
8693
- conan user -r bintray -p ${CONAN_PASSWORD} morwenn
87-
- conan upload --all -r bintray cpp-sort/1.0.0@morwenn/stable
94+
- conan upload --all -r bintray cpp-sort/1.1.0@morwenn/stable
8895

8996
before_install:
90-
- if [ `uname` = 'Darwin' ]; then
91-
brew update &&
92-
brew install ccache valgrind &&
97+
- if [[ $TRAVIS_OS_NAME = "osx" ]]; then
98+
brew update;
99+
brew install ccache valgrind;
93100
export PATH="/usr/local/opt/ccache/libexec:$PATH";
94101
fi
102+
- if [[ $TRAVIS_OS_NAME = "linux" && $CXX = "clang++" ]]; then
103+
sudo ln -s $(which ccache) /usr/lib/ccache/clang++;
104+
export CXXFLAGS="-Qunused-arguments";
105+
fi
95106

96107
install:
97-
- if [ "$CXX" = "g++" ]; then export CXX="g++-5"; fi
98-
- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.8"; fi
108+
- if [[ $CXX = "g++" ]]; then export CXX="g++-5"; fi
109+
- if [[ $CXX = "clang++" ]]; then export CXX="clang++-3.8"; fi
99110

100111
script:
101112
- cmake -H. -Bbuild
102113
-DCMAKE_CONFIGURATION_TYPES="${BUILD_TYPE}"
103114
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}"
104115
-DSANITIZE="${SANITIZE}"
105-
-DUSE_VALGRIND=${VALGRIND}
116+
-DUSE_VALGRIND=${USE_VALGRIND}
117+
-DENABLE_COVERAGE=${ENABLE_COVERAGE}
106118
-G"${CMAKE_GENERATOR}"
107-
- if [ `uname` = 'Darwin' ]; then
119+
- if [[ $TRAVIS_OS_NAME = "osx" ]]; then
108120
cmake --build build --config ${BUILD_TYPE} -- -jobs 2;
109121
else
110122
cmake --build build --config ${BUILD_TYPE} -- -j2;
111123
fi
112124
- cd build/testsuite
113125
- travis_wait ctest -C ${BUILD_TYPE} --output-on-failure
114126

127+
after_success:
128+
- if [[ $ENABLE_COVERAGE = true ]]; then
129+
make gcov;
130+
make lcov;
131+
bash <(curl -s https://codecov.io/bash) -X gcov || echo "Codecov did not collect coverage reports";
132+
fi
133+
115134
notifications:
116135
email: false

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cmake_minimum_required(VERSION 3.1.0)
66
# can optionally be built with CMake. This is what this script does.
77
#
88

9+
option(ENABLE_COVERAGE "whether to make suitable build for code coverage" OFF)
910
option(USE_VALGRIND "whether to run the tests with Valgrind" OFF)
1011

1112
set(CMAKE_CXX_STANDARD 14)
@@ -22,6 +23,15 @@ if (UNIX AND SANITIZE)
2223
endforeach()
2324
endif()
2425

26+
# Add suitable options for code coverage when needed
27+
if (ENABLE_COVERAGE)
28+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -Wextra -fprofile-arcs -ftest-coverage")
29+
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
30+
31+
set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
32+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
33+
endif()
34+
2535
# Include cpp-sort headers
2636
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
2737

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
[![Latest Release](https://img.shields.io/badge/release-cpp--sort%2F1.0.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases)
1+
[![Latest Release](https://img.shields.io/badge/release-cpp--sort%2F1.1.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases)
22
[![Build Status](https://travis-ci.org/Morwenn/cpp-sort.svg?branch=master)](https://travis-ci.org/Morwenn/cpp-sort)
33
[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)
4+
[![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/master/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort)
45

56
> *It would be nice if only one or two of the sorting methods would dominate all of the others,
67
> regardless of application or the computer being used. But in fact, each method has its own

cmake/FindGcov.cmake

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# This file is part of CMake-codecov.
2+
#
3+
# Copyright (c)
4+
# 2015-2017 RWTH Aachen University, Federal Republic of Germany
5+
#
6+
# See the LICENSE file in the package base directory for details
7+
#
8+
# Written by Alexander Haase, [email protected]
9+
#
10+
11+
12+
# include required Modules
13+
include(FindPackageHandleStandardArgs)
14+
15+
16+
# Search for gcov binary.
17+
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
18+
set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY})
19+
20+
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
21+
foreach (LANG ${ENABLED_LANGUAGES})
22+
# Gcov evaluation is dependend on the used compiler. Check gcov support for
23+
# each compiler that is used. If gcov binary was already found for this
24+
# compiler, do not try to find it again.
25+
if (NOT GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN)
26+
get_filename_component(COMPILER_PATH "${CMAKE_${LANG}_COMPILER}" PATH)
27+
28+
if ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "GNU")
29+
# Some distributions like OSX (homebrew) ship gcov with the compiler
30+
# version appended as gcov-x. To find this binary we'll build the
31+
# suggested binary name with the compiler version.
32+
string(REGEX MATCH "^[0-9]+" GCC_VERSION
33+
"${CMAKE_${LANG}_COMPILER_VERSION}")
34+
35+
find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov
36+
HINTS ${COMPILER_PATH})
37+
38+
elseif ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Clang")
39+
# Some distributions like Debian ship llvm-cov with the compiler
40+
# version appended as llvm-cov-x.y. To find this binary we'll build
41+
# the suggested binary name with the compiler version.
42+
string(REGEX MATCH "^[0-9]+.[0-9]+" LLVM_VERSION
43+
"${CMAKE_${LANG}_COMPILER_VERSION}")
44+
45+
# llvm-cov prior version 3.5 seems to be not working with coverage
46+
# evaluation tools, but these versions are compatible with the gcc
47+
# gcov tool.
48+
if(LLVM_VERSION VERSION_GREATER 3.4)
49+
find_program(LLVM_COV_BIN NAMES "llvm-cov-${LLVM_VERSION}"
50+
"llvm-cov" HINTS ${COMPILER_PATH})
51+
mark_as_advanced(LLVM_COV_BIN)
52+
53+
if (LLVM_COV_BIN)
54+
find_program(LLVM_COV_WRAPPER "llvm-cov-wrapper" PATHS
55+
${CMAKE_MODULE_PATH})
56+
if (LLVM_COV_WRAPPER)
57+
set(GCOV_BIN "${LLVM_COV_WRAPPER}" CACHE FILEPATH "")
58+
59+
# set additional parameters
60+
set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV
61+
"LLVM_COV_BIN=${LLVM_COV_BIN}" CACHE STRING
62+
"Environment variables for llvm-cov-wrapper.")
63+
mark_as_advanced(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV)
64+
endif ()
65+
endif ()
66+
endif ()
67+
68+
if (NOT GCOV_BIN)
69+
# Fall back to gcov binary if llvm-cov was not found or is
70+
# incompatible. This is the default on OSX, but may crash on
71+
# recent Linux versions.
72+
find_program(GCOV_BIN gcov HINTS ${COMPILER_PATH})
73+
endif ()
74+
endif ()
75+
76+
77+
if (GCOV_BIN)
78+
set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN "${GCOV_BIN}" CACHE STRING
79+
"${LANG} gcov binary.")
80+
81+
if (NOT CMAKE_REQUIRED_QUIET)
82+
message("-- Found gcov evaluation for "
83+
"${CMAKE_${LANG}_COMPILER_ID}: ${GCOV_BIN}")
84+
endif()
85+
86+
unset(GCOV_BIN CACHE)
87+
endif ()
88+
endif ()
89+
endforeach ()
90+
91+
92+
93+
94+
# Add a new global target for all gcov targets. This target could be used to
95+
# generate the gcov files for the whole project instead of calling <TARGET>-gcov
96+
# for each target.
97+
if (NOT TARGET gcov)
98+
add_custom_target(gcov)
99+
endif (NOT TARGET gcov)
100+
101+
102+
103+
# This function will add gcov evaluation for target <TNAME>. Only sources of
104+
# this target will be evaluated and no dependencies will be added. It will call
105+
# Gcov on any source file of <TNAME> once and store the gcov file in the same
106+
# directory.
107+
function (add_gcov_target TNAME)
108+
set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir)
109+
110+
# We don't have to check, if the target has support for coverage, thus this
111+
# will be checked by add_coverage_target in Findcoverage.cmake. Instead we
112+
# have to determine which gcov binary to use.
113+
get_target_property(TSOURCES ${TNAME} SOURCES)
114+
set(SOURCES "")
115+
set(TCOMPILER "")
116+
foreach (FILE ${TSOURCES})
117+
codecov_path_of_source(${FILE} FILE)
118+
if (NOT "${FILE}" STREQUAL "")
119+
codecov_lang_of_source(${FILE} LANG)
120+
if (NOT "${LANG}" STREQUAL "")
121+
list(APPEND SOURCES "${FILE}")
122+
set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID})
123+
endif ()
124+
endif ()
125+
endforeach ()
126+
127+
# If no gcov binary was found, coverage data can't be evaluated.
128+
if (NOT GCOV_${TCOMPILER}_BIN)
129+
message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.")
130+
return()
131+
endif ()
132+
133+
set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}")
134+
set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}")
135+
136+
137+
set(BUFFER "")
138+
foreach(FILE ${SOURCES})
139+
get_filename_component(FILE_PATH "${TDIR}/${FILE}" PATH)
140+
141+
# call gcov
142+
add_custom_command(OUTPUT ${TDIR}/${FILE}.gcov
143+
COMMAND ${GCOV_ENV} ${GCOV_BIN} ${TDIR}/${FILE}.gcno > /dev/null
144+
DEPENDS ${TNAME} ${TDIR}/${FILE}.gcno
145+
WORKING_DIRECTORY ${FILE_PATH}
146+
)
147+
148+
list(APPEND BUFFER ${TDIR}/${FILE}.gcov)
149+
endforeach()
150+
151+
152+
# add target for gcov evaluation of <TNAME>
153+
add_custom_target(${TNAME}-gcov DEPENDS ${BUFFER})
154+
155+
# add evaluation target to the global gcov target.
156+
add_dependencies(gcov ${TNAME}-gcov)
157+
endfunction (add_gcov_target)

0 commit comments

Comments
 (0)