Capturing your build settings for QNX MomenticsCapturing your build settings for QNX MomenticsBefore analyzing C/C++ projects in QNX Momentics, you must customize the IDE build process to improve the capture of build settings. Klocwork requires a build specification to perform an analysis. The build specification contains a list of the project's source files and their compiler options (includes and defines). Klocwork creates the build specification by monitoring the IDE build process or by monitoring an external (command-line) build process. The former is recommended as it automatically updates the build specification when files are added or removed from the project. Before you begin
Make sure you use Java the appropriate version of JavaQNX Momentics 4.6 and 4.7 use Java 5 by default. The Klocwork Eclipse plug-in requires Java 7. Specify the JVM for Momentics 4.6 and 4.7 in the qde.ini file (for example, \QNX650\host\win32\x86\usr\qde\eclipse\qde.ini) by adding the following two lines to the beginning of the file: -vm <jvm_install_path>\bin
Make sure you're using a supported builderMomentics uses three types of builders to make C/C++ projects. (Eclipse C/C++ projects use #2 and #3.)
If a project is being built with the "Internal CDT Builder", then you need to change its build type. Klocwork requires the "QNX Recursive Make Builder" or the "Gnu Make Builder" be specified to automatically produce an accurate build specification. You select the builder for a project with the C/C++ Build/Tool Chain Editor properties page. Continue to the next section or skip to Gnu Make Builder. QNX Recursive Make BuilderMonitoring the QNX Recursive make process requires a command/shell file be created on your machine because of how Momentics sets the MAKE environment variable. The command/shell file sets MAKE to the correct value.
Create the command/shell file kwinjectqnxBefore you can create the command/shell file, you must ensure you have the command line desktop analysis tools installed. For more information, see Downloading and deploying the desktop analysis plug-ins Windows: Create a kwinjectqnx.bat file and place it in the <command_line_tools>\bin directory (for example, C:\Klocwork\Klocwork 2018.1 Command Line\bin). The kwinjectqnx.bat file should contain two lines: set MAKE=%1 kwinject -u -o buildspec.out %* Linux: Create an executable kwinjectqnx.sh file and place it in the <command_line_tools>/bin directory (for example, /opt/tools/klocwork/commandlinetools/bin). The kwinjectqnx.sh file should contain three lines: MAKE=$1 export MAKE kwinject -u -o buildspec.out $*
Modify each project's Build CommandIn the Momentics Project Explorer, select each C/C++ project in turn and view the C/C++ Build tab of the project properties. In the Momentics Project Explorer, select each QNX C/C++ project in turn and view the Make Builder tab of the project properties. Deselect Use Default Build command and add the appropriate command/shell in front of the existing Build Command contents. For example: Windows ${system_path:kwinjectqnx.bat} ${QNX_HOST}/usr/bin/make ... Linux ${system_path:kwinjectqnx.sh} ${QNX_HOST}/usr/bin/make ...
Build each projectBuild each project in turn by doing a Clean followed by a Build. Verify that there are no build errors in the Momentics Console window.
Modify each project's Klocwork Build settingsTo modify each project's Klocwork Build Settings to use the build specification (buildspec.out) generated by the previous steps:
Now go back to Connect to a project on the Klocwork Server. Gnu Make BuilderThe Gnu Make Builder changes are simpler because the make process is not recursive.
Modify each project's Build CommandIn the Momentics Project Explorer, select each C/C++ project in turn and view the C/C++ Build project properties page. Deselect the Use Default Build command and add the kwinject command, and its arguments, in front of the existing Build Command contents. For example: ${system_path:kwinject} -u -o ${ProjDirPath}/buildspec.out make ...
Build each projectBuild each project in turn by doing a Clean followed by a Build. Verify that there are no build errors in the Momentics Console window.
Modify each project's Klocwork Build settingsTo modify each project's Klocwork Build Settings to use the build specification (buildspec.out) generated by the previous steps:
Now go back to Connect to a project on the Klocwork Server. |