Skip to content

malirod/value-or-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phone highlight

Build Status

Implementation of ValueOrError concept.

For details check:

Platform

Ubuntu 19.10: Clang 9, GCC 9, Cmake 3.13, Conan

C++14 Standard is used.

Google style is used.

See tools/Dockerfile for details how to setup development environment

Setup

Submodules are used. Initial command after clone is git submodule update --init --recursive.

Assuming all further commands are executed from project root.

Setup git hook

Run tools/install_hooks.py

This will allow to perform some code checks locally before posting changes to server.

Dependencies

Libs: Boost 1.69, Catch2

Project uses Conan Package Manager

Install conan with

sudo -H pip install conan

CMake will try to automatically setup dependencies.

Cmake will automatically check required dependencies and setup them taking into account current compiler (clang or gcc).

Draw deps with cmake

cmake --graphviz=graph ..
dot graph -T png -o graph.png

Install doxygen

sudo apt install -y doxygen graphviz

Build

Build commands

By default used clang compiler and debug mode.

Run in project root to build debug version with clang

mkdir build-clang-debug && cd build-clang-debug && cmake .. && make -j$(nproc)

To build release version with gcc run the following command

RUN mkdir build-gcc-release && cd build-gcc-release && CXX=g++ cmake -DCMAKE_BUILD_TYPE=Release .. && make -j$(nproc)

Build with sanitizers (clang)

You can enable sanitizers with SANITIZE_ADDRESS, SANITIZE_MEMORY, SANITIZE_THREAD or SANITIZE_UNDEFINED options in your CMake configuration. You can do this by passing e.g. -DSANITIZE_ADDRESS=On in your command line.

Run

Run from build directory

ctest

or

build/testrunner

Coverage report

To enable coverage support in general, you have to enable ENABLE_COVERAGE option in your CMake configuration. You can do this by passing -DENABLE_COVERAGE=On on your command line or with your graphical interface.

If coverage is supported by your compiler, the specified targets will be build with coverage support. If your compiler has no coverage capabilities (I assume Intel compiler doesn't) you'll get a warning but CMake will continue processing and coverage will simply just be ignored.

Collect coverage in Debug mode. Tested with gcc 8 and clang 7 compiler.

Sample commands to get coverage html report

CXX=g++ cmake -DENABLE_COVERAGE=On -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)
make test
make lcov-capture
make lcov-genhtml
xdg-open lcov/html/selected_targets/index.html

Integration

Create docker image

Dockerfile: image, which contains basic environment setup (compiler, build tools)

docker build -t value-or-error -f tools/Dockerfile .

Clang static analyzer

Sample command to run analyzer. By default report is stored in /tmp/scan-build*

mkdir build-debug
cd build-debug
scan-build --use-analyzer=/usr/bin/clang++ cmake ..
scan-build --use-analyzer=/usr/bin/clang++ make -j$(nproc)

or

cmake ..
make clang-static-analyzer

Clang-tidy

Setting are stored in .clang-tidy.

Run

mkdir build
cd build
cmake ..
make clang-tidy

Documentation

Code contains doxygen. To generate html documentation run command make doc. Output will be in `\doc\html