www.delorie.com/gnu/docs/gcc/gnat_ug_121.html   search  
 
Buy the book!


Untitled Document

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.3.6 Attributes

A project (and its packages) may have attributes that define the project's properties. Some attributes have values that are strings; others have values that are string lists.

There are two categories of attributes: simple attributes and associative arrays (see 10.3.7 Associative Array Attributes).

The names of the attributes are restricted; there is a list of project attributes, and a list of package attributes for each package. The names are not case sensitive.

The project attributes are as follows (all are simple attributes):

Attribute Name Value
Source_Files string list
Source_Dirs string list
Source_List_File string
Object_Dir string
Exec_Dir string
Main string list
Languages string list
Library_Dir string
Library_Name string
Library_Kind string
Library_Elaboration string
Library_Version string

The attributes for package Naming are as follows (see 10.10 Naming Schemes):

Attribute Name Category Index Value
Specification_Suffix associative array language name string
Implementation_Suffix associative array language name string
Separate_Suffix simple attribute n/a string
Casing simple attribute n/a string
Dot_Replacement simple attribute n/a string
Specification associative array Ada unit name string
Implementation associative array Ada unit name string
Specification_Exceptions associative array language name string list
Implementation_Exceptions associative array language name string list

The attributes for package Builder, Compiler, Binder, Linker, Cross_Reference, and Finder are as follows (see 10.13.1.1 Switches and Project Files).

Attribute Name Category Index Value
Default_Switches associative array language name string list
Switches associative array file name string list

In addition, package Builder has a single string attribute Local_Configuration_Pragmas and package Builder has a single string attribute Global_Configuration_Pragmas.

The attribute for package Glide are not documented: they are for internal use only.

Each simple attribute has a default value: the empty string (for string-valued attributes) and the empty list (for string list-valued attributes).

Similar to variable declarations, an attribute declaration defines a new value for an attribute.

Examples of simple attribute declarations:

 
   for Object_Dir use "objects";
   for Source_Dirs use ("units", "test/drivers");

A simple attribute declaration starts with the reserved word for, followed by the name of the attribute, followed by the reserved word use, followed by an expression (whose kind depends on the attribute), followed by a semicolon.

Attributes may be referenced in expressions. The general form for such a reference is <entity>'<attribute>: the entity for which the attribute is defined, followed by an apostrophe, followed by the name of the attribute. For associative array attributes, a litteral string between parentheses need to be supplied as index.

Examples are:

 
  project'Object_Dir
  Naming'Dot_Replacement
  Imported_Project'Source_Dirs
  Imported_Project.Naming'Casing
  Builder'Default_Switches("Ada")

The entity may be:

Example:
 
   project Prj is
     for Source_Dirs use project'Source_Dirs & "units";
     for Source_Dirs use project'Source_Dirs & "test/drivers"
   end Prj;

In the first attribute declaration, initially the attribute Source_Dirs has the default value: an empty string list. After this declaration, Source_Dirs is a string list of one element: "units". After the second attribute declaration Source_Dirs is a string list of two elements: "units" and "test/drivers".

Note: this example is for illustration only. In practice, the project file would contain only one attribute declaration:

 
   for Source_Dirs use ("units", "test/drivers");


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003