Depending on the source code you have and the way it is provided to you, you should choose a discovery method that best fits your needs. Your choices are as follows, ordered by package completeness (use the first method that matches your situation):
1 Use the standalone CPP Compilation Database Discoverer | Use the standalone CPP Compilation Database Discoverer. This discoverer requires the output of a special tool that is run while compiling the source code and will log all compile operations (i.e. the build log). The build log is then used to determine the projects (and therefore Analysis Units) that are present in your source code. | |
---|---|---|
2 Use the Microsoft Visual C++ project discoverer | Use the Microsoft Visual C++ project discoverer. This discoverer is embedded into AIP Core | |
3 Use CMake to generate Visual Studio files or a compilation database | Use CMake to generate Visual Studio files or a compilation database, and fall back to one of the previous methods | 4|
Create your own custom | discoverer5discoverer (based on make files) | - |
Manually configure the analysis | - |
Anchor | ||
---|---|---|
|
...
|
If your source code is designed to compile on Linux, you can use a compilation logging tool called Scan Build (freely available from CAST - instructions included) while compiling the source code to output two files compile_commands.json and compile_config.json that will contain all the information necessary to compile your source code. These two Scan Build files can be delivered as input with your source code in the CAST Delivery Manager Tool: as long as you have also installed the CPP Compilation Database Discoverer, then the Scan Build output files will be taken into account when you package the source code and projects will be created based on what is found in the Scan Build files (compile_commands.json and compile_config.json).
...
- When the CPP Compilation Database Discoverer is installed, the following check box will be available in the CAST Delivery Manager Tool - ensure this is ticked so that discovery functions correctly. If the checkbox is not visible, then the extension has either not been installed or has not been installed correctly:
Anchor | ||
---|---|---|
|
...
|
...
discoverers
These discoverers are embedded into the CAST Delivery Manager Tool - currently the following versions are supported:
- *.vcproj files
- Visual C++ 2003
- Visual C++ 2005
- Visual C++ 2008
- *.vcxproj files
- Visual C++ 2010
- Visual C++ 2012
- Visual C++ for versions > 2012 The Analysis Unit generated for this project is mapped to a Visual C++ 2012 environment profile
Note |
---|
Visual C++ 2013, 2015, 2017 and 2019 projects, will be discovered as a Visual C++ 2012 project (i.e. the Analysis Unit generated for this project is mapped to a Visual C++ 2012 environment profile). You can therefore:
|
The following is currently supported:
- Configures a project for each Microsoft Visual Studio 2003 - 2008 project (*.vcproj file) and each Visual Studio 2010/2012 project (*.vcxproj file) identified.
- Handles Inherited Property Sheets and standard Visual Studio macros:
- $(SolutionDir)
- $(ProjectName)
- $(InputName)
- $(ProjectDir)
- $(InputDir)
- Only the Release configuration is identified. If there is no Release, then the first configuration is identified instead.
...
In the CAST Delivery Manager Tool, this discoverer is embedded by default and is materialized with the following two checkboxes - ensure they are ticked so that discovery functions correctly:
Anchor | ||||
---|---|---|---|---|
|
...
CMake project files (CMakeLists.txt) are not directly understood by the C and Cpp Analyzer extension, however:
...
Another option with CMake is to generate compilation databases and use them in conjunction with the CPP Compilation Database Discoverer. These databases are very similar to what is generated by the Scan Build tool (see previous section CPP Compilation Database Discoverer), but they may not contain all the necessary details. We can’t guarantee perfect results if you use this method, but it should still provide adequate results.
Anchor | ||||
---|---|---|---|---|
|
If you use a simple project format, you may want to create your own "discoverer" that understands these projects. A cost-effective version of this option would consist of writing a tool that generates .vcxproj files matching your projects, or a JSON file similar to what the build log discoverer generates.
Anchor | ||||
---|---|---|---|---|
|
If none of the previous methods are suitable, you can manually create the Analysis Unit in the CAST Management Studio. This option requires a good understanding of C++ to configure include paths and macros. Please ensure you read and understand background information about C++ compilation before you decide to use this method.
...
- Get all required files in the delivery and run the packaging and delivery actions in the CAST Delivery Manager Tool
- Create the correct Analysis Units that you require (usually one per folder, or one per project file). The use of the C and Cpp File Discoverer may be of help for this step.
- Add include paths (possibly helped by reading project files, or a real compilation log)
- Add macros (possibly helped by reading project files, or a real compilation log)
- Run the analysis (in test mode), examine the log
- Repeat the process until the log is clean.
How to read a compilation log
If you run a real compilation (or get a real compilation log), you may be able to see the options you should define in your Analysis Units. Macros are usually defined with -D and include paths with -I. If the compilation logdoes not show that, you may try to increase its verbosity or use the -N option of make to get a debug run of the compilation.
Where should I start? Macros or include paths?
There is no easy answer. Usually, header files contain the definition of many, many macros. It is therefore better to start and correct the include paths first. However, in some cases, the choice of header files that will be included itself depends on a macro. So you should define this macro correctly before trying to solve problems with this header.
...