polyspace-configure

(DOS/UNIX) Create Polyspace project from your build system at the DOS or UNIX command line

Description

example

polyspace-configure buildCommand traces your build system and creates a Polyspace® project with information gathered from your build system.

example

polyspace-configure [OPTIONS] buildCommand traces your build system and uses -option value to modify the default operation of polyspace-configure. Specify the modifiers before buildCommand, otherwise they are considered as options in the build command itself.

example

polyspace-configure [OPTIONS] -compilation-database jsonFile creates a Polyspace project with information gathered from the JSON compilation database file jsonFile that you provide. You do not need to specify a build command or trace your build system. For more on JSON compilation databases, see JSON Compilation Database.

Examples

collapse all

This example shows how to create a Polyspace project if you use the command make targetName buildOptions to build your source code.

Create a Polyspace project specifying a unique project name. Use the -B or -W makefileName option with make so that the all prerequisite targets in the makefile are remade.

polyspace-configure  -prog myProject \
make -B targetName buildOptions

Open the Polyspace project in the Polyspace user interface.

This example shows how to create a Polyspace options file from a JSON compilation database that you generate with the CMake build system generator. CMake generates build instructions for the build tool you specify, such as a Unix Makefiles for make or project files for Microsoft® Visual Studio®. CMake supports the generation of a JSON compilation database only for Makefile generators and Ninja generator. For more information, see makefile generators.

Generate a JSON compilation database for your CMake project. For an example of a Cmake project, see polyspaceroot\help\toolbox\polyspace_bug_finder_server\examples\compilation_database where polyspaceroot is your Polyspace installation folder.

Navigate to the root of your project source tree. This folder contains the file CMakeLists.txt which CMake uses as an input to generate build instructions. Enter these commands:

mkdir JSON_cdb
cd JSON_cdb
cmake -G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ../
The last command generates a Unix makefile with build instructions for the make build tool. The command also outputs file compile_commands.json. This file lists the compiler calls for every translation unit in your project.

Generate a Polyspace options file from the compilation database that you generated in the previous step.

polyspace-configure -compilation-database compile_commands.json \
-output-options-file options.txt
You do not need to specify a build command and polyspace-configure does not trace your build. Polyspace extracts information about your build system from the JSON compilation database.

Pass the options file to Polyspace to run an analysis, for instance:

polyspace-bug-finder-access -options-file options.txt

This example shows how to create different Polyspace projects from the same trace of your build system. You can specify which source files to include for each project.

Trace your build system without creating a Polyspace project by specifying the option -no-project. To ensure that all the prerequisite targets in your makefile are remade, use the appropriate make build command option, for instance -B.

polyspace-configure -no-project make -B

polyspace-configure stores the cache information and the build trace in default locations inside the current folder. To store the cache information and build trace in a different location, specify the options -cache-path and -build-trace.

Generate Polyspace projects by using the build trace information from the previous step. Specify a project name and use the -include-sources or -exclude-sources option to select which files to include for each project.

polyspace-configure -no-build -prog myProject \
-include-sources "glob_pattern"

glob_pattern is a glob pattern that corresponds to folders or files you filter in or out of your project. To ensure the shell does not expand the glob patterns you pass to polyspace-configure, enclose them in double quotes. For more information on the supported syntax for glob patterns, see polyspace-configure Source Files Selection Syntax (Polyspace Bug Finder).

If you specified the options -build-trace and -cache-path in the previous step, specify them again.

Delete the trace file and cache folder.

rm -r polyspace_configure_cache polyspace_configure_built_trace
 
If you used the options -build-trace and -cache-path, use the paths and file names from those options.

This example shows how to run Polyspace analysis if you use the command make targetName buildOptions to build your source code. In this example, you use polyspace-configure to trace your build system but do not create a Polyspace project. Instead you create an options file that you can use to run Polyspace analysis from command-line.

Create a Polyspace options file specifying the -output-options-file command. Use the -B or -W makefileName option with make so that all prerequisite targets in the makefile are remade.

polyspace-configure -output-options-file\
 myOptions make -B targetName buildOptions

Use the options file that you created to run a Polyspace analysis at the command line:

polyspace-bug-finder-access -options-file myOptions

Input Arguments

collapse all

Build command specified exactly as you use to build your source code.

Example: make -B, make -W makefileName

Basic Options

OptionArgumentDescription
-progProject name

Project name that appears in the Polyspace user interface. The default is polyspace.

If you do not use the option -output-project, the -prog argument also sets the project name.

Example: -prog myProject creates a project that has the name myProject in the user interface. If you do not use the option -output-project, the project name is also myProject.psrprj.

-authorAuthor name

Name of project author.

Example: -author jsmith

-output-projectPath

Project file name and location for saving project. The default is the file polyspace.psprj in the current folder.

Example: -output-project ../myProjects/project1 creates a project project1.psprj in the folder with the relative path ../myProjects/.

-output-options-fileFile name

Option to create a Polyspace analysis options file. Use this file for command-line analysis using one of these commands:

  • polyspace-bug-finder

  • polyspace-code-prover

  • polyspace-bug-finder-server

  • polyspace-code-prover-server

  • polyspace-bug-finder-access

