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


11.9 Packages in Project Files

A package defines the settings for project-aware tools within a project. For each such tool one can declare a package; the names for these packages are preset (see Packages). 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;

The syntax of package declarations mimics that of package in Ada.

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).