Next: , Previous: External References in Project Files, Up: GNAT Project Manager


10.8 Packages in Project Files

The package is the project file feature that defines the settings for project-aware tools. For each such tool you can declare a corresponding package; the names for these packages are preset (see Packages) but are not case sensitive. A package may contain variable declarations, attribute declarations, and case constructions.

        project Proj is
           package Builder is  -- used by gnatmake
              for Default_Switches ("Ada") use ("-v", "-g");
           end Builder;
        end Proj;

A package declaration starts with the reserved word package, followed by the package name (case insensitive), followed by the reserved word is. It ends with the reserved word end, followed by the package name, finally followed by a semi-colon.

Most of the packages have an attribute Default_Switches. This attribute is an associative array, and its value is a string list. The index of the associative array is the name of a programming language (case insensitive). This attribute indicates the switch or switches to be used with the corresponding tool.

Some packages also have another attribute, Switches, an associative array whose value is a string list. The index is the name of a source file. This attribute indicates the switch or switches to be used by the corresponding tool when dealing with this specific file.

Further information on these switch-related attributes is found in Switches and Project Files.

A package may be declared as a renaming of another package; e.g., from the project file for an imported project.

       with "/global/apex.gpr";
       project Example is
         package Naming renames Apex.Naming;
         ...
       end Example;

Packages that are renamed in other project files often come from project files that have no sources: they are just used as templates. Any modification in the template will be reflected automatically in all the project files that rename a package from the template.

In addition to the tool-oriented packages, you can also declare a package named Naming to establish specialized source file naming conventions (see Naming Schemes).