Skip to content

Commit 6a4878b

Browse files
author
Geoffrey Hunter
committed
Merge branch 'develop'
2 parents de126c4 + 92629c0 commit 6a4878b

File tree

348 files changed

+25640
-1495
lines changed

Some content is hidden

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

348 files changed

+25640
-1495
lines changed

.travis.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
language: cpp
22
compiler: g++
33

4-
before_install:
5-
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
6-
- sudo apt-get update -qq
7-
- mkdir $HOME/usr
8-
- export PATH="$HOME/usr/bin:$PATH"
9-
- wget https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.sh
10-
- chmod +x cmake-3.7.2-Linux-x86_64.sh
11-
- ./cmake-3.7.2-Linux-x86_64.sh --prefix=$HOME/usr --exclude-subdir --skip-license
4+
sudo: required
5+
dist: trusty
6+
7+
addons:
8+
apt:
9+
sources:
10+
- llvm-toolchain-precise
11+
- ubuntu-toolchain-r-test
12+
packages:
13+
- clang-3.7
14+
- g++-5
15+
- gcc-5
16+
- lcov
1217

1318
install:
14-
- sudo apt-get install -qq g++-4.8
15-
- export CXX="g++-4.8"
19+
- if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi
20+
- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
21+
22+
script:
23+
# Run the build script, telling it to run/upload coverage tests and install files
24+
# on local system (purely to make sure the install process works correctly)
25+
- ./tools/build.sh -i -c
1626

17-
script:
18-
- mkdir build
19-
- cd build
20-
- cmake ..
21-
- make
22-
- ./test/MFixedPointTests
27+
after_success:
28+
# Creating report
29+
# - cd ${TRAVIS_BUILD_DIR}
30+
# - lcov --directory . --capture --output-file coverage.info # capture coverage info
31+
# - lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter out system
32+
# - lcov --list coverage.info #debug info
33+
# # Uploading report to CodeCov
34+
# - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) (as of v7.0.0).
6+
7+
## [Unreleased]
8+
9+
## [v7.0.0] - 2017-12-13
10+
11+
### Added
12+
- Added enclosing `mn` namespace for all source code, closes #84.
13+
- Added this CHANGELOG.md file, closes #85.
14+
- Added documentation to 'docs/', closes #87.
15+
- Added code coverage support.
16+
17+
### Changed
18+
- Changed the `Fp` namespace to `MFixedPoint` (to reflect actual project name), closes #86.
19+
- Modified header guard macros to include the text `MN_MFIXEDPOINT_...` (to include organization/project name).

CMakeLists.txt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ project(MFixedPoint)
44

55
add_definitions(-std=c++11)
66

7-
option(BUILD_DEPENDENCIES "If set to ON, dependencies will be downloaded and built as part of the build process." ON)
7+
# Custom CMake module path that is part if this repo
8+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
9+
10+
include(CodeCoverage)
11+
12+
#=================================================================================================#
13+
#========================================= INPUT ARGUMENTS =======================================#
14+
#=================================================================================================#
815

16+
option(BUILD_DEPENDENCIES "If set to ON, dependencies will be downloaded and built as part of the build process." ON)
917
if (BUILD_DEPENDENCIES)
1018
message("BUILD_DEPENDENCIES=ON, dependencies will be downloaded and built automatically.")
1119
# EXTERNAL_INSTALL_LOCATION is used by external projects, except for gtest
@@ -15,6 +23,20 @@ else ()
1523
message("BUILD_DEPENDENCIES=OFF, dependencies have to be downloaded, built and installed manually.")
1624
endif ()
1725

26+
option(BUILD_TESTS "If set to true, unit tests will be build as part of make all." TRUE)
27+
if (BUILD_TESTS)
28+
message("BUILD_TESTS=TRUE, unit tests will be built.")
29+
else ()
30+
message("BUILD_TESTS=FALSE, unit tests will NOT be built.")
31+
endif ()
32+
33+
option(COVERAGE "If set to true, coverage will be enabled." FALSE)
34+
if (COVERAGE)
35+
message("COVERAGE=TRUE, coverage will be enabled.")
36+
else ()
37+
message("COVERAGE=FALSE, coverage will NOT be enabled.")
38+
endif ()
39+
1840
#=================================================================================================#
1941
#============================================ MUnitTest ==========================================#
2042
#=================================================================================================#
@@ -32,7 +54,9 @@ endif ()
3254
include_directories(include)
3355

