Main Content

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.

Configuration node in project tree

The configuration opens on a separate Configuration pane. The Configuration pane contains these tabs:

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).

Searching for the option 'Compilation toolchain' shows two instances on the Build tab of the Configuration pane.

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:

  1. Open your project configuration.

  2. On the Polyspace Platform toolstrip, click New.

    Menu showing options to create a new build configuration set, to create a new static analysis configuration set, and to create a new testing and profiling configuration set

    Select the type of configuration variant you want to create. For example, select New Build Configuration to create a build configuration variant.

  3. Set options as needed. For example, set Compilation toolchain (testing) as MinGW64| CMake/Ninja (64-bit Windows) and select Enable portable word sizes.

  4. Click edit button 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:

Drop-down list showing the user-defined build configuration sets

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:

  1. Open your project configuration.

  2. 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

  3. On the Polyspace platform toolstrip, click Export.

    Menu showing options to export the current configuration to a file, to export active configurations to files, and to export all configurations to files

    Select Export Active Configurations.

  4. 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.

Related Topics