Next: Library Projects, Previous: Variables from Imported Projects, Up: GNAT Project Manager
Sometimes an Ada software system is ported from a foreign compilation
environment to GNAT, and the file names do not use 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 in your project file.
Note that the use of pragmas described in Alternative File Naming Schemes by mean of a configuration pragmas file is not supported when using project files. You must use the features described in this paragraph. You can however use specify other configuration pragmas (see Specifying Configuration Pragmas).
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;
You can define the following attributes in package Naming
:
Casing
"lowercase"
,
"uppercase"
or "mixedcase"
; these strings are case insensitive.
If Casing
is not specified, then the default is "lowercase"
.
Dot_Replacement
'.'
except if the entire string
is "."
If Dot_Replacement
is not specified, then the default is "-"
.
Spec_Suffix
Spec_Suffix ("Ada")
is not specified, then the default is
".ads"
.
Body_Suffix
Spec_Suffix ("Ada")
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
, a file called Makefile will be part
of the project. This is not interesting in general when using projects to
compile. 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).
If Body_Suffix ("Ada")
is not specified, then the default is
".adb"
.
Separate_Suffix
Body_Suffix
. The same "longest suffix" rules apply.
If Separate_Suffix ("Ada")
is not specified, then it defaults to same
value as Body_Suffix ("Ada")
.
Spec
Spec
to define
the source file name for an individual Ada compilation unit's spec. The array
index must be a string literal that identifies the Ada unit (case insensitive).
The value of this attribute must be a string that identifies the file that
contains this unit's spec (case sensitive or insensitive depending on the
operating system).
for Spec ("MyPack.MyChild") use "mypack.mychild.spec";
When the source file contains several units, you can indicate at what position the unit occurs in the file, with the following. The first unit in the file has index 1
for Body ("top") use "foo.a" at 1; for Body ("foo") use "foo.a" at 2;
Body
Body
to
define the source file name for an individual Ada compilation unit's body
(possibly a subunit). The array index must be a string literal that identifies
the Ada unit (case insensitive). The value of this attribute must be a string
that identifies the file that contains this unit's body or subunit (case
sensitive or insensitive depending on the operating system).
for Body ("MyPack.MyChild") use "mypack.mychild.body";