Main Content

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

User interface (Polyspace Platform (Polyspace Test), desktop products only): In your project configuration, the option is in the Advanced section of 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 Add empty row button 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).

Version History

Introduced in R2024a