Main Content

Generate Launching Script for a Polyspace Platform Project to Run Static Analysis from the Command Line

You 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:

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

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

The command generates these files, which enable you to run a Polyspace Bug Finder analysis on the project from the command line:

  • launchingCommand.bat (Windows®) or launchingCommand.sh (Linux®) — A script that launches a static analysis on your project

  • source_command.txt — List of the project source files

  • options_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

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 execute the launchingCommand script:

launchingCommand

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

Override Options in the Launching Script

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
Here, newResultsFolder is the absolute or relative path to the new results folder.

Use Generated Script to Run Static Analysis with Polyspace Bug Finder Server

To automate a Polyspace Bug Finder analysis with Polyspace Bug Finder Server™:

  1. 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 Share Polyspace Platform Projects, Workspaces, and Configurations.

  2. Generate the launching script, using optional arguments to override configurations or variables as needed. Then modify the script so that it executes the server product instead of the desktop product. For instance, find the path to the desktop product:

    "C:\Program Files\Polyspace\R2025a\polyspace\bin\polyspace-code-prover.exe"
    And replace it with the path to a server product executable, for instance:
    "C:\Program Files\Polyspace Server\R2025a\polyspace\bin\polyspace-code-prover-server.exe"

  3. Move the files to the server where Polyspace Bug Finder Server is running.

  4. Execute the launchingCommand script to run static analysis on the server.

See Also

| |

Topics