What determines the value of an environment variable
Environment variables define the environment used by the compiler and executables launched from Project Manager. Where and when the environment variable is set is important.
Order of precedence
An environment variable can be set in multiple places, inside and outside of Genero Studio. Environment variables have an order of priority (high to low):
- Environment variables defined for the node. This has the highest priority. A node's environment variables are set using the Advanced Properties dialog.
- The environment of the node's parents (ancestors).
- The environment of the node's dependencies.
- Build rule environment variables for the project for the current language of the node. See Add a project-level environment variable.
- Build rule environment variables for the specific setup for the current language of the node. See Add a specific setup-level environment variable
- Build rule environment variables for the global for the current language of the node. See Add a global-level environment variable.
- Environment variables defined in Environment sets.
- System environment variables. These have the lowest priority.
Order within an Environment Set
Within an Environment Set, arrow keys can be used to change the order of the variables defined. This affects the way the variables are interpreted when the program is executed. For example:
Project level | Variables definition and order | Result when application is executed |
---|---|---|
Project | V1="hello" |
|
Application | V2="$(V1) world"
|
|
Application |
|
|
Example: Priority and Environment Variables
In this example, the program node in the project has a library node as a dependency. The environments have been defined as shown:
Level | Environment Set |
---|---|
System environment |
|
My Library Environment |
|
My Program Environment |
|
If the project directory $(ProjectDir)
is set to
"/home/joe/project
", the environment for the program will be:
PATH=/bin;/usr/bin/;/home/joe/project/scripts
VAR1=goodbye world
VAR2=bonjour goodbye world
VAR3=guten tag