Next: , Previous: Project Extension, Up: GNAT Project Manager


10.7 External References in Project Files

A project file may contain references to external variables; such references are called external references.

An external variable is either defined as part of the environment (an environment variable in Unix, for example) or else specified on the command line via the -Xvbl=value switch. If both, then the command line value is used.

An external reference is denoted by the built-in function external, which returns a string value. This function has two forms:

Each parameter must be a string literal. For example:

        external ("USER")
        external ("OS", "Linux")

In the form with one parameter, the function returns the value of the external variable given as parameter. If this name is not present in the environment, then the returned value is an empty string.

In the form with two string parameters, the second parameter is the value returned when the variable given as the first parameter is not present in the environment. In the example above, if "OS" is not the name of an environment variable and is not passed on the command line, then the returned value will be "Linux".

An external reference may be part of a string expression or of a string list expression, to define variables or attributes.

        type Mode_Type is ("Debug", "Release");
        Mode : Mode_Type := external ("MODE");
        case Mode is
          when "Debug" =>
             ...