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

11.7.9 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.

     attribute_declaration ::=
        simple_attribute_declaration | indexed_attribute_declaration
     simple_attribute_declaration ::= for attribute_designator use expression ;
     indexed_attribute_declaration ::=
       for <indexed_attribute_>simple_name ( string_literal) use expression ;
     attribute_designator ::=
       | <indexed_attribute_>simple_name ( string_literal )

There are two categories of attributes: simple attributes and indexed attributes. Each simple attribute has a default value: the empty string (for string attributes) and the empty list (for string list attributes). An attribute declaration defines a new value for an attribute, and overrides the previous value. The syntax of a simple attribute declaration is similar to that of an attribute definition clause in Ada.

Some attributes are indexed. These attributes are mappings whose domain is a set of strings. They are declared one association at a time, by specifying a point in the domain and the corresponding image of the attribute. Like untyped variables and simple attributes, indexed attributes may be declared several times. Each declaration supplies a new value for the attribute, and replaces the previous setting.

Here are some examples of attribute declarations:

        --  simple attributes
        for Object_Dir use "objects";
        for Source_Dirs use ("units", "test/drivers");
        --  indexed attributes
        for Body ("main") use "Main.ada";
        for Switches ("main.ada") use ("-v", "-gnatv");
        for Switches ("main.ada") use Builder'Switches ("main.ada") & "-g";
        --  indexed attributes copy (from package Builder in project Default)
        --  The package name must always be specified, even if it is the current
        --  package.
        for Default_Switches use Default.Builder'Default_Switches;

Attributes references may be appear anywhere in expressions, and are used to retrieve the value previously assigned to the attribute. If an attribute has not been set in a given package or project, its value defaults to the empty string or the empty list.

     attribute_reference ::= attribute_prefix ' <simple_attribute>_simple_name [ (string_literal) ]
     attribute_prefix ::= project
       | <project_>simple_name
       | package_identifier
       | <project_>simple_name . package_identifier

Examples are:

       Builder'Default_Switches ("Ada")

The prefix of an attribute may be:

Legal attribute names are listed below, including the package in which they must be declared. These names are case-insensitive. The semantics for the attributes is explained in great details in other sections.

The column index indicates whether the attribute is an indexed attribute, and when it is whether its index is case sensitive (sensitive) or not (insensitive), or if case sensitivity depends is the same as file names sensitivity on the system (file). The text is between brackets ([]) if the index is optional.