-allow-build-errorNone

Option to create a Polyspace project even if an error occurs in the build process.

If an error occurs, the build trace log shows the following message:

polyspace-configure (polyspaceConfigure) 
   ERROR: build command 
   command_name fail [status=status_value]
command_name is the build command name that you use and status_value is the non-zero exit status or error level that indicates which error occurred in your build process.

This option is ignored when you use -compilation-database.

-allow-overwriteNone

Option to overwrite a project with the same name, if it exists.

By default, polyspace-configure (polyspaceConfigure) throws an error if a project with the same name already exists in the output folder. Use this option to overwrite the project.

-no-console-output

-silent (default)

-verbose

None

Option to suppress or display additional messages from running polyspace-configure (polyspaceConfigure).

  • -no-console-output – Suppress all outputs including errors and warnings.

  • -silent (default) – Show only errors and warnings.

  • -verbose – Show all messages.

If you specify more than one of these options, the most verbose option is applied.

These options are ignored if they are used in combination with -easy-debug.

-helpNone

Option to display the full list of polyspace-configure (polyspaceConfigure) commands

-debugNone

Option to store debug information for use by MathWorks® technical support.

This option has been superseded by the option -easy-debug.

-easy-debugPath

Option to store debug information for use by MathWorks technical support.

After a polyspace-configure (polyspaceConfigure) run, the path provided contains a zipped file ending with pscfg-output.zip. If the run fails to create a complete Polyspace project or options file, send this zipped file to MathWorks Technical Support for further debugging. The zipped file does not contain source files traced in the build. See also Errors in Project Creation from Build Systems (Polyspace Bug Finder).

Options to Create Multiple Modules

These options are not compatible with -compilation-database.

OptionArgumentDescription
-moduleNone

Option to create a separate options file for each binary created in build system.

You can only create separate options files for different binaries. You cannot create multiple modules in a Polyspace project (for running in the Polyspace user interface).

Use this option only for build systems that use GNU® and Visual C++® compilers.

See also Modularize Polyspace Analysis by Using Build Command (Polyspace Bug Finder).

-output-options-pathPath name

Location where generated options files are saved. Use this option together with the option -module.

The options files are named after the binaries created in the build system.

Advanced Options

OptionArgumentDescription
-compilation-databasePath and file name

Location and name of JSON compilation database (JSON CDB) file. You generate this file from your build system, for instance by using the flag -DCMAKE_EXPORT_COMPILE_COMMANDS=1 with cmake. The file contains compiler calls for all the translation units in you projects. For more information, see JSON Compilation Database. polyspace-configure uses the content of this file to get information about your build system. The extracted compiler paths in the JSON CDB must be accessible from the path where you run polyspace-configure.

You do not specify a build command when you use this option.

The build systems and compilers support the generation of a JSON CDB:

  • CMake

  • Bazel

  • Clang

  • Ninja

  • Qbs

  • waf

This option is not compatible with -no-project and with the options to create multiple modules.

The cache control options, -allow-build-error, and -no-build are ignored when you use this option.

-compiler-configPath and file name

Location and name of compiler configuration file.

The file must be in a specific format. For guidance, see the existing configuration files in polyspaceroot\polyspace\configure\compiler_configuration\. For information on the contents of the file, see Compiler Not Supported for Project Creation from Build Systems (Polyspace Bug Finder).

Example: -compiler-configuration myCompiler.xml

-no-projectNone

Option to trace your build system without creating a Polyspace project and save the build trace information.

Use this option to save your build trace information for a later run of polyspace-configure (polyspaceConfigure) with the -no-build option.

This option is not compatible with -compilation-database.

-no-buildNone

Option to create a Polyspace project using previously saved build trace information.

To use this option, you must have the build trace information saved from an earlier run of polyspace-configure (polyspaceConfigure) with the -no-project option.

If you use this option, you do not need to specify the buildCommand argument.

This option is ignored when you use -compilation-database.

-no-sourcesNone

Option to create a Polyspace options file that does not contain the source file specifications.

Use this option when you intend to specify the source files by other means. For instance, you can use this option when:

  • Running Polyspace on AUTOSAR-specific code.

    You want to create an options file that traces your build command for the compiler options:

    -output-options-file options.txt -no-sources
    You later append this options file when extracting source file names from ARXML specifications and running the subsequent Code Prover analysis with polyspace-autosar (Polyspace Code Prover)
    -extra-options-file options.txt

    See also Run Polyspace on AUTOSAR Code Using Build Command (Polyspace Code Prover).

  • Running Polyspace in Eclipse™.

    Your source files are already specified in your Eclipse project. When running a Polyspace analysis, you want to specify an options file that has the compilation options only.

-extra-project-optionsOptions to use for subsequent Polyspace analysis. For instance, "-stubbed-pointers-are-unsafe".

Options that are used for subsequent Polyspace analysis.

Once a Polyspace project is created, you can change some of the default options in the project. Alternatively, you can pass these options when tracing your build command. The flag -extra-project-options allows you to pass additional options.

