Next: , Previous: Importing Projects, Up: GNAT Project Manager

10.6 Project Extension

During development of a large system, it is sometimes necessary to use modified versions of some of the source files without changing the original sources. This can be achieved through a facility known as project extension.

        project Modified_Utilities extends "/baseline/utilities.gpr" is ...

The project file for the project being extended (the parent) is identified by the literal string that follows the reserved word extends, which itself follows the name of the extending project (the child).

By default, a child project inherits all the sources of its parent. However, inherited sources can be overridden: a unit with the same name as one in the parent will hide the original unit. Inherited sources are considered to be sources (but not immediate sources) of the child project; see Project File Syntax.

An inherited source file retains any switches specified in the parent project.

For example if the project Utilities contains the specification and the body of an Ada package Util_IO, then the project Modified_Utilities can contain a new body for package Util_IO. The original body of Util_IO will not be considered in program builds. However, the package specification will still be found in the project Utilities.

A child project can have only one parent but it may import any number of other projects.

A project is not allowed to import directly or indirectly at the same time a child project and any of its ancestors.