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

11.8 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.

The value of an external reference is obtained by means of 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", "GNU/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, the function returns an empty string.

In the form with two string parameters, the second argument is the value returned when the variable given as the first argument 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 is "GNU/Linux".

An external reference may be part of a string expression or of a string list expression, and can therefore appear in a variable declaration or an attribute declaration.

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