[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes the syntax and semantics of project files. Project files specify the options to be used when building a system. Project files can specify global settings for all tools, as well as tool-specific settings. See the chapter on project files in the GNAT Users guide for examples of use.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
All Ada95 reserved words are reserved in project files, and cannot be used as variable names or project names. In addition, the following are also reserved in project files:
extends
external
project
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Rules for identifiers are the same as in Ada95. Identifiers are case-insensitive. Strings are case sensitive, except where noted. Comments have the same form as in Ada95.
Syntax:
simple_name ::= identifier name ::= simple_name {. simple_name} |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Declarations introduce new entities that denote types, variables, attributes, and packages. Some declarations can only appear immediately within a project declaration. Others can appear within a project or within a package.
Syntax:
declarative_item ::= simple_declarative_item | typed_string_declaration | package_declaration simple_declarative_item ::= variable_declaration | typed_variable_declaration | attribute_declaration | case_construction | empty_declaration |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
empty_declaration ::= null ; |
An empty declaration is allowed anywhere a declaration is allowed. It has no effect.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Typed strings are sequences of string literals. Typed strings are the only named types in project files. They are used in case constructions, where they provide support for conditional attribute definitions.
Syntax:
typed_string_declaration ::= type <typed_string_>_simple_name is ( string_literal {, string_literal} ); |
A typed string declaration can only appear immediately within a project declaration.
All the string literals in a typed string declaration must be distinct.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Variables denote values, and appear as constituents of expressions.
typed_variable_declaration ::= <typed_variable_>simple_name : <typed_string_>name := string_expression ; variable_declaration ::= <variable_>simple_name := expression; |
The elaboration of a variable declaration introduces the variable and assigns to it the value of the expression. The name of the variable is available after the assignment symbol.
A typed_variable can only be declare once.
a non typed variable can be declared multiple times.
Before the completion of its first declaration, the value of variable is the null string.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An expression is a formula that defines a computation or retrieval of a value. In a project file the value of an expression is either a string or a list of strings. A string value in an expression is either a literal, the current value of a variable, an external value, an attribute reference, or a concatenation operation.
Syntax:
expression ::= term {& term} term ::= string_literal | string_list | <variable_>name | external_value | attribute_reference string_literal ::= (same as Ada) string_list ::= ( <string_>expression { , <string_>expression } ) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
function "&" (X : String; Y : String) return String; function "&" (X : String_List; Y : String) return String_List; function "&" (X : String_List; Y : String_List) return String_List; |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An attribute declaration defines a property of a project or package. This property can later be queried by means of an attribute reference. Attribute values are strings or string lists.
Some attributes are associative arrays. These attributes are mappings whose domain is a set of strings. These attributes are declared one association at a time, by specifying a point in the domain and the corresponding image of the attribute. They may also be declared as a full associative array, getting the same associations as the corresponding attribute in an imported or extended project.
Attributes that are not associative arrays are called simple attributes.
Syntax:
attribute_declaration ::= full_associative_array_declaration | for attribute_designator use expression ; full_associative_array_declaration ::= for <associative_array_attribute_>simple_name use <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ; attribute_designator ::= <simple_attribute_>simple_name | <associative_array_attribute_>simple_name ( string_literal ) |
Some attributes are project-specific, and can only appear immediately within a project declaration. Others are package-specific, and can only appear within the proper package.
The expression in an attribute definition must be a string or a string_list. The string literal appearing in the attribute_designator of an associative array attribute is case-insensitive.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following attributes apply to a project. All of them are simple attributes.
Object_Dir
Exec_Dir
Source_Dirs
Source_Files
Source_List_File
Library_Dir
Library_Name
Library_Kind
"static"
, "dynamic"
or "relocatable"
. This
string is case-insensitive. If this attribute is not specified, the library is
a static library. Otherwise, the library may be dynamic or relocatable. This
distinction is operating-system dependent.
Library_Version
"soname"
). If the
library file name (built from the Library_Name
) is different from the
Library_Version
, then the library file will be a symbolic link to the
actual file whose name will be Library_Version
.
Library_Interface
Library_Auto_Init
Library_Options
Library_GCC
Library_Src_Dir
Main
When a project file is elaborated, as part of the execution of a gnatmake command, one or several executables are built and placed in the Exec_Dir. If the gnatmake command does not include explicit file names, the executables that are built correspond to the files specified by this attribute.
Main_Language
Languages
Locally_Removed_Files
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Attribute references are used to retrieve the value of previously defined attribute for a package or project. Syntax:
attribute_reference ::= attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ] attribute_prefix ::= project | <project_simple_name | package_identifier | <project_>simple_name . package_identifier |
If an attribute has not been specified for a given package or project, its value is the null string or the empty list.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An external value is an expression whose value is obtained from the command that invoked the processing of the current project file (typically a gnatmake command).
Syntax:
external_value ::= external ( string_literal [, string_literal] ) |
The first string_literal is the string to be used on the command line or in the environment to specify the external value. The second string_literal, if present, is the default to use if there is no specification for this external value either on the command line or in the environment.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A case construction supports attribute declarations that depend on the value of a previously declared variable.
Syntax:
case_construction ::= case <typed_variable_>name is {case_item} end case ; case_item ::= when discrete_choice_list => {case_construction | attribute_declaration | empty_declaration} discrete_choice_list ::= string_literal {| string_literal} | others |
All choices in a choice list must be distinct. The choice lists of two
distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
alternatives do not need to include all values of the type. An others
choice must appear last in the list of alternatives.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A package provides a grouping of variable declarations and attribute declarations to be used when invoking various GNAT tools. The name of the package indicates the tool(s) to which it applies. Syntax:
package_declaration ::= package_specification | package_renaming package_specification ::= package package_identifier is {simple_declarative_item} end package_identifier ; package_identifier ::= |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of a Naming
package specifies the naming conventions
that apply to the source files in a project. When invoking other GNAT tools,
they will use the sources in the source directories that satisfy these
naming conventions.
The following attributes apply to a Naming
package:
Casing
"lowercase"
, "uppercase"
or "mixedcase"
.
These strings are themselves case insensitive.
If Casing
is not specified, then the default is "lowercase"
.
Dot_Replacement
'.'
if longer than one character
If Dot_Replacement
is not specified, then the default is "-"
.
Spec_Suffix
For Ada, the attribute denotes the suffix used in file names that contain
library unit declarations, that is to say units that are package and
subprogram declarations. If Spec_Suffix ("Ada")
is not
specified, then the default is ".ads"
.
For C and C++, the attribute denotes the suffix used in file names that contain prototypes.
Body_Suffix
Spec_Suffix
For Ada, the attribute denotes the suffix used in file names that contain
library bodies, that is to say units that are package and subprogram bodies.
If Body_Suffix ("Ada")
is not specified, then the default is
".adb"
.
For C and C++, the attribute denotes the suffix used in file names that contain source code.
Separate_Suffix
Body_Suffix
.
This attribute is specific to Ada. It denotes the suffix used in file names
that contain separate bodies. If it is not specified, then it defaults to same
value as Body_Suffix ("Ada")
.
Spec
Body
Specification_Exceptions
This attribute is not significant for Ada.
For C and C++, each string in the list denotes the name of a file that
contains prototypes, but whose suffix is not necessarily the
Spec_Suffix
for the language.
Implementation_Exceptions
This attribute is not significant for Ada.
For C and C++, each string in the list denotes the name of a file that
contains source code, but whose suffix is not necessarily the
Body_Suffix
for the language.
The following attributes of package Naming
are obsolescent. They are
kept as synonyms of other attributes for compatibility with previous versions
of the Project Manager.
Specification_Suffix
Spec_Suffix
.
Implementation_Suffix
Body_Suffix
.
Specification
Spec
.
Implementation
Body
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of the Compiler
package specify the compilation options
to be used by the underlying compiler.
Default_Switches
Switches
Local_Configuration_Pragmas.
Executable
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package Builder
specify the compilation, binding, and
linking options to be used when building an executable for a project. The
following attributes apply to package Builder
:
Default_Switches
Switches
Global_Configuration_Pragmas
Executable
Executable_Suffix
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package Gnatls
specify the tool options to be used
when invoking the library browser gnatls
.
The following attributes apply to package Gnatls
:
Switches
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package Binder
specify the options to be used
when invoking the binder in the construction of an executable.
The following attributes apply to package Binder
:
Default_Switches
Switches
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package Linker
specify the options to be used when
invoking the linker in the construction of an executable.
The following attributes apply to package Linker
:
Default_Switches
Switches
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package Cross_Reference
specify the tool options
to be used
when invoking the library tool gnatxref
.
The following attributes apply to package Cross_Reference
:
Default_Switches
Switches
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package Finder
specify the tool options to be used
when invoking the search tool gnatfind
.
The following attributes apply to package Finder
:
Default_Switches
Switches
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package Pretty_Printer
specify the tool options to be used
when invoking the formatting tool gnatpp
.
The following attributes apply to package Pretty_Printer
:
Default_switches
Switches
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The attributes of package IDE
specify the options to be used when using
an Integrated Development Environment such as GPS
.
Remote_Host
Program_Host
Communication_Protocol
"wtx"
or "vxworks"
.
Compiler_Command
Compiler_Command ("Ada")
is expected to be compatible with
gnatmake, in particular in the handling of switches.
Debugger_Command
Default_Switches
Gnatlist
gnatls
utility to be used to retrieve information about the
predefined path; e.g., "gnatls"
, "powerpc-wrs-vxworks-gnatls"
.
VCS_Kind
VCS_File_Check
VCS_Log_Check
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A package can 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. Syntax:
package_renaming ::== package package_identifier renames <project_>simple_name.package_identifier ; |
The package_identifier of the renamed package must be the same as the package_identifier. The project whose name is the prefix of the renamed package must contain a package declaration with this name. This project must appear in the context_clause of the enclosing project declaration, or be the parent project of the enclosing child project.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A project file specifies a set of rules for constructing a software system. A project file can be self-contained, or depend on other project files. Dependencies are expressed through a context clause that names other projects.
Syntax:
project ::= context_clause project_declaration project_declaration ::= simple_project_declaration | project_extension simple_project_declaration ::= project <project_>simple_name is {declarative_item} end <project_>simple_name; context_clause ::= {with_clause} with_clause ::= [limited] with path_name { , path_name } ; path_name ::= string_literal |
A path name denotes a project file. A path name can be absolute or relative. An absolute path name includes a sequence of directories, in the syntax of the host operating system, that identifies uniquely the project file in the file system. A relative path name identifies the project file, relative to the directory that contains the current project, or relative to a directory listed in the environment variable ADA_PROJECT_PATH. Path names are case sensitive if file names in the host operating system are case sensitive.
The syntax of the environment variable ADA_PROJECT_PATH is a list of directory names separated by colons (semicolons on Windows).
A given project name can appear only once in a context_clause.
It is illegal for a project imported by a context clause to refer, directly
or indirectly, to the project in which this context clause appears (the
dependency graph cannot contain cycles), except when one of the with_clause
in the cycle is a limited with
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A project extension introduces a new project, which inherits the declarations of another project. Syntax:
project_extension ::= project <project_>simple_name extends path_name is {declarative_item} end <project_>simple_name; |
The project extension declares a child project. The child project inherits all the declarations and all the files of the parent project, These inherited declaration can be overridden in the child project, by means of suitable declarations.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A project file is processed as part of the invocation of a gnat tool that uses the project option. Elaboration of the process file consists in the sequential elaboration of all its declarations. The computed values of attributes and variables in the project are then used to establish the environment in which the gnat tool will execute.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |