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 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):
- The environment defined on the node itself (Genero variables and User variables). This has the highest priority.
- The environment of the node's parents (ancestors).
- The environment of the node's dependencies.
- Environment variables defined in the current language.
- Environment variables defined in Environment sets.
- System environment variables. This has the lowest priority.
The order of priority allows you to override both system environment variables (6, above) or environment variables defined in a Genero Studio configuration (5, above) by setting them in Project Manager (1 through 4, above).
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