8.4.2. Eclipse Project Setup¶
Eclipse for C/C++ can be used in various ways; consequently, there are different methods for building your project for analysis with the Axivion Suite. We enumerate some of the most common setups below. The descriptions are written for Windows, but the same type of setup also works on other operating systems.
The major distinction of Eclipse CDT projects is between:
projects built by an external build tool (Makefile Projects)
projects managed by Eclipse CDT (Managed Make)
For several Eclipse-based IDEs, the folder profiles in the Axivion Suite
installation folder contains ready-made build scripts, see
IDE Profiles.
8.4.2.1. Makefile Project¶
Eclipse can be used for projects with external makefiles. In this case, Eclipse only triggers the build by calling an external make tool. Set up the project using this external make tool and do not use Eclipse as the build driver.
8.4.2.2. Managed Make¶
In Managed Make projects, Eclipse is responsible for maintaining the build rules. You
must set up a build that builds the project using cafeCC instead of the original
compiler and linker.
Basic Configuration in Eclipse¶
For the project setup, you can either use an existing configuration or create a new one.
Create a new Build Configuration for the build with Axivion Suite¶
You can add a new build configuration to your project and configure the C/C++ toolchain
to run cafeCC and build IR directly. This setup is possible if you mainly use
configurations for different build types (e.g., “Debug” and “Release”) which can
easily be cloned and do not change often.
To configure this, open the project Properties, select C/C++ Build, and click Manage
Configurations. Add the new configuration. Then, go to C/C++ Build > Settings and configure all
build tools to execute cafeCC.
Once this build configuration is selected, Eclipse will build an IR file that can be picked up for analysis.
Use an existing Build Configuration¶
If you prefer not to maintain an additional build configuration for the build with Axivion Suite, you can use an existing one. This is preferable if you use different build configurations for various software variants and want to analyze several of them using Axivion Suite.
In the project properties under C/C++ Build > Settings > Tool Settings, prepend
$(AXIVION_INJECTOR) followed by a space to the command line pattern of each build
tool (C compiler, C++ compiler, assembler, linker). For example, the command line
pattern of the C compiler becomes:
$(AXIVION_INJECTOR) ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}
$(AXIVION_INJECTOR) is a make variable and ends up in the generated makefile
unchanged, whereas Eclipse expands ${...}. Eclipse does not define the variable, so
it builds natively as before, without the Axivion Suite. For the analysis, set
AXIVION_INJECTOR to axivion_injector MODE, where MODE selects what
axivion_injector builds:
cdt: withBAUHAUS_CONFIGset, only Axivion IR files, with the suffix.ir, so that they do not overwrite native objects.ir: only Axivion IR files, with the original file names.
Setup Server Build¶
To set up the server build (i.e., when axivion_ci runs in ci_mode),
Eclipse can be started in headless mode to build the
project. The procedure depends on the specific Eclipse installation; we describe
a default method below. Note that this build mode can only be
executed while the Eclipse workspace is not locked. Consequently, the headless build
cannot run if an open Eclipse instance is using the same workspace. We assume that the
server build has its own workspace, which remains closed otherwise during the server build.
In
start_analysis.bat, set the name of the Eclipse build configuration as an environment variable. This variable can be referenced in the project configuration and the build process. In the following example, we assume that the “Release” configuration is used:set "CONFIG_NAME=Release" axivion_ci
Create a file named
build_ir.batto call Eclipse in headless mode. If you use an existing build configuration (see Use an existing Build Configuration), setAXIVION_INJECTORin the environment; the headless build passes the environment on to make:set "CONFIG_NAME=%1" set "AXIVION_INJECTOR=axivion_injector cdt" eclipsec ^ --launcher.suppressErrors ^ -nosplash ^ -application org.eclipse.cdt.managedbuilder.core.headlessbuild ^ -importAll "%IDE_PROJECT_PATH%" ^ -data "%IDE_WORKSPACE_PATH%" ^ -cleanBuild "%CONFIG_NAME%"
In your project configuration, choose Command as BuildSystemIntegration and set
build_commandto$(builtin:AXIVION_CONFDIR)/build_ir.bat $(env:CONFIG_NAME).Configure a suitable
clean_commandif workspace cleaning is not handled via your external CI.
Setup Local Build¶
If you configured a separate build configuration in Eclipse (as in step Create a new Build Configuration for the build with Axivion Suite), you can execute the Local Build in two steps:
Build the respective configuration in Eclipse using the standard build command.
Configure /Project/ir in your project configuration to pick up the IR file generated by this build configuration.
If you decide to reuse an existing build configuration, you cannot use the built-in build feature of Eclipse. Consider the following issues:
The original build should not be overwritten by the Axivion build, and vice-versa.
The Axivion build should run incrementally.
The Eclipse headless build cannot be used because the workspace is locked while Eclipse is running.
Therefore, set up the Local Build to call GNU Make directly on the makefiles that Eclipse generated for the original build:
In your
build_ir.batfile, create an alternative section for the Local Build. This section is activated whenaxivion_ciis run inlocal_mode, which implicitly sets the environment variableAXIVION_LOCAL_BUILD. Use this variable as a condition to select the alternative case:Clone the makefiles generated for the original build into a separate build tree directory using the script
clone_build_structure.py. The Axivion build in the cloned build tree runs incrementally. This step is optional; you may also reuse the original build tree withAXIVION_INJECTOR="axivion_injector cdt"instead.Build the project by calling GNU Make from your
build_ir.bat. By default,clone_build_structure.pywrites the cloned build tree to a directory using the original build tree path with the suffix.Axivion_Local:
set "LOCAL_BUILD_DIR=%CONFIG_NAME%.Axivion_Local" if defined AXIVION_LOCAL_BUILD ( rfgscript "%~dp0clone_build_structure.py" "%CONFIG_NAME%" make -C "%LOCAL_BUILD_DIR%" "AXIVION_INJECTOR=axivion_injector ir" all ) else ( rem server build, code see above )
Ensure the Eclipse build configuration is passed as the first parameter to
build_ir.bat, and executebuild_ir.batin a working directory where the first parameter is a relative path to the existing original build tree.
8.4.2.3. IDE Profiles¶
The folder profiles in the Axivion Suite installation folder contains
instructions for several IDEs. The Eclipse-based ones use an existing build
configuration with $(AXIVION_INJECTOR) as described in
Use an existing Build Configuration. Each of them has its own axivion_injector
mode, which currently is an alias for cdt. For the compiler profiles in the same folder, see
Compiler profile overview.
IDEs with build scripts¶
The profiles of the following IDEs contain the example build scripts
build_ir.sh and build_ir.bat, which implement the server build and the
local build described above. The comments in each script list the changes to the
project properties and the paths and project settings to adjust. Use the script as
build command of the project configuration.
Atollic TrueSTUDIO¶
Profile:
profiles/atollicaxivion_injectormode:atollicCommand line patterns: C Compiler, C++ Compiler, Assembler, Linker
Infineon DAVE¶
Profile:
profiles/daveaxivion_injectormode:daveCommand line patterns: C Compiler, C++ Compiler, Assembler, Linker
Copy your
DAVE.inifile into the project configuration folder and remove the switch-showlocationfrom the copy.
NXP S32 Design Studio¶
Profile:
profiles/s32dsaxivion_injectormode:s32dsCommand line patterns: Standard S32DS C Compiler, Standard S32DS C++ Compiler, Standard S32DS Assembler, Standard S32DS Linker
If make does not find
cafeCC, append the folderbinof the Axivion Suite installation toPATHin the build environment of the project.If Platform SDK headers such as
StandardTypes.hare not found, define the Platform SDK build variables of the project, as described in the script.
STM32CubeIDE¶
Profile:
profiles/stm32cubeideaxivion_injectormode:stm32cubeideCommand line patterns: C Compiler, C++ Compiler, Assembler, Linker
Texas Instruments Code Composer Studio¶
Profile:
profiles/tiaxivion_injectormode:ticcsCommand line patterns: Compiler, Linker
Vitis (Classic)¶
Profile:
profiles/xilinx-vitisaxivion_injectormode:vitisCommand line patterns, under Expert settings: C Compiler, C++ Compiler, Assembler, C Linker, C++ Linker, Archiver, Print Size
The headless build does not work for Vitis Classic. The script prepares the workspace with xsct and always builds with make.
IDEs without build scripts¶
For the following IDEs, call make on the generated makefile with
BAUHAUS_CONFIG set and the make variables given for each IDE.
Analog Devices Blackfin¶
Profile:
profiles/blackfinaxivion_injectormode:blackfinCommand line patterns: C Compiler, C++ Compiler, Assembler, Linker
Make variables:
AXIVION_INJECTOR="axivion_injector blackfin"
Freescale CodeWarrior S12Z¶
Profile:
profiles/codewarrioraxivion_injectormode:codewarriorCommand line patterns: Compiler, Linker
Make variables:
AXIVION_INJECTOR="axivion_injector codewarrior"For further CodeWarrior topics, see Code Warrior.
Microchip MPLAB X¶
Profile:
profiles/microchipMPLAB X is not Eclipse-based. Its generated makefiles call the build tools through make variables, so no changes to the project properties are needed.
Make variables:
MP_CC=cafeCC MP_AS=cafeCC MP_LD=cafeCC
Wind River Workbench¶
Profile:
profiles/windriverstart_analysis.batis an example of how to start the analysis with wrenv.exe, which sets up the environment variables of the Wind River installation.