Integrate Polyspace Server Products with MATLAB
You can install Polyspace® Bug Finder™ Server™ and Polyspace Code Prover™ Server as standalone products and analyze C/C++ code.
When installing Polyspace server products and MATLAB®, you cannot install MATLAB and Polyspace server products together in a single run of the installer. First install MATLAB by running the MATLAB installer. Then install the Polyspace server product in a different root folder by running the installer separately. For instance, in Windows®:
Your default MATLAB root folder is
C:\Program Files\MATLAB\R2024b
.Your default Polyspace root folder is
C:\Program Files\Polyspace Server\R2024b
for the Polyspace server products.
To automate the Polyspace analysis by using MATLAB scripts, integrate the Polyspace server products and MATLAB by running a post-installation step.
Integrate Polyspace Server Products with MATLAB
You can integrate your Polyspace server product with MATLAB only if both installations are from the same release. After the integration, you can use all MATLAB functions and classes available for running Polyspace.
To link your MATLAB and Polyspace installations:
Open MATLAB with administrator privileges.
At the MATLAB command prompt, enter:
By default, Polyspace is installed in the folderpolyspacesetup('install');
C:\Program Files\Polyspace\R2024b
. If you install Polyspace in the default folder, the command integrates Polyspace with MATLAB. If a Polyspace installation is not detected at the default location, provide the path to the Polyspace installation folder when prompted. The process might take a few minutes to complete.To avoid the prompt during installation, enter:
polyspacesetup('install', 'polyspaceFolder', Folder, 'silent', true);
Restart MATLAB. You can now use all functions and classes available for running Polyspace server products.
A MATLAB installation can be integrated with only one Polyspace installation. To integrate to a new Polyspace installation, any previous integration must be removed. To remove the integration between a Polyspace and MATLAB installation, open MATLAB with administrator privilege and at the MATLAB command prompt, enter:
polyspacesetup('uninstall')
Check Integration Between MATLAB and Polyspace
To check if a MATLAB installation is already integrated with a Polyspace installation, open MATLAB and at the command prompt, enter:
ver
The MATLAB-Polyspace integration adds some Polyspace installation subfolders to the MATLAB search path. To see which paths were added, enter:
polyspacesetup('showpolyspacefolders')
Run Polyspace Server Products with MATLAB Scripts
In a continuous integration process, you can execute MATLAB scripts that run a Polyspace analysis on new code submissions and compares the results against predefined criteria. Use these functions/classes:
Create a
polyspace.Project
object to configure Polyspace analysis options, run an analysis and read results to MATLAB tables. You can use other MATLAB functions for comparing results against predefined criteria.To only read existing results without running an analysis, use the
polyspace.CodeProverResults
class with the path to a results folder.If you want a more granular selection of checkers for:
Coding rules, create a
polyspace.CodingRulesOptions
object.Bug Finder defects, create a
polyspace.DefectsOptions
object.
To create a custom target for the analysis and explicitly specify sizes of data types, create a
polyspace.GenericTargetOptions
object.
You can also use the polyspaceCodeProverServer
function to run
the analysis and then read results with the polyspace.CodeProverResults
class. If you use
build commands to build your source code, you can create a Polyspace configuration from the build command using the polyspaceConfigure
function.