How to Analyze a C/C++ project with Scanyp?

Introduction

There are a lot of managed C/C++ build systems like Makefile, CMake, SCon and Visual Studio. To perform the analysis Scanyp needs all the data concerning the compilation and link commands. Out of the box Scanyp supports the Visual studio solutions and for the other cases the recommended way is to provide a json CMake compilation database.

From the terminal you can execute the analysis:

>scanyp.exe  --input C:\work\MyProject.sln --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

The --identifier switch is mandatory to define the project key, the Scanyp agent will get from the Scanyp server the configuration of this specific key if it's found, else a default configuration will be created in the server and it will be used by the scanyp agent for the analysis.

Supported entries

C Projects

The build specifications of C project could be any kind of project enumerated below. However you have to specify the --kind switch

>ScanypAnalyzer.exe  C:\work\MySolution.sln --identifier MyProject --kind c
>./analyze.sh  /home/myuser/compile_commands.json --identifier MyProject

Visual Studio Projects

Scanyp supports Visual Studio projects 2010 up to 2022. The extensions supported are .sln,.vcproj and .vcxproj

>scanyp.exe --input C:\work\MySolution.sln --identifier MyProject

CMAKE JSON Compilation Database

A compilation database is a database for compile options. It records which compile options are used to build the files in a project. The compilation database could be generated from CMake or Ninja, and there are many other ways to generate a compilation database as descibed here.

>scanyp.exe  --input C:\work\compile_commands.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

XCode Projects

With the xcpretty utility, you can generate 'compile_commands.json'. To do this, run the following command: xcodebuild [flags] | xcpretty -r json-compilation-database

>./scanyp --input /home/user/myproject/compile_commands.json --identifier MyProject

Qt Projects

The recommended way to analyze a Qt project is to generate the compilation database from the QtCreator IDE.

>scanyp.exe --input C:\work\compile_commands.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

CLion Projects

The recommended way to analyze a CLion project is to generate the compilation database as described here

>scanyp.exe --input C:\work\compile_commands.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

Eclipse Projects

The recommended way to analyze an Eclipse project, is to generate a compilation database using bear for linux or BuildMonitor for windows. .

>scanyp.exe --input C:\work\MySolution.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

Scon

The recommended way to analyze a SCON project is to generate the compilation database as described here .

>scanyp.exe --input C:\work\MySolution.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

Ninja

The recommended way to analyze a Ninja project is to generate the compilation database as described here .

>scanyp.exe --input C:\work\MySolution.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

Makefile

The recommended way to analyze a Makefile, is to generate a compilation database using bear for Linux or BuildMonitor for windows.

>scanyp.exe --input C:\work\MySolution.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject

Other Projects

The recommended way to analyze any C/C++ project, is to generate a compilation database like described here, and if in your case it's not possible you can use bear for Linux to generate the compilation database.

>scanyp.exe  --input C:\work\MySolution.json --identifier MyProject
>./scanyp --input /home/myuser/compile_commands.json --identifier MyProject