Configure Project for Static Analysis in Polyspace Platform User Interface
The Polyspace Platform user interface allows you to author functional tests for C/C++ code, or check C/C++ code for bugs or run-time errors using static code analysis. Before you begin test authoring or code analysis, you have to specify additional information. For example:
To build and run a test, specify a target, a compiler, and related information such as compiler flags, include paths and defines.
To check C/C++ code for bugs, you first have to specify the defects and coding standards Polyspace checks for.
The information required for building and executing tests or running a static analysis comes from your project configuration. A Polyspace Platform project configuration consists of these sets of options:
Project-specific configuration — Project-wide options
Build configuration — Options that specify how to build your code and tests
Testing and profiling configuration — Options that specify how to test and profile your code
Static analysis configuration — Options specific to static analyses
You can specify distinct sets of build, testing, and static analysis configurations. These sets are configuration variants. A Polyspace® Platform project supports multiple variants of build configurations, testing configurations, and static analysis configurations. You can switch between the variants in a single project and share them between projects. You cannot create variants for the project-specific options. The project options apply to all configuration variants.
Set Up Configuration
To open your configuration, on the Projects pane, double-click the Configuration node of your project.
The configuration opens on a separate Configuration pane. The Configuration pane contains these tabs:
Project — The options on this tab includes various options that apply to the entire project. These options are relevant to both static analysis and dynamic testing. You cannot create variants for these options.
For more information on the options, see Bug Finder Analysis in Polyspace Platform User Interface.
Build — The options on this tab cover both static analysis and dynamic testing.
Only a subset of the options on the Target & Compiler node apply to Polyspace Test™. The remaining options on this and other nodes apply only to the static analysis tools, Polyspace Bug Finder™ and Polyspace Code Prover™.
For more information on the options, see Polyspace Bug Finder Options in Polyspace Platform User Interface.
Testing & Profiling — The options on this tab apply only to Polyspace Test. Using these options, you can specify certain aspects of testing and profiling such as code coverage metrics and folders to exclude from profiling.
For more information on the options, see Code Profiling in Polyspace Platform User Interface (Polyspace Test).
Static Analysis — The options on this tab do not apply to Polyspace Test. For more information on these options, see:
You can also find individual options on the Configuration pane through search if you know the option name. For instance, if you search for the term Compilation toolchain
, you can find two matches on the Build tab corresponding to these two options:
Compilation toolchain (Static analysis)
Compilation toolchain (Testing)
Note that you can search for options on the Static Analysis Tab by their command-line name in addition to the name that appears in the user interface. For instance, you can search for the option Constraint setup by its command-line equivalent -data-range-specifications
. For more information on this option, see Constraint setup (-data-range-specifications)
(Polyspace Code Prover).
Once you locate an option, you can use contextual help to find more information about an option. Hover on the option to see a tooltip describing the option or click More Help in the tooltip to open the documentation for the option.
Create Configuration Variants
You can create multiple configuration variants for build, testing, or static analysis options for specific goals and switch between them within the same project. For example, you can create different configuration variants to use different compilers, or to check for different code coverage metrics.
To create new configuration variants in your project:
Open your project configuration.
On the Polyspace Platform toolstrip, click New.
Select the type of configuration variant you want to create. For example, select New Build Configuration to create a build configuration variant.
Set options as needed. For example, set Compilation toolchain (testing) as
MinGW64| CMake/Ninja (64-bit Windows)
and select Enable portable word sizes.Click to rename the configuration variant.
Once you have more than one variants in your project, you can select a variant using the drop-down lists in the configuration tabs:
To use the selected variant as part of the active configuration, select Make Active on the toolstrip. To remove a configuration variant, select the variant and then select Delete on the toolstrip.
Share and Reuse Configuration Variants
To reuse configurations across projects, export the configuration of your project as Polyspace configuration (.pscfg
) files and then import the .pscfg
files in other projects. Importing project configuration allows you to use identical or similar configuration in multiple projects. Exporting a configuration for a project as a .pscfg
file allow you to compare configuration of different versions of a project as text files.
In a continuous integration workflow, submit the .pscfg
files to a version control system as you would with other text files. Before submission, compare and merge your version of a configuration with the version in the repository using the diff/merge tool. For more details on the diff/merge tool, see Compare and Merge Polyspace Platform Projects and Configurations Before Submission to Source Control (Polyspace Test).
To export an active configuration variant from your project:
Open your project configuration.
Navigate to the tab from which you want to export the configurations:
Build — Export the build configuration variant
Static Analysis — Export the static analysis configuration variant
Testing & Profiling — Export the testing and profiling configuration variant
On the Polyspace platform toolstrip, click Export.
Select Export Active Configurations.
Save the current build configuration in a
.pscfg
file.
If your project contains more than one variants of build, testing, or static analysis configuration, you can export all variants of a particular type by clicking Export All Configurations.
To import one or more configuration variants into your project, click Import and navigate to the Polyspace configuration files (.pscfg
) you want to import. To use one of the imported configuration variants, select the imported configuration variant from the drop-down list and select Make Active in the toolstrip.