Next: , Previous: Variables, Up: Project File Reference   [Contents][Index]

1.8.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 ::=
  <simple_attribute_>simple_name
  | <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:

  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:

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 NameValuePackageIndex
General attributessee Building With Projects
Namestring-(Read-only, name of project)
Project_Dirstring-(Read-only, directory of project)
Source_Fileslist--
Source_Dirslist--
Source_List_Filestring--
Locally_Removed_Fileslist--
Excluded_Source_Fileslist--
Object_Dirstring--
Exec_Dirstring--
Excluded_Source_Dirslist--
Excluded_Source_Fileslist--
Excluded_Source_List_Filelist--
Inherit_Source_Pathlist-insensitive
Languageslist--
Mainlist--
Main_Languagestring--
Externally_Builtstring--
Rootslist-file
Library-related attributessee Library Projects
Library_Dirstring--
Library_Namestring--
Library_Kindstring--
Library_Versionstring--
Library_Interfacestring--
Library_Auto_Initstring--
Library_Optionslist--
Leading_Library_Optionslist--
Library_Src_Dirstring--
Library_ALI_Dirstring--
Library_GCCstring--
Library_Symbol_Filestring--
Library_Symbol_Policystring--
Library_Reference_Symbol_Filestring--
Interfaceslist--
Namingsee Naming Schemes
Spec_SuffixstringNaminginsensitive (language)
Body_SuffixstringNaminginsensitive (language)
Separate_SuffixstringNaming-
CasingstringNaming-
Dot_ReplacementstringNaming-
SpecstringNaminginsensitive (Ada unit)
BodystringNaminginsensitive (Ada unit)
Specification_ExceptionslistNaminginsensitive (language)
Implementation_ExceptionslistNaminginsensitive (language)
Buildingsee Switches and Project Files
Default_SwitcheslistBuilder, Compiler, Binder, Linker, Cross_Reference, Finder, Pretty_Printer, gnatstub, Check, Synchronize, Eliminate, Metrics, IDEinsensitive (language name)
SwitcheslistBuilder, Compiler, Binder, Linker, Cross_Reference, Finder, gnatls, Pretty_Printer, gnatstub, Check, Synchronize, Eliminate, Metrics, Stack[file] (file name)
Local_Configuration_PragmasstringCompiler-
Local_Config_Filestringinsensitive-
Global_Configuration_PragmaslistBuilder-
Global_Compilation_SwitcheslistBuilderlanguage
ExecutablestringBuilder[file]
Executable_SuffixstringBuilder-
Global_Config_FilestringBuilderinsensitive (language)
IDE (used and created by GPS)
Remote_HoststringIDE-
Program_HoststringIDE-
Communication_ProtocolstringIDE-
Compiler_CommandstringIDEinsensitive (language)
Debugger_CommandstringIDE-
GnatliststringIDE-
GnatstringIDE-
VCS_KindstringIDE-
VCS_File_CheckstringIDE-
VCS_Log_CheckstringIDE-
Documentation_DirstringIDE-
Configuration filesSee gprbuild manual
Default_Languagestring--
Run_Path_Optionlist--
Run_Path_Originstring--
Separate_Run_Path_Optionsstring--
Toolchain_Versionstring-insensitive
Toolchain_Descriptionstring-insensitive
Object_Generatedstring-insensitive
Objects_Linkedstring-insensitive
Targetstring--
Library_Builderstring--
Library_Supportstring--
Archive_Builderlist--
Archive_Builder_Append_Optionlist--
Archive_Indexerlist--
Archive_Suffixstring--
Library_Partial_Linkerlist--
Shared_Library_Prefixstring--
Shared_Library_Suffixstring--
Symbolic_Link_Supportedstring--
Library_Major_Minor_Id_Supportedstring--
Library_Auto_Init_Supportedstring--
Shared_Library_Minimum_Switcheslist--
Library_Version_Switcheslist--
Library_Install_Name_Optionstring--
Runtime_Library_Dirstring-insensitive
Runtime_Source_Dirstring-insensitive
DriverstringCompiler,Binder,Linkerinsensitive (language)
Required_SwitcheslistCompiler,Binder,Linkerinsensitive (language)
Leading_Required_SwitcheslistCompilerinsensitive (language)
Trailing_Required_SwitcheslistCompilerinsensitive (language)
Pic_OptionslistCompilerinsensitive (language)
Path_SyntaxstringCompilerinsensitive (language)
Object_File_SuffixstringCompilerinsensitive (language)
Object_File_SwitcheslistCompilerinsensitive (language)
Multi_Unit_SwitcheslistCompilerinsensitive (language)
Multi_Unit_Object_SeparatorstringCompilerinsensitve (language)
Mapping_File_SwitcheslistCompilerinsensitive (language)
Mapping_Spec_SuffixstringCompilerinsensitive (language)
Mapping_body_SuffixstringCompilerinsensitive (language)
Config_File_SwitcheslistCompilerinsensitive (language)
Config_Body_File_NamestringCompilerinsensitive (language)
Config_Body_File_Name_IndexstringCompilerinsensitive (language)
Config_Body_File_Name_PatternstringCompilerinsensitive (language)
Config_Spec_File_NamestringCompilerinsensitive (language)
Config_Spec_File_Name_IndexstringCompilerinsensitive (language)
Config_Spec_File_Name_PatternstringCompilerinsensitive (language)
Config_File_UniquestringCompilerinsensitive (language)
Dependency_SwitcheslistCompilerinsensitive (language)
Dependency_DriverlistCompilerinsensitive (language)
Include_SwitcheslistCompilerinsensitive (language)
Include_PathstringCompilerinsensitive (language)
Include_Path_FilestringCompilerinsensitive (language)
PrefixstringBinderinsensitive (language)
Objects_PathstringBinderinsensitive (language)
Objects_Path_FilestringBinderinsensitive (language)
Linker_OptionslistLinker-
Leading_SwitcheslistLinker-
Map_File_OptionsstringLinker-
Executable_SwitcheslistLinker-
Lib_Dir_SwitchstringLinker-
Lib_Name_SwitchstringLinker-
Max_Command_Line_LengthstringLinker-
Response_File_FormatstringLinker-
Response_File_SwitcheslistLinker-