Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viva64/pvs-studio-makefile-examples
Examples of PVS-Studio integration in Makefile
https://github.com/viva64/pvs-studio-makefile-examples
makefile pvs-studio
Last synced: 4 days ago
JSON representation
Examples of PVS-Studio integration in Makefile
- Host: GitHub
- URL: https://github.com/viva64/pvs-studio-makefile-examples
- Owner: viva64
- License: apache-2.0
- Created: 2018-01-30T09:43:31.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-25T11:50:52.000Z (over 2 years ago)
- Last Synced: 2024-09-27T01:49:48.410Z (4 months ago)
- Topics: makefile, pvs-studio
- Language: Makefile
- Size: 15.6 KB
- Stars: 7
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Examples of PVS-Studio integration in Makefile
A few examples in this repository will help you learn to properly integrate [PVS-Studio](https://www.pvs-studio.com/en/pvs-studio/) in build systems on the example of *Makefile*.
This way of using the analyzer has the following advantages:
* Full control over the analyzer settings;
* Incremental analysis of files;
* Parallel analysis of files.Analyzer settings that are the same for all the project files, can be stored in a separate file. *PVS-Studio.cfg* file is used in test projects for this purpose.
### Preprocessor parameters
The analyzer checks not the source files, but [preprocessed](https://www.pvs-studio.com/en/t/0076/) files. This method allows the analyzer perform a more in-depth and qualitative analysis of the source code.
In this regard, we have several restrictions for the compilation parameters being passed. These are parameters that hinder the compiler run in the preprocessor mode, or damage the preprocessor output. A number of debugging and optimization flags, for example,*-O2*, *-O3*, *-g3*, *-ggdb3* and others, create changes which affect the preprocessor output. Information about invalid parameters will be displayed by the analyzer when they are detected.
This fact does not presuppose any changes in the settings of project to be checked, but part of the parameters should be excluded for the analyzer to run in properly.
### Analysis without integration (Linux)
This utility requires the [strace](http://man7.org/linux/man-pages/man1/strace.1.html) utility.
This can be built with the help of the command:
```
pvs-studio-analyzer trace -- make
```You can use any other build command with all the necessary parameters instead of make, for example:
``
pvs-studio-analyzer trace -- make debug
``After you build your project, you should execute the commands:
```
pvs-studio-analyzer analyze -o /path/to/project.log -e /path/to/exclude-path -j
plog-converter -a GA:1,2 -t tasklist -o /path/to/project.tasks /path/to/project.log
```Analyzer warnings will be saved into the specified *project.tasks* file.
If your project isn't CMake or you have problems with the *strace* utility, you may try generating the file *compile_commands.json* with the help of the [Bear](https://github.com/rizsotto/Bear) utility. This file will help the analyzer to check a project successfully only in cases where the environment variables don't influence the file compilation.
#### If you use cross compilers
In this case, the compilers may have special names and the analyzer will not be able to find them. To analyze such a project, you must explicitly list the names of the compilers without the paths:
```
pvs-studio-analyzer analyze ... --compiler COMPILER_NAME --compiler COMPILER_NAME ...
plog-converter ...
```Also, when you use cross compilers, the directory with the header files of the compiler will be changed. It's necessary to exclude such directories from the analysis with the help of ```-e``` flag, so that the analyzer doesn't issue warnings for these files.
```
pvs-studio-analyzer ... -e /path/to/exclude-path ...
```There shouldn't be any issues with the cross compilers during the integration of the analyzer into the build system.
### Analysis without integration (Windows)
[Compiler Monitoring System in PVS-Studio](https://www.pvs-studio.com/en/m/0031/)