8.1.8. cafeCC wrapper for complex setups

8.1.8.1. Background

Your project has at least one of the following properties:

  • multiple compilers are used in the same build (e.g. a certified compiler for functional safety and a non-certified compiler for more modern language features)

  • the build system cleans the whole environment when calling compiler subprocesses (e.g. SCons)

8.1.8.2. What needs to be done?

  • create a wrapper for cafeCC which sets the required environment variables for the compiler toolchain profile (e.g. especially BAUHAUS_CONFIG and CAFECC_BASEPATH)

GNU/Linux or macOS

Instead of using cafeCC as a compiler replacement, you need to use a wrapper shell script which you can place either in PATH or at any location when specifying the compiler via an absolute path.

The wrapper shell script (e.g. named custom-cc.sh and made executable) should contain the following exemplary content:

#!/bin/sh
export CAFECC_BASEPATH="/path/to/project"
export BAUHAUS_CONFIG="$CAFECC_BASEPATH/axivion/custom-cc"
cafeCC "$@"

Windows

Instead of using cafeCC as a compiler replacement, you need to use a wrapper executable which you can place either in PATH or at any location when specifying the compiler via an absolute path.

We supply the files cafeCCwrapper.exe and cafeCCwrapper.exe.config for such cases. Copy both files to the desired location and rename them according to your needs (e.g. to custom-cc.exe and custom-cc.exe.config).

In the *.exe.config file, modify the <appSettings> section to include the following variables:

<add key="env:CAFECC_BASEPATH" value="D:\path\to\project" />
<add key="env:BAUHAUS_CONFIG" value="D:\path\to\project\axivion\custom-cc" />

You can use %~dp0 to specify the directory location of the wrapper (which already includes the trailing backslash) and also the syntax %ENVVAR% to expand existing environment variables in the value attribute.