bmwcarit / capu

Collections And Platform Utils (CAPU)
Apache License 2.0
19 stars 10 forks source link

Build Status Coverity Status

Introduction

CAPU stands for Collections and Platform Utils. It is a library providing both an implementation of a modified C++ STL interface and a platform abstraction framework. This library has been designed for projects running on multiple hardware platforms and/or operation systems.


Build environment

The CAPU build scripts are based on CMake, but we avoided writing plain CMake build scripts for each module of the project. Instead we use a centralized set of CMake macros for project configuration, which are called ACME2 ("Another CMake Extension 2"). Having centralized scripts greatly improves maintainability of our build scripts and guarantees the same behaviour for each module.

Concerning build environment setup, ACME2 is fully transparent, therefore CAPU can be treated as standard CMake project.

There's one special behaviour, which is uncommon for CMake based projects: CAPU requires the use of a toolchain file to configure itself for the given platform. These example toolchain files are located in the following directory: cmake/toolchain

Example to generate a Makefile build environment on Linux 64 bit host:

$ mkdir <build-dir>
$ cd <build-dir>
$ cmake -DCMAKE_TOOLCHAIN_FILE=<capu-root>/cmake/toolchain/Linux_X86_64.toolchain <capu-root>
$ make

If you use the cmake-gui you need to select the option "Specify toolchain file for cross-compiling" during the configure step.

Activate test for build

The CAPU unit tests are based on the Google C++ Testing Framework (https://github.com/google/googletest). This dependency is already contained in the Git repository as a Git submodule. In order to checkout the repository, please execute the following Git command:

$ cd <capu-root>
$ git submodule update --init --recursive

In order to enable the CAPU unit tests, you need to activate the CMake option Capu_BUILD_TESTS. Command line:

$ cmake -DCapu_BUILD_TESTS:BOOL=ON -DCMAKE_TOOLCHAIN_FILE=<capu-root>/cmake/toolchain/Linux_X86_64.toolchain <capu-root> 

C++ STL implementation

On multiplatform projects normally you don’t want to use the STL implementation shipped with the target’s compiler in order to avoid getting in trouble with different behaviors, error handling mechanisms or performance issues.

Why we don’t use existing implementations?

At the moment we support only a subset of the known STL constructs:


Platform abstraction

The platform abstraction itself has been designed in a way that it is easy to maintain and extend without any IFDEF blocks in the code itself. Furthermore if the platform abstraction is the same on multiple platforms (e.g. ARM and x86, Linux and QNX) no code duplication is needed.

At the moment we have an abstraction for the following platforms/OS:

The following features are available on those platforms:


Utils build on top of platform abstraction or STL containers

All mentioned components are heavily tested by using the GoogleMock/GoogleTest framework. Furthermore it is possible to execute the test executable on the all of the mentioned platforms.