A compilation unit in a source file in one project may depend on compilation
units in source files in other projects. To compile this unit under
control of a project file, the
dependent project must import the projects containing the needed source
This effect is obtained using syntax similar to an Ada
withed entities are strings that denote project files.
As an example, suppose that the two projects
Comm_Proj are defined in the project files gui_proj.gpr and
comm_proj.gpr in directories /gui
and /comm, respectively.
Suppose that the source files for
gui.ads and gui.adb, and that the source files for
Comm_Proj are comm.ads and comm.adb, where each set of
files is located in its respective project file directory. Schematically:
/gui gui_proj.gpr gui.ads gui.adb /comm comm_proj.gpr comm.ads comm.adb
We want to develop an application in directory /app that
with the packages
Comm, using the properties of
the corresponding project files (e.g. the switch settings
and object directory).
Skeletal code for a main procedure might be something like the following:
with GUI, Comm; procedure App_Main is ... begin ... end App_Main;
Here is a project file, app_proj.gpr, that achieves the desired effect:
with "/gui/gui_proj", "/comm/comm_proj"; project App_Proj is for Main use ("app_main"); end App_Proj;
Building an executable is achieved through the command:
which will generate the
in the directory where app_proj.gpr resides.
If an imported project file uses the standard extension (
(as illustrated above) the
with clause can omit the extension.
Our example specified an absolute path for each imported project file. Alternatively, the directory name of an imported object can be omitted if either
ADA_PROJECT_PATHis the same as the syntax of
ADA_OBJECTS_PATH: a list of directory names separated by colons (semicolons on Windows).
Thus, if we define
to include /gui and
/comm, then our project file app_proj.gpr can be written
with "gui_proj", "comm_proj"; project App_Proj is for Main use ("app_main"); end App_Proj;
Importing other projects can create ambiguities. For example, the same unit might be present in different imported projects, or it might be present in both the importing project and in an imported project. Both of these conditions are errors. Note that in the current version of the Project Manager, it is illegal to have an ambiguous unit even if the unit is never referenced by the importing project. This restriction may be relaxed in a future release.