How to use environnement variables inside Polyspace project configuration ?

5 次查看(过去 30 天)
Hi,
I'm using Polyspace BugFinder in my company to do static analysis compliance with MISRA rules. I'm starting to use this software with the desktop version (no command line for now).
I wanted to create one project definition for all the developpers that will need to use a static analysis of their code. Since each of us have the source code repository at different location on our computer, we set an environment variable to retrieve those sources.
I tried to use this environment variable inside Polyspace but it doesn't work. My question is : is there a way to include sources/includes files path with an environment variable inside Polyspace BugFinder ?
Thanks

采纳的回答

Anirban
Anirban 2020-1-21
编辑:Anirban 2020-1-21
Each time you open a project in the Polyspace user interface, the path to source files in the project is recomputed with respect to the project location. So, if you submit your Polyspace project to a version control system, each developer creating a local copy of the project will see the project pointing to a local copy of his/her source files.
To give an example, say that the project file (.psprj file) is in a network repository with the path:
//networkLocation/polyspaceProjects/
Say, this project points to a source file:
//networkLocation/src/file.c
If you make a local copy of this repository and the project file is now in:
//usr/local/polyspaceProjects/
When you open this project in the Polyspace user interface, it will recompute the path to the source file as (and try to find the source file there):
//usr/local/src/file.c
In effect, you should not need the environment variable that you are speaking of (as long as the developers' copy of the project can point to their copy of source files).

更多回答(1 个)

Judy Zouaoui
Judy Zouaoui 2020-1-22
Thanks for your reply Anirban.
I tried to copy the project I created inside another directory but the path to sources and includes files seems to be absolute. We are working on Windows 7 and 10 by the way.
I opened the .psprj file with a text editor, and some variable shows absolute path inside it. For example :
<polyspace_project name="Test" product="Polyspace C CPP" author="username" version="1.0" date="22/01/2020" path="file:/C:/AbsolutePath/To/Test.psprj" rev="2.1">
<source>
<root_folder path="file:/C:/AbsolutePath/To/Repository/src/" isnested="true" filter=".cpp,.cxx,.cc,.c">
<file path="RelativePath/To/file.cpp"/>
<file path="RelativePath/To/AnotherFile.cpp"/>
</root_folder>
</source>
I've looked inside the user interface parameters and there is no option for relative source path. There may be a variable to add manually inside the .psprj to set the root folder relatively ?
I didn't tried the command line, I'll explore this alternative if the user interface is too restrictive.
  2 个评论
Anirban
Anirban 2020-1-22
Hi Judy,
The path is indeed absolute, but the absolute path is recomputed when you open the project in the Polyspace user interface (based on the current location of the project).
This means that in practice, you will see the following if you move the project (possibly along with sources) to a new location like you did:
  1. If you open the psprj file in a text editor, it still has the old path.
  2. If you open the project in the Polyspace user interface instead and navigate to the 'Source' folder and the sources inside on the Project Browser pane, you should see the paths to the new files. However, the .psprj file when opened in a text editor still shows the old path.
  3. Only when you start a new analysis from the user interface are these new locations written to the psprj file. So, now if you open the psprj file in a text editor, you should see the new paths.
The idea was that opening the psprj file directly in a text editor is something that is not recommended. So, all these things happen "behind the scenes" and if the user interacts with the project through the user interface only, the right things should happen.
Note that the recomputing of paths works in most cases but there are some corner cases where it might not work. If you don't see the change I am stating above, please contact MathWorks Technical Support: https://www.mathworks.com/support/contact_us.html

请先登录,再进行评论。

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by