Sometimes an Ada software system is ported from one compilation environment to another (say GNAT), and the file are not named using the default GNAT conventions. Instead of changing all the file names, which for a variety of reasons might not be possible, you can define the relevant file naming scheme in the Naming package of your project file.
The naming scheme has two distinct goals for the project manager: it allows finding of source files when searching in the source directories, and given a source file name it makes it possible to guess the associated language, and thus the compiler to use.
Note that the use by the Ada compiler of pragmas Source_File_Name is not supported when using project files. You must use the features described in this paragraph. You can however specify other configuration pragmas.
The following attributes can be defined in package Naming
:
"lowercase"
(the default if
unspecified), "uppercase"
or "mixedcase"
. It describes the
casing of file names with regards to the Ada unit name. Given an Ada unit
My_Unit, the file name will respectively be my_unit.adb (lowercase),
MY_UNIT.ADB (uppercase) or My_Unit.adb (mixedcase).
On Windows, file names are case insensitive, so this attribute is
irrelevant.
"-"
so that a unit
Parent.Child
is expected to be found in the file
parent-child.adb. The replacement string must satisfy the following
requirements to avoid ambiguities in the naming scheme:
'.'
except if the entire string
is "."
If the value of the attribute is the empty string, it indicates to the
Project Manager that the only specifications/header files for the language
are those specified with attributes Spec
or
Specification_Exceptions
.
If Spec_Suffix ("Ada")
is not specified, then the default is
"^.ads^.ADS^"
.
A non empty value must satisfy the following requirements:
Dot_Replacement
is a single dot, then it cannot include
more than one dot.
For each language of a project, one of these two attributes need to be specified, either in the project itself or in the configuration project file.
If the value of the attribute is the empty string, it indicates to the
Project Manager that the only source files for the language
are those specified with attributes Body
or
Implementation_Exceptions
.
These attributes must satisfy the same requirements as Spec_Suffix
.
In addition, they must be different from any of the values in
Spec_Suffix
.
If Body_Suffix ("Ada")
is not specified, then the default is
"^.adb^.ADB^"
.
If Body_Suffix ("Ada")
and Spec_Suffix ("Ada")
end with the
same string, then a file name that ends with the longest of these two
suffixes will be a body if the longest suffix is Body_Suffix ("Ada")
or a spec if the longest suffix is Spec_Suffix ("Ada")
.
If the suffix does not start with a '.', a file with a name exactly equal to
the suffix will also be part of the project (for instance if you define the
suffix as Makefile.in
, a file called Makefile.in will be part
of the project. This capability is usually not interesting when building.
However, it might become useful when a project is also used to
find the list of source files in an editor, like the GNAT Programming System
(GPS).
Body_Suffix ("Ada")
.
The value of this attribute cannot be the empty string.
Otherwise, the same rules apply as for the
Body_Suffix
attribute. The only accepted index is "Ada".
Spec
can be used to define the source file name for a
given Ada compilation unit's spec. The index is the literal name of the Ada
unit (case insensitive). The value is the literal base name of the file that
contains this unit's spec (case sensitive or insensitive depending on the
operating system). This attribute allows the definition of exceptions to the
general naming scheme, in case some files do not follow the usual
convention.
When a source file contains several units, the relative position of the unit can be indicated. The first unit in the file is at position 1
for Spec ("MyPack.MyChild") use "mypack.mychild.spec"; for Spec ("top") use "foo.a" at 1; for Spec ("foo") use "foo.a" at 2;
For example, the following package models the Apex file naming rules:
package Naming is for Casing use "lowercase"; for Dot_Replacement use "."; for Spec_Suffix ("Ada") use ".1.ada"; for Body_Suffix ("Ada") use ".2.ada"; end Naming;