Next: , Previous: Project Dependencies, Up: Organizing Projects into Subsystems

11.3.2 Cyclic Project Dependencies

Cyclic dependencies are mostly forbidden: if A imports B (directly or indirectly) then B is not allowed to import A. However, there are cases when cyclic dependencies would be beneficial. For these cases, another form of import between projects exists: the limited with. A project A that imports a project B with a straight with may also be imported, directly or indirectly, by B through a limited with.

The difference between straight with and limited with is that the name of a project imported with a limited with cannot be used in the project importing it. In particular, its packages cannot be renamed and its variables cannot be referred to.

     with "b.gpr";
     with "c.gpr";
     project A is
         For Exec_Dir use B'Exec_Dir; -- ok
     end A;
     limited with "a.gpr";   --  Cyclic dependency: A -> B -> A
     project B is
        For Exec_Dir use A'Exec_Dir; -- not ok
     end B;
     with "d.gpr";
     project C is
     end C;
     limited with "a.gpr";  --  Cyclic dependency: A -> C -> D -> A
     project D is
        For Exec_Dir use A'Exec_Dir; -- not ok
     end D;