Next: , Previous: Variables from Imported Projects, Up: GNAT Project Manager


11.10 Naming Schemes

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
This must be a string with one of the three values "lowercase", "uppercase" or "mixedcase"; these strings are case insensitive.

If Casing is not specified, then the default is "lowercase".

Dot_Replacement
This must be a string whose value satisfies the following conditions:

If Dot_Replacement is not specified, then the default is "-".

Spec_Suffix
This is an associative array (indexed by the programming language name, case insensitive) whose value is a string that must satisfy the following conditions: If Spec_Suffix ("Ada") is not specified, then the default is ".ads".
Body_Suffix
This is an associative array (indexed by the programming language name, case insensitive) whose value is a string that must satisfy the following conditions: If Body_Suffix ("Ada") is not specified, then the default is ".adb".
Separate_Suffix
This must be a string whose value satisfies the same conditions as Body_Suffix.

If Separate_Suffix ("Ada") is not specified, then it defaults to same value as Body_Suffix ("Ada").

Spec
You can use the associative array attribute 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";
     

Body
You can use the associative array attribute 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";