Project variables
Define environment variables for use as shorthands in Polyspace Platform project
Since R2024a
Description
Define variables for use as shorthands in a Polyspace Platform (Polyspace Test) project configuration.
Set Option
In your Polyspace Platform project configuration, enter variable names and values for this option on the Project tab.
Why Use This Option
You can use project variables as shorthands when entering values for options that require a path to a file or folder.
For instance, you can define a project variable as shorthand for a root path to folders containing your sources and handwritten tests. You can then use the variable in other fields such as Application source folders and Polyspace xUnit test folders to parameterize your paths. For example, suppose that your source and test folders are subfolders of a root folder E:\repo
. You can define a project variable
SRC_ROOT_PATH
with the value E:\repo
and enter all other paths relative to this location by starting your entry with $(SRC_ROOT_PATH)
. For instance, the source folder path E:\repo\src\moduleMathLibs
can be entered as $(SRC_ROOT_PATH)\src\moduleMathLibs
. Parameterizing the path using project variables allows you or another user to reuse the project even when the root folder has changed. By
modifying the SRC_ROOT_PATH
to refer to the new source root path, you can reuse the project without having to manually update all file paths.
Note that you can also refer to environment variables on your operating system using the same notation. For instance, you can define an environment variable SRC_ROOT_PATH
and use $(SRC_ROOT_PATH)
as a shorthand in the project settings. If another user using the same project has the same environment variable set to a different root path, they can directly use the project without having to make changes in the project. Using system environment
variables is preferred over project variables since this does not require users to make changes to a shared project. For more information on recommendations for sharing projects, see Share Polyspace Platform Projects, Workspaces, and Configurations (Polyspace Test).
Settings
Select to add an empty row. Enter the project configuration variable name in the Name column and its value in the Value column. You can then use the variable name within
$()
in options that support environment variables. For instance, if you define an environment variable SRC_ROOT_PATH
you can use the variable as $(SRC_ROOT_PATH)
in options that support environment
variables.
For the full list of options that support variables, see Share Polyspace Platform Projects, Workspaces, and Configurations (Polyspace Test).
Tips
You can use the predefined project variable PROJECTDIR
in place of the current project path. For instance, if you want to specify a source file path relative to the current project path, you can enter the file path for the option Application source files
using the following syntax:
$(PROJECTDIR)\path\to\file.c
PROJECTDIR
is implicitly defined and you cannot redefine its value.Version History
Introduced in R2024a