'Coverity: command line build script for basic c++ code

I am working on a requirement to do instrumented build for c++ code on coverity(static code analysis tool, version 7.5.1) build server via command line. Need to execute a basic c++ code via command line, I tried using the cov-build command cov-build –-dir cov-int cl /c test.cpp and various other permutations on the directory where coverity is actually installed in the build machine. But there is some problem. System can understand only the cov-buld --dir and if i use only this command along with /c, this file opens in visual studio rather than giving the% of compilation units. Please help me if anyone have done this before.



Solution 1:[1]

First be clear with your requirements. Which system you are working on?(windows or Mac or Unix or Solaris). Before starting cov-build, configure the compiler which will execute the source file. As you said you are working on C++ source code, use GCC compiler to configure with Coverity Static Analyzer. Coverity Directly supports for 3 Compilers(Gcc and 2 more). To configure this GCC use cov-configure command followed by gcc.

Then use cov-build command to analyze.

Sample command is:

path_to_cov_bin/cov-build --dir path_to_output_folder gcc hi.cpp

It will create emit folder with emit-db in path_to_output_folder. Then cov-analyze command will be analyze that emit folder and create Output Directory in given path.

To compile N number of source files use makefile. If you have any query about makefile You can put a post here or refer in this site.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sivanantham M