3456
add_subdirectory(src)
35-
add_subdirectory(test)
57+
if(BUILD_TESTS)
58+
add_subdirectory(test)
59+
endif()
3660
add_subdirectory(benchmark)
3761

3862

CMakeModules/CodeCoverage.cmake

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# Copyright (c) 2012 - 2015, Lars Bilke
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without modification,
5+
# are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# 3. Neither the name of the copyright holder nor the names of its contributors
15+
# may be used to endorse or promote products derived from this software without
16+
# specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
#
29+
#
30+
#
31+
# 2012-01-31, Lars Bilke
32+
# - Enable Code Coverage
33+
#
34+
# 2013-09-17, Joakim Söderberg
35+
# - Added support for Clang.
36+
# - Some additional usage instructions.
37+
#
38+
# USAGE:
39+
40+
# 0. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here:
41+
# http://stackoverflow.com/a/22404544/80480
42+
#
43+
# 1. Copy this file into your cmake modules path.
44+
#
45+
# 2. Add the following line to your CMakeLists.txt:
46+
# INCLUDE(CodeCoverage)
47+
#
48+
# 3. Set compiler flags to turn off optimization and enable coverage:
49+
# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
50+
# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
51+
#
52+
# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
53+
# which runs your test executable and produces a lcov code coverage report:
54+
# Example:
55+
# SETUP_TARGET_FOR_COVERAGE(
56+
# my_coverage_target # Name for custom target.
57+
# test_driver # Name of the test driver executable that runs the tests.
58+
# # NOTE! This should always have a ZERO as exit code
59+
# # otherwise the coverage generation will not complete.
60+
# coverage # Name of output directory.
61+
# )
62+
#
63+
# 4. Build a Debug build:
64+
# cmake -DCMAKE_BUILD_TYPE=Debug ..
65+
# make
66+
# make my_coverage_target
67+
#
68+
#
69+
70+
# Check prereqs
71+
FIND_PROGRAM( GCOV_PATH gcov )
72+
FIND_PROGRAM( LCOV_PATH lcov )
73+
FIND_PROGRAM( GENHTML_PATH genhtml )
74+
FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
75+
76+
IF(NOT GCOV_PATH)
77+
MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
78+
ENDIF() # NOT GCOV_PATH
79+
80+
IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
81+
IF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
82+
MESSAGE(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
83+
ENDIF()
84+
ELSEIF(NOT CMAKE_COMPILER_IS_GNUCXX)
85+
MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
86+
ENDIF() # CHECK VALID COMPILER
87+
88+
SET(CMAKE_CXX_FLAGS_COVERAGE
89+
"-g -O0 --coverage -fprofile-arcs -ftest-coverage"
90+
CACHE STRING "Flags used by the C++ compiler during coverage builds."
91+
FORCE )
92+
SET(CMAKE_C_FLAGS_COVERAGE
93+
"-g -O0 --coverage -fprofile-arcs -ftest-coverage"
94+
CACHE STRING "Flags used by the C compiler during coverage builds."
95+
FORCE )
96+
SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
97+
""
98+
CACHE STRING "Flags used for linking binaries during coverage builds."
99+
FORCE )
100+
SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
101+
""
102+
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
103+
FORCE )
104+
MARK_AS_ADVANCED(
105+
CMAKE_CXX_FLAGS_COVERAGE
106+
CMAKE_C_FLAGS_COVERAGE
107+
CMAKE_EXE_LINKER_FLAGS_COVERAGE
108+
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
109+
110+
IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage"))
111+
MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
112+
ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
113+
114+
115+
# Param _targetname The name of new the custom make target
116+
# Param _testrunner The name of the target which runs the tests.
117+
# MUST return ZERO always, even on errors.
118+
# If not, no coverage report will be created!
119+
# Param _outputname lcov output is generated as _outputname.info
120+
# HTML report is generated in _outputname/index.html
121+
# Optional fourth parameter is passed as arguments to _testrunner
122+
# Pass them in list form, e.g.: "-j;2" for -j 2
123+
FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
124+
125+
IF(NOT LCOV_PATH)
126+
MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
127+
ENDIF() # NOT LCOV_PATH
128+
129+
IF(NOT GENHTML_PATH)
130+
MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
131+
ENDIF() # NOT GENHTML_PATH
132+
133+
SET(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info")
134+
SET(coverage_cleaned "${coverage_info}.cleaned")
135+
136+
SEPARATE_ARGUMENTS(test_command UNIX_COMMAND "${_testrunner}")
137+
138+
# Setup target
139+
ADD_CUSTOM_TARGET(${_targetname}
140+
141+
# Cleanup lcov
142+
${LCOV_PATH} --directory . --zerocounters
143+
144+
# Run tests
145+
COMMAND ${test_command} ${ARGV3}
146+
147+
# Capturing lcov counters and generating report
148+
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${coverage_info}
149+
COMMAND ${LCOV_PATH} --remove ${coverage_info} 'tests/*' '/usr/*' --output-file ${coverage_cleaned}
150+
COMMAND ${GENHTML_PATH} -o ${_outputname} ${coverage_cleaned}
151+
COMMAND ${CMAKE_COMMAND} -E remove ${coverage_info} ${coverage_cleaned}
152+
153+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
154+
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
155+
)
156+
157+
# Show info where to find the report
158+
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
159+
COMMAND ;
160+
COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
161+
)
162+
163+
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
164+
165+
# Param _targetname The name of new the custom make target
166+
# Param _testrunner The name of the target which runs the tests
167+
# Param _outputname cobertura output is generated as _outputname.xml
168+
# Optional fourth parameter is passed as arguments to _testrunner
169+
# Pass them in list form, e.g.: "-j;2" for -j 2
170+
FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
171+
172+
IF(NOT PYTHON_EXECUTABLE)
173+
MESSAGE(FATAL_ERROR "Python not found! Aborting...")
174+
ENDIF() # NOT PYTHON_EXECUTABLE
175+
176+
IF(NOT GCOVR_PATH)
177+
MESSAGE(FATAL_ERROR "gcovr not found! Aborting...")
178+
ENDIF() # NOT GCOVR_PATH
179+
180+
ADD_CUSTOM_TARGET(${_targetname}
181+
182+
# Run tests
183+
${_testrunner} ${ARGV3}
184+
185+
# Running gcovr
186+
COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml
187+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
188+
COMMENT "Running gcovr to produce Cobertura code coverage report."
189+
)
190+
191+
# Show info where to find the report
192+
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
193+
COMMAND ;
194+
COMMENT "Cobertura code coverage report saved in ${_outputname}.xml."
195+
)
196+
197+
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA

