Next: , Previous: Declarations, Up: Project File Reference


11.9.4 Packages

A project file may contain packages, that group attributes (typically all the attributes that are used by one of the GNAT tools).

A package with a given name may only appear once in a project file. The following packages are currently supported in project files (See see Attributes for the list of attributes that each can contain).

Binder
This package specifies characteristics useful when invoking the binder either directly via the gnat driver or when using a builder such as gnatmake or gprbuild. See Main Subprograms.
Builder
This package specifies the compilation options used when building an executable or a library for a project. Most of the options should be set in one of Compiler, Binder or Linker packages, but there are some general options that should be defined in this package. See Main Subprograms, and see Executable File Names in particular.
Clean
This package specifies the options used when cleaning a project or a project tree using the tools gnatclean or gprclean.
Compiler
This package specifies the compilation options used by the compiler for each languages. See Tools Options in Project Files.
Cross_Reference
This package specifies the options used when calling the library tool gnatxref via the gnat driver. Its attributes Default_Switches and ^Switches^Switches^ have the same semantics as for the package Builder.
Finder
This package specifies the options used when calling the search tool gnatfind via the gnat driver. Its attributes Default_Switches and ^Switches^Switches^ have the same semantics as for the package Builder.
^Gnatls^Gnatls^
This package specifies the options to use when invoking gnatls via the gnat driver.
IDE
This package specifies the options used when starting an integrated development environment, for instance GPS or Gnatbench.
Install
This package specifies the options used when installing a project with gprinstall. See Installation.
Linker
This package specifies the options used by the linker. See Main Subprograms.
Naming
This package specifies the naming conventions that apply to the source files in a project. In particular, these conventions are used to automatically find all source files in the source directories, or given a file name to find out its language for proper processing. See Naming Schemes.
Remote
This package is used by gprbuild to describe how distributed compilation should be done.
Stack
This package specifies the options used when calling the tool gnatstack via the gnat driver. Its attributes Default_Switches and ^Switches^Switches^ have the same semantics as for the package Builder.
Synchronize
This package specifies the options used when calling the tool gnatsync via the gnat driver.

In its simplest form, a package may be empty:

     project Simple is
       package Builder is
       end Builder;
     end Simple;

A package may contain attribute declarations, variable declarations and case constructions, as will be described below.

When there is ambiguity between a project name and a package name, the name always designates the project. To avoid possible confusion, it is always a good idea to avoid naming a project with one of the names allowed for packages or any name that starts with gnat.

A package can also be defined by a renaming declaration. The new package renames a package declared in a different project file, and has the same attributes as the package it renames. The name of the renamed package must be the same as the name of the renaming package. The project must contain a package declaration with this name, and the project must appear in the context clause of the current project, or be its parent project. It is not possible to add or override attributes to the renaming project. If you need to do so, you should use an extending declaration (see below).

Packages that are renamed in other project files often come from project files that have no sources: they are just used as templates. Any modification in the template will be reflected automatically in all the project files that rename a package from the template. This is a very common way to share settings between projects.

Finally, a package can also be defined by an extending declaration. This is similar to a renaming declaration, except that it is possible to add or override attributes.

     package_declaration ::= package_spec | package_renaming | package_extension
     package_spec ::=
       package <package_>simple_name is
         {simple_declarative_item}
       end package_identifier ;
     package_renaming ::==
       package <package_>simple_name renames <project_>simple_name.package_identifier ;
     package_extension ::==
       package <package_>simple_name extends <project_>simple_name.package_identifier is
         {simple_declarative_item}
       end package_identifier ;