Next: Configurations, Previous: GPRconfig external values, Up: The GPRconfig knowledge base [Contents][Index]
The various compiler attributes defined above are made available as
variables in the rest of the XML files. Each of these variables can be used
in the value of the various nodes (for instance in <directory>
),
and in the configurations (see Configuration).
A variable is referenced by ${name}
where name is either
a user variable or a predefined variable. An alternate reference is
$name
where name is a sequence of alpha numeric characters or
underscores. Finally $$
is replaced by a simple $
.
User variables are defined by <variable>
nodes and may override
predefined variables. To avoid a possible override use lower case names.
The variables are used in two contexts: either in a
<compiler_description>
node, in which case the variable refers to
the compiler we are describing, or within a <configuration>
node.
In the latter case, and since there might be several compilers selected,
you need to further specify the variable by adding in parenthesis the
language of the compiler you are interested in.
For instance, the following is invalid:
<configuration> <compilers> <compiler name="GNAT" /> </compilers> <targets negate="true"> <target name="^powerpc-elf$"/> </targets> <config> package Compiler is for Driver ("Ada") use "${PATH}gcc"; -- Invalid ! end Compiler; </config> </configuration>
The trouble with the above is that if you are using multiple languages
like C and Ada, both compilers will match the "negate" part, and therefore
there is an ambiguity for the value of ${PATH}
. To prevent such
issues, you need to use the following syntax instead when inside a
<configuration>
node:
for Driver ("Ada") use "${PATH(ada)}gcc"; -- Correct
Predefined variables are always in upper case. Here is the list of predefined variables
is the name of the executable that was found through <executable>
. It
only contains the basename, not the directory information.
is replaced by the architecture of the host on which GPRconfig is
running. This name is hard-coded in GPRconfig itself, and is generated
by configure
when GPRconfig was built.
is replaced by the target architecture of the compiler, as returned by the
<target>
node. This is of course not available when computing the
target itself.
This variable takes the language of the compiler as an optional index when
in a <configuration>
block: if the language is specified, the target
returned by that specific compiler is used; otherwise, the normalized target
common to all the selected compilers will be returned (target normalization
is also described in the knowledge base’s XML files).
is replaced by the version of the compiler. This is not available when computing the target or, of course, the version itself.
is replaced by the prefix to the executable name, as defined by the
<executable>
node.
is the current directory, i.e. the one containing the executable found through
<executable>
. It always ends with a directory separator.
is the language supported by the compiler, always folded to lower-case
This string will always be substituted by the empty string when the value of the external value is computed. These are special strings used when substituting text in configuration chunks.
RUNTIME_DIR always end with a directory separator.
is the directory in which GPRconfig was installed (e.g
"/usr/local/" if the executable is "/usr/local/bin/gprconfig".
This directory always ends with a directory separator.
This variable never takes a language in parameter, even within a
<configuration>
node.
If a variable is not defined, an error message is issued and the variable is substituted by an empty string.