Next: , Previous: Variables, Up: Project File Syntax


11.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 Associative Array Attributes).

Legal project attribute names, and attribute names for each legal package are listed below. Attributes names are case-insensitive.

The following attributes are defined on projects (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
Locally_Removed_Files string list
Main string list
Languages string list
Main_Language string
Library_Dir string
Library_Name string
Library_Kind string
Library_Version string
Library_Interface string
Library_Auto_Init string
Library_Options string list
Library_GCC string

The following attributes are defined for package Naming (see Naming Schemes):

Attribute Name Category Index Value
Spec_Suffix associative array language name string
Body_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
Spec associative array Ada unit name string
Body associative array Ada unit name string
Specification_Exceptions associative array language name string list
Implementation_Exceptions associative array language name string list

The following attributes are defined for packages Builder, Compiler, Binder, Linker, Cross_Reference, and Finder (see 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 Compiler has a single string attribute Local_Configuration_Pragmas and package Builder has a single string attribute Global_Configuration_Pragmas.

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

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");

The syntax of a simple attribute declaration is similar to that of an attribute definition clause in Ada.

Attributes references may be appear in expressions. The general form for such a reference is <entity>'<attribute>: Associative array attributes are functions. Associative array attribute references must have an argument that is a string literal.

Examples are:

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

The prefix of an attribute 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");