When launching Polyspace in command line, it is possible to specify an options file (a text file containing the list of options), by using the parameter '-options-file'.
This option can still be used graphically by specifying this option in the "Other" field (in Advanced Settings).
The idea here is then to call polyspace-configure in order to generate an options file (that will then contain the compilation related options only), and then to use this options file in the Polyspace project generated by the Polyspace Eclipse plugin.
When the verification will be started, the options coming from the options file and the ones defined in the project will be merged.
To implement this solution in Eclipse, you can create a script that will be used to launch polyspace-configure on the build command.
This script can be called via a "Build target".
Then use the generated options file with the extra option -options-file in the Polyspace project (Polyspace>configure project).
The script itself will call polyspace-configure with the build command as parameter.
Since a conflict will occur due to the source files specification in both the project file and the options file, the list of source files needs to be removed from the generated options file.
You may see additional warnings at the beginning of the verification for similar reasons, but these can safely be ignored.
Since R2018b, there is an option that prevents the generation of the list of source files : -no-sources.
Before this version, it has to be done in the script.
Here is an example where the build command is a call to the command ninja.exe, used to compile a project using the Ninja open-source build system:
set BUILD_COMMAND="C:\PROGRA~1\NINJA-~1\ninja.exe"
set CLEAN_COMMAND="C:\PROGRA~1\NINJA-~1\ninja.exe -t clean"
set MATLAB_ROOT="C:\Program Files\MATLAB\R2017a"
set DUMMY_FILE=dummy.txt
set OPTION_FILE=option_file.txt
cmd /C %CLEAN_COMMAND%
%MATLAB_ROOT%\polyspace\bin\polyspace-configure.exe -output-options-file %DUMMY_FILE% -allow-overwrite %BUILD_COMMAND%
findstr /v /r /c:"^-sources " %DUMMY_FILE% > %OPTION_FILE%
First, the ninja clean command is called to ensure that a full build will be done.
Then polyspace-configure is called with the build command in parameter.
Lastly, the options file is modified to remove the lines starting with -sources.
In R2018b, the end of the script is simply:
%MATLAB_ROOT%\polyspace\bin\polyspace-configure.exe -output-options-file %DUMMY_FILE% -no-sources -allow-overwrite %BUILD_COMMAND%
Best Answer