Options Files for Polyspace Analysis
To adapt the Polyspace analysis configuration to your development environment and
requirements, you have to modify the default configuration through command-line
options such as -compiler
. Options files are a convenient way to
collect multiple options together and reuse them across projects.
What are Options Files
Options files are text files with one option per line. For instance, the content of an options file can look like this:
# Options for Polyspace analysis # Options apply to all projects in Controller module -compiler visual16.x -D _WIN32 -code-behavior-specifications "Z:\utils\polyspace\forbiddenfunctions.xml"
#
represent
comments for better readability. These lines are ignored during
analysis.Specifying Options Files
Depending on the platform where you run analysis, you can specify an options file in one of the following ways.
Command Line
At the command line (and in scripts), specify an options file as argument to the option
-options-file
.
For instance, instead of the command:
polyspace-bug-finder -sources file.c -compiler visual16.x -D _WIN32 -code-behavior-specifications "Z:\utils\polyspace\forbiddenfunctions.xml"
-compiler visual16.x -D _WIN32 -code-behavior-specifications "Z:\utils\polyspace\forbiddenfunctions.xml"
options.txt
in the path
Z:\utils\polyspace\
and shorten the
command
to:polyspace-bug-finder -sources file.c -options-file "Z:\utils\polyspace\options.txt"
You can use options files with these Polyspace commands:
polyspace-bug-finder
polyspace-bug-finder-server
polyspace-bug-finder-access
polyspace-code-prover
polyspace-code-prover-server
IDEs
If you run Polyspace as You Code using IDE extensions, you typically specify three groups of options differently:
Options Group | Extension Settings |
---|---|
Build options: You can extract build options from existing artifacts such as build commands and JSON compilation database. You can also collect all build options in an options file and specify the option file path in the appropriate extension setting. |
|
Checkers: You can select checkers using a checkers selection wizard. | |
Other remaining options: All remaining options can be collected in a second options file that goes into the appropriate extension setting. |
|
If you use options files both for build options and other options, the result is the same as specifying a single options file with the other options appended to the build options. See also Specifying Multiple Options Files.
For more information on IDE extensions, see:
Configure Polyspace as You Code Extension in Visual Studio (Polyspace Access)
Configure Polyspace as You Code Extension in Visual Studio Code (Polyspace Access)
Configure Polyspace as You Code Plugin in Eclipse (Polyspace Access)
Polyspace User Interface
In the user interface of the Polyspace desktop products, you typically do not require an options file. Most options can be specified on the Configuration pane in the Polyspace user interface.
However, some options are available only at the command line and do not have a counterpart in
the user interface. If you have to specify multiple
command-line-only options, you can collect them in an options file,
for instance commandLineStyleOptions.txt
. On the
Configuration pane, under the
Advanced Settings node, specify the
absolute path of the options file in the Other
field:
-options-file C:\psconfig\commandLineStyleOptions.txt
Specifying Multiple Options Files
You can specify multiple options files in an analysis. For instance, at the command line, you can enter:
polyspace-bug-finder -sources file.c -options-file opts1.txt -options-file opts2.txt
When you specify multiple options files in an analysis, all options from the options files are
appended to the analysis command. For instance, the preceding command has
the same effect as using a single options file that places the content of
opts1.txt
above
opts2.txt
.
If an option appears in multiple files with conflicting arguments, the
argument in the last options file prevails. For instance, in the preceding
command, if opts1.txt
contains:
-checkers all -misra3 all
opts2.txt
contains:-misra3 single-unit-rules
single-unit-rules
for the
option -misra3
. You can use this stacking of options files to override options. For instance, suppose you use a read-only options file that applies to your entire team but want to override some of the options in the file. You can override the options by using a second options file that you create and specifying your options file after the team-wide options file.
You can also specify the option -options-file
within an
options file and aggregate several options files in this way.