A number of GNAT tools, other than gnatmake are project-aware:
gnatbind, gnatfind, gnatlink, gnatls
and gnatxref. However, none of these tools can be invoked directly
with a project file switch (
-P). They need to be invoke through the
The gnat driver is a front-end that accepts a number of commands and call the corresponding tool. It has been designed initially for VMS to convert VMS style qualifiers to Unix style switches, but it is now available to all the GNAT supported platforms.
On non VMS platforms, the gnat driver accepts the following commands (case insensitive):
Note that the compiler is invoked using the command gnatmake -f -u.
Following the command, you may put switches and arguments for the invoked tool.
gnat bind -C main.ali gnat ls -a main gnat chop foo.txt
In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the project
file related switches (
-vPx) may be used in
addition to the switches of the invoking tool.
For each of these command, there is possibly a package in the main project that corresponds to the invoked tool.
Binderfor command BIND (invoking
Finderfor command FIND (invoking
Gnatlsfor command LS or LIST (invoking
Linkerfor command LINK (invoking
Cross_Referencefor command XREF (invoking
Gnatls has a unique attribute
Switches, a simple variable
with a string list value. It contains switches for the invocation of
project Proj1 is package gnatls is for Switches use ("-a", "-v"); end gnatls; end Proj1;
All other packages contains a switch
Default_Switches, an associative
array, indexed by the programming language (case insensitive) and having a
string list value.
Default_Switches ("Ada") contains the switches for
the invocation of the tool corresponding to the package.
project Proj is for Source_Dirs use ("./**"); package gnatls is for Switches use ("-a", "-v"); end gnatls; package Binder is for Default_Switches ("Ada") use ("-C", "-e"); end Binder; package Linker is for Default_Switches ("Ada") use ("-C"); end Linker; package Finder is for Default_Switches ("Ada") use ("-a", "-f"); end Finder; package Cross_Reference is for Default_Switches ("Ada") use ("-a", "-f", "-d", "-u"); end Cross_Reference; end Proj;
With the above project file, commands such as
gnat ls -Pproj main gnat xref -Pproj main gnat bind -Pproj main.ali
will set up the environment properly and invoke the tool with the switches found in the package corresponding to the tool.