README.rst

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ A microcontroller-friendly fixed-point library specifically designed for embedde
99
.. image:: https://travis-ci.org/mbedded-ninja/MFixedPoint.png?branch=master
1010
:target: https://travis-ci.org/mbedded-ninja/MFixedPoint
1111

12-
- Author: gbmhunter <[email protected]> (http://blog.mbedded.ninja)
13-
- Created: 2012-10-23
14-
- Last Modified: 2017-06-27
15-
- Version: v6.0.2
16-
- Company: mbedded.ninja
17-
- Project: MToolkit
18-
- Language: C++
19-
- Compiler: GCC
20-
- uC Model: Any
21-
- Computer Architecture: Any
22-
- Operating System: Any
23-
- Documentation Format: Doxygen
24-
- License: GPLv3
12+
13+
.. image:: https://codecov.io/gh/mbedded-ninja/MFixedPoint/branch/master/graph/badge.svg
14+
:target: https://codecov.io/gh/mbedded-ninja/MFixedPoint
15+
2516

2617
Description
2718
===========

benchmark/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "MFixedPoint/Fp64f.hpp"
2020
#include "MFixedPoint/Fp64s.hpp"
2121

22-
using namespace Fp;
22+
using namespace mn::MFixedPoint;
2323

2424
#define NUM_TESTS 10000
2525

0 commit comments

Comments
 (0)