Generate Launching Script for Polyspace Platform Project to Run Static Analysis from Command Line
R2026bYou can run a Polyspace® static analysis from the command line by generating a launching script for your project. The system command polyspace-project -generate-launching-script-for generates the script using the configuration settings in your project and any overrides you specify. Before generating the launching script, use the Polyspace Platform user interface to configure your project and perform trial runs. Then generate the launching script to perform static analysis from the command line using the Polyspace desktop or server products. For more information on initial project setup, see Create Project and Add Source Files in Polyspace Platform User Interface.
Prerequisites
You must have a license for either Polyspace Bug Finder™ or Polyspace Code Prover™ to open the Polyspace Platform user interface, configure the analysis options, and perform trial runs.
Generate Launching Script for Polyspace Platform Project
Use the polyspace-project -generate-launching-script-for system command to generate the files needed to run static
analysis on a Polyspace Platform project from the command line. For example, to generate a launching script that runs a Polyspace
Bug Finder analysis on the Bug_Finder_Example_Cpp.psprjx project:
Open the Polyspace Platform user interface. On the start page, in the Examples section, select Find defects in your C code to load the project.
Open a command prompt, navigate to the project location, and enter:
polyspace-project -generate-launching-script-for Bug_Finder_Example_Cpp.psprjx -product bug-finder -output-dir myScripts
The command generates these files in a subfolder named myScripts:
launchingCommand.bat(Windows®) orlaunchingCommand.sh(Linux®) — A script that launches a static analysis on your projectsource_command.txt— List of the project source filesoptions_command.txt— Information from the project configuration settings
If you are working with a shared project or are running the static analysis on a different machine, you may need to override the active build configuration, static analysis configuration, or project variable values. You can override these settings when generating your launching script by using optional arguments with the polyspace-project -generate-launching-script-for system command. To override the build or static analysis configurations, define an alternative
configuration in the Polyspace Platform user interface and reference that configuration name when using the override options.
Run Static Analysis on Polyspace Platform Projects Using Desktop Products
After you generate the launching script and supporting files, you are ready to run the Polyspace
Bug Finder analysis from the command line. To do so, return to your command window and navigate to the output folder myScripts, which contains the generated files. Then, execute the launchingCommand script:
launchingCommandThe launchingCommand script initiates a Polyspace
Bug Finder analysis on the Bug_Finder_Example_Cpp.psprjx project, using the configuration settings captured in the options_command.txt file. You can monitor progress in the command window, and if desired, open the Polyspace Platform user interface to further explore the results.
To automate subsequent analysis, execute the launchingCommand script at periodic intervals or based on predefined triggers.
You can override options in the launchingCommand script as needed. For example, by default, the launchingCommand script saves the static analysis results in a results subfolder of the project folder. You can override this setting and send static analysis results to another folder, either by editing the launchingCommand script directly, or by specifying a different folder at execution
time:
launchingCommand -results-dir newResultsFolder
newResultsFolder is the absolute or relative path to the new results folder.Run Static Analysis on Polyspace Platform Projects on a CI Server
To run static analysis on a CI server with Polyspace Bug Finder Server™ or Polyspace Code Prover Server:
In the Polyspace Platform user interface, create and save appropriate configurations for the server environment. Consider using project variables to define file paths or other resources that may differ between machines running the static analysis. For more information, see Add Resources Using Variables and Create Easily Shareable Projects for Version Control.
Submit the project to your CI server where Polyspace Bug Finder Server or Polyspace Code Prover Server is installed.
On the CI server, generate the launching script and specify a server product using the
-productoption. For example:Or, for Polyspace Code Prover Server:polyspace-project -generate-launching-script-for myProject.psprjx -product bug-finder-server -output-dir myScriptspolyspace-project -generate-launching-script-for myProject.psprjx -product code-prover-server -output-dir myScriptsExecute the
launchingCommandscript to run static analysis on the CI server.
Alternatively, if you do not have a Polyspace Platform project, you can create one directly on the CI server by using
polyspace-configure to trace your build command
and generate the project from your build system.
See Also
polyspace-project -diff, polyspace-project -merge | polyspace-project -convert-psprj-to-workspace | polyspace-project -generate-launching-script-for
Topics
- Using Polyspace Platform as Default User Interface for Static Analysis
- Create Project and Add Source Files in Polyspace Platform User Interface
- Create Easily Shareable Projects for Version Control
- Add Resources Using Variables
- Open Polyspace Results in Polyspace Platform User Interface
- Run Static Analysis in Polyspace Platform User Interface