In Eclipse, how can I use the result of polyspace-configure in my Polyspace project?

1 view (last 30 days)
I find the Polyspace plugin for Eclipse works well when calling the compiler directly from Eclipse. However, when I use a makefile I do not observe the same degree of integration (presumably since the use of a makefile is preventing Polyspace from being configured properly).
I know it is possible to use polyspace-configure to create a project file and use it as the Polyspace project inside Eclipse, but in that case every time polyspace-configure is called, the options set in the project (for example the options related to the coding rules checking) are lost.
Is there a way I use both polyspace-configure to get the compilation options from my makefile but still use the same Polyspace project file?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Oct 2018
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%

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!