📜 ⬆️ ⬇️

We build PVS-Studio in Eclipse CDT (Linux)

The news about the possibility of free source verification using PVS-Studio has finally stimulated me to implement source verification in Eclipse CDT. And then for CLion / QtCreator / etc it was written as , but purple was bypassed :) For the experiments we used: Eclipse IDE for C / C ++ Developers, Version: Neon.1a Release (4.6.1), Build id: 20161007-1200 and PVS-Studio 6.11.20138.1. And that's what happened.

To begin, let's wrap the analyzer's call into the script (about it later) and we will call it as an external utility. In the configuration, specify the working directory:

External Tools Configurations / Main


And turn on the checkbox "Allocate console":

External Tools Configurations / Common


The disadvantage of this method is that the output will not be understood by the Eclipse parser, and it can be seen only in the console:
')
Run as External Tool


If this method does not suit you, you can embed the check into an external utility for assembly. The method is not suitable for all projects, but if it suits, then go to the project properties and configure the External Builder parameters for the current configuration:

  1. We select External builder as Build type
  2. Uncheck “Use default build command”
  3. In the field "Build command" enter our script
  4. Check "Generate Makefiles automatically"

C / C ++ Build


The "-k" key Eclipse adds itself. Accordingly, when building a project, our script will be called with the "-k all" keys, while clearing, with the "-k clean".

As a result, we will receive an automatic check of the project during the assembly, plus the output that Eclipse understands and, as a result, navigation through the sources in the Problems window:

Run as Builder


Well, now the script itself:

#!/bin/sh #      External Tool,   `make clean`: if [ -z "$1" ]; then make -f makefile clean fi #   ,  : if [ "$2" = "clean" ]; then make -f makefile clean #      : exit fi #  clean    External Tool -  : TEMPLOG=$(tempfile) #   `strace`,      : pvs-studio-analyzer trace -- make -f makefile all 2>&1 | sed '/strace: umovestr:/d' - pvs-studio-analyzer analyze -o "$TEMPLOG" #   ,       : RC=$(plog-converter -t errorfile "$TEMPLOG" | sed '/The documentation for all/d' -) rm -f "$TEMPLOG" echo "$RC" 

For now. On real projects, nothing has been driven yet, maybe some shortcomings will come out there. But the general scheme is clear in principle.

Source: https://habr.com/ru/post/316670/


All Articles