Next: Expressions, Previous: Declarations, Up: Project File Reference [Contents][Index]
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).
BinderThis 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.
BuilderThis 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.
CheckThis package specifies the options used when calling the checking tool
gnatcheck via the gnat driver. Its attribute
Default_Switches has the same semantics as for the package
Builder. The first string should always be -rules to specify
that all the other options belong to the -rules section of the
parameters to gnatcheck.
CompilerThis package specifies the compilation options used by the compiler for each languages. See Tools Options in Project Files.
Cross_ReferenceThis package specifies the options used when calling the library tool
gnatxref via the gnat driver. Its attributes
Default_Switches and Switches have the same semantics as for the
package Builder.
EliminateThis package specifies the options used when calling the tool
gnatelim via the gnat driver. Its attributes
Default_Switches and Switches have the same semantics as for the
package Builder.
FinderThis package specifies the options used when calling the search tool
gnatfind via the gnat driver. Its attributes
Default_Switches and Switches have the same semantics as for the
package Builder.
GnatlsThis package the options to use when invoking gnatls via the
gnat driver.
GnatstubThis package specifies the options used when calling the tool
gnatstub via the gnat driver. Its attributes
Default_Switches and Switches have the same semantics as for the
package Builder.
IDEThis package specifies the options used when starting an integrated
development environment, for instance GPS or Gnatbench.
See The Development Environments.
LinkerThis package specifies the options used by the linker. See Main Subprograms.
MakefileThis package is used by the GPS plugin Makefile.py. See the documentation in that plugin (from GPS: /Tools/Plug-ins).
MetricsThis package specifies the options used when calling the tool
gnatmetric via the gnat driver. Its attributes
Default_Switches and Switches have the same semantics as for the
package Builder.
NamingThis 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.
Pretty_PrinterThis package specifies the options used when calling the formatting tool
gnatpp via the gnat driver. Its attributes
Default_Switches and Switches have the same semantics as for the
package Builder.
StackThis package specifies the options used when calling the tool
gnatstack via the gnat driver. Its attributes
Default_Switches and Switches have the same semantics as for the
package Builder.
SynchronizeThis 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 ;