Attribute Name Value Package Index
General attributes see Building With Projects
Name string - (Read-only, name of project)
Project_Dir string - (Read-only, directory of project)
Source_Files list - -
Source_Dirs list - -
Source_List_File string - -
Locally_Removed_Files list - -
Excluded_Source_Files list - -
Object_Dir string - -
Exec_Dir string - -
Excluded_Source_Dirs list - -
Excluded_Source_Files list - -
Excluded_Source_List_File list - -
Inherit_Source_Path list - insensitive
Languages list - -
Main list - -
Main_Language string - -
Externally_Built string - -
Roots list - file
Library-related attributes see Library Projects
Library_Dir string - -
Library_Name string - -
Library_Kind string - -
Library_Version string - -
Library_Interface string - -
Library_Auto_Init string - -
Library_Options list - -
Leading_Library_Options list - -
Library_Src_Dir string - -
Library_ALI_Dir string - -
Library_GCC string - -
Library_Symbol_File string - -
Library_Symbol_Policy string - -
Library_Reference_Symbol_File string - -
Interfaces list - -
Naming see Naming Schemes
Spec_Suffix string Naming insensitive (language)
Body_Suffix string Naming insensitive (language)
Separate_Suffix string Naming -
Casing string Naming -
Dot_Replacement string Naming -
Spec string Naming insensitive (Ada unit)
Body string Naming insensitive (Ada unit)
Specification_Exceptions list Naming insensitive (language)
Implementation_Exceptions list Naming insensitive (language)
Building see Switches and Project Files
Default_Switches list Builder, Compiler, Binder, Linker, Cross_Reference, Finder, Pretty_Printer, gnatstub, Check, Synchronize, Eliminate, Metrics, IDE insensitive (language name)
Switches list Builder, Compiler, Binder, Linker, Cross_Reference, Finder, gnatls, Pretty_Printer, gnatstub, Check, Synchronize, Eliminate, Metrics, Stack [file] (file name)
Local_Configuration_Pragmas string Compiler -
Local_Config_File string insensitive -
Global_Configuration_Pragmas list Builder -
Global_Compilation_Switches list Builder language
Executable string Builder [file]
Executable_Suffix string Builder -
Global_Config_File string Builder insensitive (language)
IDE (used and created by GPS)
Remote_Host string IDE -
Program_Host string IDE -
Communication_Protocol string IDE -
Compiler_Command string IDE insensitive (language)
Debugger_Command string IDE -
Gnatlist string IDE -
VCS_Kind string IDE -
VCS_File_Check string IDE -
VCS_Log_Check string IDE -
Documentation_Dir string IDE -
Configuration files See gprbuild manual
Default_Language string - -
Run_Path_Option list - -
Run_Path_Origin string - -
Separate_Run_Path_Options string - -
Toolchain_Version string - insensitive
Toolchain_Description string - insensitive
Object_Generated string - insensitive
Objects_Linked string - insensitive
Target string - -
Library_Builder string - -
Library_Support string - -
Archive_Builder list - -
Archive_Builder_Append_Option list - -
Archive_Indexer list - -
Archive_Suffix string - -
Library_Partial_Linker list - -
Shared_Library_Prefix string - -
Shared_Library_Suffix string - -
Symbolic_Link_Supported string - -
Library_Major_Minor_Id_Supported string - -
Library_Auto_Init_Supported string - -
Shared_Library_Minimum_Switches list - -
Library_Version_Switches list - -
Library_Install_Name_Option string - -
Runtime_Library_Dir string - insensitive
Runtime_Source_Dir string - insensitive
Driver string Compiler,Binder,Linker insensitive (language)
Required_Switches list Compiler,Binder,Linker insensitive (language)
Leading_Required_Switches list Compiler insensitive (language)
Trailing_Required_Switches list Compiler insensitive (language)
Pic_Options list Compiler insensitive (language)
Path_Syntax string Compiler insensitive (language)
Object_File_Suffix string Compiler insensitive (language)
Object_File_Switches list Compiler insensitive (language)
Multi_Unit_Switches list Compiler insensitive (language)
Multi_Unit_Object_Separator string Compiler insensitive (language)
Mapping_File_Switches list Compiler insensitive (language)
Mapping_Spec_Suffix string Compiler insensitive (language)
Mapping_body_Suffix string Compiler insensitive (language)
Config_File_Switches list Compiler insensitive (language)
Config_Body_File_Name string Compiler insensitive (language)
Config_Body_File_Name_Index string Compiler insensitive (language)
Config_Body_File_Name_Pattern string Compiler insensitive (language)
Config_Spec_File_Name string Compiler insensitive (language)
Config_Spec_File_Name_Index string Compiler insensitive (language)
Config_Spec_File_Name_Pattern string Compiler insensitive (language)
Config_File_Unique string Compiler insensitive (language)
Dependency_Switches list Compiler insensitive (language)
Dependency_Driver list Compiler insensitive (language)
Include_Switches list Compiler insensitive (language)
Include_Path string Compiler insensitive (language)
Include_Path_File string Compiler insensitive (language)
Prefix string Binder insensitive (language)
Objects_Path string Binder insensitive (language)
Objects_Path_File string Binder insensitive (language)
Linker_Options list Linker -
Leading_Switches list Linker -
Map_File_Options string Linker -
Executable_Switches list Linker -
Lib_Dir_Switch string Linker -
Lib_Name_Switch string Linker -
Max_Command_Line_Length string Linker -
Response_File_Format string Linker -
Response_File_Switches list Linker -