Specify multiple options in a space separated list, for instance "-allow-negative-operand-in-shift -stubbed-pointers-are-unsafe".

Suppose you have to set the option -stubbed-pointers-are-unsafe for every Polyspace project created. Instead of opening each project and setting the option, you can use this flag when creating the Polyspace project:

-extra-project-options "-stubbed-pointers-are-unsafe"

For the list of options available, see:

If you are creating an options file instead of a Polyspace project from your build command, do not use this flag.

-tmp-pathPathLocation of folder where temporary files are stored.
-build-tracePath and file name

Location and name of file where build information is stored. The default is ./polyspace_configure_build_trace.log.

Example: -build-trace ../build_info/trace.log

-include-sources

-exclude-sources

Glob pattern

Option to specify which source files polyspace-configure (polyspaceConfigure) includes in, or excludes from, the generated project. You can combine both options together.

A source file is included if the file path matches the glob pattern (Polyspace Bug Finder) that you pass to -include-sources.

A source file is excluded if the file path matches the glob pattern (Polyspace Bug Finder) that you pass to -exclude-sources.

-print-included-sources

-print-excluded-sources

None

Option to print the list of source files that polyspace-configure (polyspaceConfigure) includes in, or excludes from, the generated project. You can combine both options together. The output displays the full path of each file on a separate line.

Use this option to troubleshoot the glob patterns that you pass to -include-sources or -exclude-sources. You can see which files match the pattern that you pass to -include-sources or -exclude-sources.

-compiler-cache-pathFolder path

Specify a folder path where polyspace-configure looks for or stores the compiler cache files. If the folder does not exist, polyspace-configure creates it.

By default, Polyspace looks for and stores compiler caches under these folder paths:

  • Windows®

    %appdata%\Mathworks\R20xxY\Polyspace

  • Linux®

    ~/.matlab/R20xxY/Polyspace

  • Mac

    ~/Library/Application Support/MathWorks/MATLAB/R20xxY/Polyspace

R20xxY is the release version of your Polyspace product, for instance R2020b.

-no-compiler-cacheNone

Use this option if you do not want Polyspace to cache your compiler configuration information or to use an existing cache for your compiler configuration.

By default, the first time you run polyspace-configure with a particular compiler configuration, Polyspace queries your compiler for the size of fundamental types, compiler macro definitions, and other compiler configuration information then caches this information. Polyspace reuses the cached information in subsequent runs of polyspace-configure for builds that use the same compiler configuration.

-reset-compiler-cache-entryNoneUse this option to query the compiler for the current configuration and to refresh the entry in the cache file that corresponds to this configuration. Other compiler configuration entries in the cache are not updated.
-clear-compiler-cacheNone

Use this option to delete all compiler configurations stored in the cache file.

If you also specify a build command or -compilation-database, polyspace-configure computes and caches the compiler configuration information of the current run, except if you specify -no-project or -no-compiler-cache.

-import-macro-definitions

none

from-whitelist

from-source-tokens

Use this option to specify how polyspace-configure queries the compiler for macro definitions.

You can specify:

  • none — Polyspace does not query the compiler for macro definitions. You must provide the macro definitions manually.

  • from-whitelist — Polyspace uses an internal white list to query the compiler for macro definitions.

    Polyspace uses the white list by default when you use the option -compilation-database.

  • from-source-tokens (default, except if you use -compilation-database ) — Polyspace uses every non-keyword token in your source code to query your compiler for macro definitions.

-options-for-sources-delimiterA single character

Specify an option separator to use when multiple analysis options are associated with one source file using the -options-for-sources option. Typically, the -options-for-sources option uses a semicolon as separator.

See also -options-for-sources.

Cache Control Options

These options are primarily useful for debugging. Use the options if polyspace-configure (polyspaceConfigure) fails and MathWorks Technical Support asks you to use the option and provide the cached files. Starting R2020a, the option -easy-debug provides an easier way to provide debug information. See Contact Technical Support About Issues with Running Polyspace (Polyspace Bug Finder).

These options are ignored when you use -compilation-database.

OptionArgumentDescription

-no-cache

-cache-sources (default)

-cache-all-text

-cache-all-files

None

Option to perform one of the following:

  • -no-cache: Not create a cache

  • -cache-sources: Cache text files temporarily created during build for later use by polyspace-configure (polyspaceConfigure).

  • -cache-all-text: Cache all text files including sources and headers.

  • -cache-all-files: Cache all files including binaries.

Typically, you cache temporary files created by your build command to debug issues in tracing the command.

-cache-pathPath

Location of folder where cache information is stored.

When tracing a Visual Studio build (devenv.exe), if you see the error:

path is too long
try using a shorter path for this option to work around the error.

Example: -cache-path ../cache

-keep-cache

-no-keep-cache (default)

None

Option to preserve or clean up cache information after polyspace-configure (polyspaceConfigure) completes execution.

If polyspace-configure (polyspaceConfigure) fails, you can provide this cache information to technical support for debugging purposes.

Introduced in R2013b