diff mbox

[Ada] Straigthen implementation of aggregate libraries

Message ID 20111223093701.GA29619@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Dec. 23, 2011, 9:37 a.m. UTC
Handle case where the same library project is imported by multiple
aggregated libraries.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-12-23  Pascal Obry  <obry@adacore.com>

	* prj.ads (For_Every_Project_Imported): Add In_Aggregate_Lib
	parameter to generic formal procedure.
	* prj.adb (For_Every_Project_Imported): Update accordingly.
	(Recursive_Check): Likewise. Do not parse imported project for
	aggregate library. This is needed as the imported projects are
	there just to handle dependencies.
	(Look_For_Sources): Likewise.
	(Recursive_Add): Likewise.
	* prj-env.adb, prj-conf.adb, makeutl.adb, gnatcmd.adb:
	Add In_Aggregate_Lib parameter to routines used with
	For_Every_Project_Imported generic procedure.
	* prj-nmsc.adb (Tree_Processing_Data): Add In_Aggregate_Lib
	field.
	(Check): Move where it is used. Fix implementation
	to not check libraries that are inside aggregate libraries.
	(Recursive_Check): Add In_Aggregate_Lib parameter.
diff mbox

Patch

Index: gnatcmd.adb
===================================================================
--- gnatcmd.adb	(revision 182655)
+++ gnatcmd.adb	(working copy)
@@ -264,6 +264,7 @@ 
    procedure Set_Library_For
      (Project           : Project_Id;
       Tree              : Project_Tree_Ref;
+      In_Aggregate_Lib  : Boolean;
       Libraries_Present : in out Boolean);
    --  If Project is a library project, add the correct -L and -l switches to
    --  the linker invocation.
@@ -1264,9 +1265,10 @@ 
    procedure Set_Library_For
      (Project           : Project_Id;
       Tree              : Project_Tree_Ref;
+      In_Aggregate_Lib  : Boolean;
       Libraries_Present : in out Boolean)
    is
-      pragma Unreferenced (Tree);
+      pragma Unreferenced (Tree, In_Aggregate_Lib);
 
       Path_Option : constant String_Access :=
                       MLib.Linker_Library_Path_Option;
Index: prj.adb
===================================================================
--- prj.adb	(revision 182655)
+++ prj.adb	(working copy)
@@ -528,20 +528,24 @@ 
       Seen : Project_Boolean_Htable.Instance := Project_Boolean_Htable.Nil;
 
       procedure Recursive_Check
-        (Project : Project_Id;
-         Tree    : Project_Tree_Ref);
-      --  Check if a project has already been seen. If not seen, mark it as
-      --  Seen, Call Action, and check all its imported projects.
+        (Project          : Project_Id;
+         Tree             : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean);
+      --  Check if a project has already been seen. If not seen, mark it
+      --  as Seen, Call Action, and check all its imported and aggregated
+      --  projects.
 
       ---------------------
       -- Recursive_Check --
       ---------------------
 
       procedure Recursive_Check
-        (Project : Project_Id;
-         Tree    : Project_Tree_Ref)
+        (Project          : Project_Id;
+         Tree             : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean)
       is
          List : Project_List;
+         T    : Project_Tree_Ref;
 
       begin
          if not Get (Seen, Project) then
@@ -552,22 +556,28 @@ 
             Set (Seen, Project, True);
 
             if not Imported_First then
-               Action (Project, Tree, With_State);
+               Action (Project, Tree, In_Aggregate_Lib, With_State);
             end if;
 
             --  Visit all extended projects
 
             if Project.Extends /= No_Project then
-               Recursive_Check (Project.Extends, Tree);
+               Recursive_Check (Project.Extends, Tree, In_Aggregate_Lib);
             end if;
 
-            --  Visit all imported projects
+            --  Visit all imported projects if needed. This is not needed
+            --  for an aggregate library as imported libraries are just
+            --  there for dependency support.
 
-            List := Project.Imported_Projects;
-            while List /= null loop
-               Recursive_Check (List.Project, Tree);
-               List := List.Next;
-            end loop;
+            if Project.Qualifier /= Aggregate_Library
+              or else not Include_Aggregated
+            then
+               List := Project.Imported_Projects;
+               while List /= null loop
+                  Recursive_Check (List.Project, Tree, In_Aggregate_Lib);
+                  List := List.Next;
+               end loop;
+            end if;
 
             --  Visit all aggregated projects
 
@@ -580,14 +590,25 @@ 
                   Agg := Project.Aggregated_Projects;
                   while Agg /= null loop
                      pragma Assert (Agg.Project /= No_Project);
-                     Recursive_Check (Agg.Project, Agg.Tree);
+
+                     --  For aggregated libraries, the tree must be the one
+                     --  of the aggregate library.
+
+                     if Project.Qualifier = Aggregate_Library then
+                        T := Tree;
+                     else
+                        T := Agg.Tree;
+                     end if;
+
+                     Recursive_Check
+                       (Agg.Project, T, Project.Qualifier = Aggregate_Library);
                      Agg := Agg.Next;
                   end loop;
                end;
             end if;
 
             if Imported_First then
-               Action (Project, Tree, With_State);
+               Action (Project, Tree, In_Aggregate_Lib, With_State);
             end if;
          end if;
       end Recursive_Check;
@@ -595,7 +616,7 @@ 
    --  Start of processing for For_Every_Project_Imported
 
    begin
-      Recursive_Check (Project => By, Tree => Tree);
+      Recursive_Check (Project => By, Tree => Tree, In_Aggregate_Lib => False);
       Reset (Seen);
    end For_Every_Project_Imported;
 
@@ -614,9 +635,10 @@ 
       Result : Source_Id  := No_Source;
 
       procedure Look_For_Sources
-        (Proj : Project_Id;
-         Tree : Project_Tree_Ref;
-         Src  : in out Source_Id);
+        (Proj         : Project_Id;
+         Tree         : Project_Tree_Ref;
+         In_Aggregate : Boolean;
+         Src          : in out Source_Id);
       --  Look for Base_Name in the sources of Proj
 
       ----------------------
@@ -624,10 +646,13 @@ 
       ----------------------
 
       procedure Look_For_Sources
-        (Proj : Project_Id;
-         Tree : Project_Tree_Ref;
-         Src  : in out Source_Id)
+        (Proj         : Project_Id;
+         Tree         : Project_Tree_Ref;
+         In_Aggregate : Boolean;
+         Src          : in out Source_Id)
       is
+         pragma Unreferenced (In_Aggregate);
+
          Iterator : Source_Iterator;
 
       begin
@@ -662,14 +687,14 @@ 
       if In_Extended_Only then
          Proj := Project;
          while Proj /= No_Project loop
-            Look_For_Sources (Proj, In_Tree, Result);
+            Look_For_Sources (Proj, In_Tree, False, Result);
             exit when Result /= No_Source;
 
             Proj := Proj.Extends;
          end loop;
 
       elsif In_Imported_Only then
-         Look_For_Sources (Project, In_Tree, Result);
+         Look_For_Sources (Project, In_Tree, False, Result);
 
          if Result = No_Source then
             For_Imported_Projects
@@ -680,7 +705,7 @@ 
          end if;
 
       else
-         Look_For_Sources (No_Project, In_Tree, Result);
+         Look_For_Sources (No_Project, In_Tree, False, Result);
       end if;
 
       return Result;
@@ -1365,9 +1390,10 @@ 
          Project : Project_Id;
 
          procedure Recursive_Add
-           (Prj   : Project_Id;
-            Tree  : Project_Tree_Ref;
-            Dummy : in out Boolean);
+           (Prj              : Project_Id;
+            Tree             : Project_Tree_Ref;
+            In_Aggregate_Lib : Boolean;
+            Dummy            : in out Boolean);
          --  Recursively add the projects imported by project Project, but not
          --  those that are extended.
 
@@ -1376,11 +1402,13 @@ 
          -------------------
 
          procedure Recursive_Add
-           (Prj   : Project_Id;
-            Tree  : Project_Tree_Ref;
-            Dummy : in out Boolean)
+           (Prj              : Project_Id;
+            Tree             : Project_Tree_Ref;
+            In_Aggregate_Lib : Boolean;
+            Dummy            : in out Boolean)
          is
-            pragma Unreferenced (Dummy, Tree);
+            pragma Unreferenced (Dummy, Tree, In_Aggregate_Lib);
+
             List : Project_List;
             Prj2 : Project_Id;
 
Index: prj.ads
===================================================================
--- prj.ads	(revision 182654)
+++ prj.ads	(working copy)
@@ -1562,9 +1562,10 @@ 
    generic
       type State is limited private;
       with procedure Action
-        (Project    : Project_Id;
-         Tree       : Project_Tree_Ref;
-         With_State : in out State);
+        (Project          : Project_Id;
+         Tree             : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         With_State       : in out State);
    procedure For_Every_Project_Imported
      (By                 : Project_Id;
       Tree               : Project_Tree_Ref;
@@ -1589,8 +1590,10 @@ 
    --
    --  If Include_Aggregated is True, then an aggregate project will recurse
    --  into the projects it aggregates. Otherwise, the latter are never
-   --  returned
+   --  returned.
    --
+   --  In_Aggregate_Lib is True if the project is in an aggregate library
+   --
    --  The Tree argument passed to the callback is required in the case of
    --  aggregated projects, since they might not be using the same tree as 'By'
 
Index: makeutl.adb
===================================================================
--- makeutl.adb	(revision 182654)
+++ makeutl.adb	(working copy)
@@ -692,9 +692,10 @@ 
    is
 
       procedure Recursive_Add
-        (Project  : Project_Id;
-         Tree     : Project_Tree_Ref;
-         Extended : in out Boolean);
+        (Project          : Project_Id;
+         Tree             : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Extended         : in out Boolean);
       --  Add all the source directories of a project to the path only if
       --  this project has not been visited. Calls itself recursively for
       --  projects being extended, and imported projects.
@@ -731,14 +732,18 @@ 
       -------------------
 
       procedure Recursive_Add
-        (Project  : Project_Id;
-         Tree     : Project_Tree_Ref;
-         Extended : in out Boolean)
+        (Project          : Project_Id;
+         Tree             : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Extended         : in out Boolean)
       is
+         pragma Unreferenced (In_Aggregate_Lib);
+
          Current   : String_List_Id;
          Dir       : String_Element;
          OK        : Boolean := False;
          Lang_Proc : Language_Ptr := Project.Languages;
+
       begin
          --  Add to path all directories of this project
 
@@ -1229,9 +1234,10 @@ 
       In_Tree  : Project_Tree_Ref) return String_List
    is
       procedure Recursive_Add
-        (Proj    : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean);
+        (Proj             : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean);
       --  The recursive routine used to add linker options
 
       -------------------
@@ -1239,11 +1245,12 @@ 
       -------------------
 
       procedure Recursive_Add
-        (Proj    : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean)
+        (Proj             : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean)
       is
-         pragma Unreferenced (Dummy);
+         pragma Unreferenced (Dummy, In_Aggregate_Lib);
 
          Linker_Package : Package_Id;
          Options        : Variable_Value;
Index: prj-nmsc.adb
===================================================================
--- prj-nmsc.adb	(revision 182655)
+++ prj-nmsc.adb	(working copy)
@@ -151,9 +151,10 @@ 
    --  be discarded as soon as we have finished processing the project
 
    type Tree_Processing_Data is record
-      Tree      : Project_Tree_Ref;
-      Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
-      Flags     : Prj.Processing_Flags;
+      Tree             : Project_Tree_Ref;
+      Node_Tree        : Prj.Tree.Project_Node_Tree_Ref;
+      Flags            : Prj.Processing_Flags;
+      In_Aggregate_Lib : Boolean;
    end record;
    --  Temporary data which is needed while parsing a project. It does not need
    --  to be kept in memory once a project has been fully loaded, but is
@@ -185,11 +186,6 @@ 
    procedure Free (Data : in out Tree_Processing_Data);
    --  Free the memory occupied by Data
 
-   procedure Check
-     (Project : Project_Id;
-      Data    : in out Tree_Processing_Data);
-   --  Process the naming scheme for a single project
-
    procedure Initialize
      (Data    : in out Project_Processing_Data;
       Project : Project_Id);
@@ -728,6 +724,7 @@ 
          elsif Prev_Unit /= No_Unit_Index
            and then Prev_Unit.File_Names (Kind) /= null
            and then not Source.Locally_Removed
+           and then not Data.In_Aggregate_Lib
          then
             --  Path is set if this is a source we found on the disk, in which
             --  case we can provide more explicit error message. Path is unset
@@ -765,6 +762,7 @@ 
            and then not Data.Flags.Allow_Duplicate_Basenames
            and then Lang_Id.Config.Kind = Unit_Based
            and then Source.Language.Config.Kind = Unit_Based
+           and then not Data.In_Aggregate_Lib
          then
             Error_Msg_File_1 := File_Name;
             Error_Msg_File_2 := File_Name_Type (Source.Project.Name);
@@ -924,9 +922,10 @@ 
       Flags     : Processing_Flags)
    is
       Data : Tree_Processing_Data :=
-               (Tree      => Tree,
-                Node_Tree => Node_Tree,
-                Flags     => Flags);
+               (Tree             => Tree,
+                Node_Tree        => Node_Tree,
+                Flags            => Flags,
+                In_Aggregate_Lib => False);
 
       Project_Files : constant Prj.Variable_Value :=
                         Prj.Util.Value_Of
@@ -1012,132 +1011,6 @@ 
       Free (Project_Path_For_Aggregate);
    end Process_Aggregated_Projects;
 
-   -----------
-   -- Check --
-   -----------
-
-   procedure Check
-     (Project : Project_Id;
-      Data    : in out Tree_Processing_Data)
-   is
-      procedure Check_Aggregate
-        (Project : Project_Id;
-         Data    : in out Tree_Processing_Data);
-      --  Check the aggregate project attributes, reject any not supported
-      --  attributes.
-
-      ---------------------
-      -- Check_Aggregate --
-      ---------------------
-
-      procedure Check_Aggregate
-        (Project : Project_Id;
-         Data    : in out Tree_Processing_Data)
-      is
-         procedure Check_Not_Defined (Name : Name_Id);
-         --  Report an error if Var is defined
-
-         -----------------------
-         -- Check_Not_Defined --
-         -----------------------
-
-         procedure Check_Not_Defined (Name : Name_Id) is
-            Var : constant Prj.Variable_Value :=
-                    Prj.Util.Value_Of
-                      (Name,
-                       Project.Decl.Attributes,
-                       Data.Tree.Shared);
-         begin
-            if not Var.Default then
-               Error_Msg_Name_1 := Name;
-               Error_Msg
-                 (Data.Flags, "wrong attribute %% in aggregate library",
-                  Var.Location, Project);
-            end if;
-         end Check_Not_Defined;
-
-      --  Start of processing for Check_Not_Defined
-
-      begin
-         Check_Not_Defined (Snames.Name_Library_Dir);
-         Check_Not_Defined (Snames.Name_Library_Interface);
-         Check_Not_Defined (Snames.Name_Library_Name);
-         Check_Not_Defined (Snames.Name_Library_Ali_Dir);
-         Check_Not_Defined (Snames.Name_Library_Src_Dir);
-         Check_Not_Defined (Snames.Name_Library_Options);
-         Check_Not_Defined (Snames.Name_Library_Standalone);
-         Check_Not_Defined (Snames.Name_Library_Kind);
-         Check_Not_Defined (Snames.Name_Leading_Library_Options);
-         Check_Not_Defined (Snames.Name_Library_Version);
-      end Check_Aggregate;
-
-      Shared   : constant Shared_Project_Tree_Data_Access := Data.Tree.Shared;
-      Prj_Data : Project_Processing_Data;
-
-   begin
-      Debug_Increase_Indent ("check", Project.Name);
-
-      Initialize (Prj_Data, Project);
-
-      Check_If_Externally_Built (Project, Data);
-
-      case Project.Qualifier is
-         when Aggregate =>
-            null;
-
-         when Aggregate_Library =>
-            if Project.Object_Directory = No_Path_Information then
-               Project.Object_Directory := Project.Directory;
-            end if;
-
-         when others =>
-            Get_Directories (Project, Data);
-            Check_Programming_Languages (Project, Data);
-
-            if Current_Verbosity = High then
-               Show_Source_Dirs (Project, Shared);
-            end if;
-
-            if Project.Qualifier = Dry then
-               Check_Abstract_Project (Project, Data);
-            end if;
-      end case;
-
-      --  Check configuration. This must be done even for gnatmake (even though
-      --  no user configuration file was provided) since the default config we
-      --  generate indicates whether libraries are supported for instance.
-
-      Check_Configuration (Project, Data);
-
-      --  For aggregate project checks that no library attributes are defined
-
-      if Project.Qualifier = Aggregate then
-         Check_Aggregate (Project, Data);
-
-      else
-         Check_Library_Attributes (Project, Data);
-         Check_Package_Naming (Project, Data);
-
-         --  An aggregate library has no source, no need to look for them
-
-         if Project.Qualifier /= Aggregate_Library then
-            Look_For_Sources (Prj_Data, Data);
-         end if;
-
-         Check_Interfaces (Project, Data);
-
-         if Project.Library then
-            Check_Stand_Alone_Library (Project, Data);
-         end if;
-
-         Get_Mains (Project, Data);
-      end if;
-
-      Free (Prj_Data);
-
-      Debug_Decrease_Indent ("done check");
-   end Check;
-
    ----------------------------
    -- Check_Abstract_Project --
    ----------------------------
@@ -3219,7 +3092,7 @@ 
                      Lib_Name.Location, Project);
                end if;
 
-            when Library =>
+            when Library | Aggregate_Library =>
                if not Project.Library then
                   if Project.Library_Name = No_Name then
                      Error_Msg
@@ -3579,7 +3452,7 @@ 
          end loop;
       end if;
 
-      if Project.Library then
+      if Project.Library and not Data.In_Aggregate_Lib then
 
          --  Record the library name
 
@@ -8313,20 +8186,163 @@ 
       Node_Tree    : Prj.Tree.Project_Node_Tree_Ref;
       Flags        : Processing_Flags)
    is
+
+      procedure Check
+        (Project          : Project_Id;
+         In_Aggregate_Lib : Boolean;
+         Data             : in out Tree_Processing_Data);
+      --  Process the naming scheme for a single project
+
       procedure Recursive_Check
-        (Project  : Project_Id;
-         Prj_Tree : Project_Tree_Ref;
-         Data     : in out Tree_Processing_Data);
+        (Project          : Project_Id;
+         Prj_Tree         : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Data             : in out Tree_Processing_Data);
       --  Check_Naming_Scheme for the project
 
+      -----------
+      -- Check --
+      -----------
+
+      procedure Check
+        (Project          : Project_Id;
+         In_Aggregate_Lib : Boolean;
+         Data             : in out Tree_Processing_Data)
+      is
+         procedure Check_Aggregate
+           (Project : Project_Id;
+            Data    : in out Tree_Processing_Data);
+         --  Check the aggregate project attributes, reject any not supported
+         --  attributes.
+
+         ---------------------
+         -- Check_Aggregate --
+         ---------------------
+
+         procedure Check_Aggregate
+           (Project : Project_Id;
+            Data    : in out Tree_Processing_Data)
+         is
+
+            procedure Check_Not_Defined (Name : Name_Id);
+            --  Report an error if Var is defined
+
+            -----------------------
+            -- Check_Not_Defined --
+            -----------------------
+
+            procedure Check_Not_Defined (Name : Name_Id) is
+               Var : constant Prj.Variable_Value :=
+                       Prj.Util.Value_Of
+                         (Name,
+                          Project.Decl.Attributes,
+                          Data.Tree.Shared);
+            begin
+               if not Var.Default then
+                  Error_Msg_Name_1 := Name;
+                  Error_Msg
+                    (Data.Flags, "wrong attribute %% in aggregate library",
+                     Var.Location, Project);
+               end if;
+            end Check_Not_Defined;
+
+         begin
+            Check_Not_Defined (Snames.Name_Library_Dir);
+            Check_Not_Defined (Snames.Name_Library_Interface);
+            Check_Not_Defined (Snames.Name_Library_Name);
+            Check_Not_Defined (Snames.Name_Library_Ali_Dir);
+            Check_Not_Defined (Snames.Name_Library_Src_Dir);
+            Check_Not_Defined (Snames.Name_Library_Options);
+            Check_Not_Defined (Snames.Name_Library_Standalone);
+            Check_Not_Defined (Snames.Name_Library_Kind);
+            Check_Not_Defined (Snames.Name_Leading_Library_Options);
+            Check_Not_Defined (Snames.Name_Library_Version);
+         end Check_Aggregate;
+
+         Shared   : constant Shared_Project_Tree_Data_Access :=
+                      Data.Tree.Shared;
+         Prj_Data : Project_Processing_Data;
+
+      --  Start of processing for Check
+
+      begin
+         Debug_Increase_Indent ("check", Project.Name);
+
+         Initialize (Prj_Data, Project);
+
+         Check_If_Externally_Built (Project, Data);
+
+         case Project.Qualifier is
+            when Aggregate =>
+               null;
+
+            when Aggregate_Library =>
+               if Project.Object_Directory = No_Path_Information then
+                  Project.Object_Directory := Project.Directory;
+               end if;
+
+            when others =>
+               Get_Directories (Project, Data);
+               Check_Programming_Languages (Project, Data);
+
+               if Current_Verbosity = High then
+                  Show_Source_Dirs (Project, Shared);
+               end if;
+
+               if Project.Qualifier = Dry then
+                  Check_Abstract_Project (Project, Data);
+               end if;
+         end case;
+
+         --  Check configuration. This must be done even for gnatmake (even
+         --  though no user configuration file was provided) since the default
+         --  config we generate indicates whether libraries are supported for
+         --  instance.
+
+         Check_Configuration (Project, Data);
+
+         --  For aggregate project check no library attributes are defined
+
+         if Project.Qualifier = Aggregate then
+            Check_Aggregate (Project, Data);
+
+         else
+            Check_Library_Attributes (Project, Data);
+            Check_Package_Naming (Project, Data);
+
+            --  An aggregate library has no source, no need to look for them
+
+            if Project.Qualifier /= Aggregate_Library then
+               Look_For_Sources (Prj_Data, Data);
+            end if;
+
+            Check_Interfaces (Project, Data);
+
+            --  If this library is part of an aggregated library don't check it
+            --  as it has no sources by itself and so interface won't be found.
+
+            if Project.Library and not In_Aggregate_Lib then
+               Check_Stand_Alone_Library (Project, Data);
+            end if;
+
+            Get_Mains (Project, Data);
+         end if;
+
+         Free (Prj_Data);
+
+         Debug_Decrease_Indent ("done check");
+      end Check;
+
       ---------------------
       -- Recursive_Check --
       ---------------------
 
       procedure Recursive_Check
-        (Project  : Project_Id;
-         Prj_Tree : Project_Tree_Ref;
-         Data     : in out Tree_Processing_Data) is
+        (Project          : Project_Id;
+         Prj_Tree         : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Data             : in out Tree_Processing_Data)
+      is
       begin
          if Current_Verbosity = High then
             Debug_Increase_Indent
@@ -8334,8 +8350,10 @@ 
          end if;
 
          Data.Tree := Prj_Tree;
-         Prj.Nmsc.Check (Project, Data);
+         Data.In_Aggregate_Lib := In_Aggregate_Lib;
 
+         Check (Project, In_Aggregate_Lib, Data);
+
          if Current_Verbosity = High then
             Debug_Decrease_Indent ("done Processing_Naming_Scheme");
          end if;
@@ -8347,6 +8365,7 @@ 
       Data : Tree_Processing_Data;
 
    --  Start of processing for Process_Naming_Scheme
+
    begin
       Lib_Data_Table.Init;
       Initialize (Data, Tree => Tree, Node_Tree => Node_Tree, Flags => Flags);
Index: prj-conf.adb
===================================================================
--- prj-conf.adb	(revision 182654)
+++ prj-conf.adb	(working copy)
@@ -728,9 +728,10 @@ 
                  Value_Of (Name_Ide, Project.Decl.Packages, Shared);
 
          procedure Add_Config_Switches_For_Project
-           (Project    : Project_Id;
-            Tree       : Project_Tree_Ref;
-            With_State : in out Integer);
+           (Project          : Project_Id;
+            Tree             : Project_Tree_Ref;
+            In_Aggregate_Lib : Boolean;
+            With_State       : in out Integer);
          --  Add all --config switches for this project. This is also called
          --  for aggregate projects.
 
@@ -739,11 +740,13 @@ 
          -------------------------------------
 
          procedure Add_Config_Switches_For_Project
-           (Project    : Project_Id;
-            Tree       : Project_Tree_Ref;
-            With_State : in out Integer)
+           (Project          : Project_Id;
+            Tree             : Project_Tree_Ref;
+            In_Aggregate_Lib : Boolean;
+            With_State       : in out Integer)
          is
-            pragma Unreferenced (With_State);
+            pragma Unreferenced (With_State, In_Aggregate_Lib);
+
             Shared : constant Shared_Project_Tree_Data_Access := Tree.Shared;
 
             Variable      : Variable_Value;
@@ -757,9 +760,8 @@ 
                Variable :=
                  Value_Of (Name_Languages, Project.Decl.Attributes, Shared);
 
-               if Variable = Nil_Variable_Value
-                 or else Variable.Default
-               then
+               if Variable = Nil_Variable_Value or else Variable.Default then
+
                   --  Languages is not declared. If it is not an extending
                   --  project, or if it extends a project with no Languages,
                   --  check for Default_Language.
@@ -792,17 +794,17 @@ 
                         Lang := Name_Find;
                         Language_Htable.Set (Lang, Lang);
 
+                     --  If no default language is declared, default to Ada
+
                      else
-                        --  If no default language is declared, default to Ada
-
                         Language_Htable.Set (Name_Ada, Name_Ada);
                      end if;
                   end if;
 
                elsif Variable.Values /= Nil_String then
 
-                  --  Attribute Languages is declared with a non empty
-                  --  list: put all the languages in Language_HTable.
+                  --  Attribute Languages is declared with a non empty list:
+                  --  put all the languages in Language_HTable.
 
                   List := Variable.Values;
                   while List /= Nil_String loop
Index: prj-env.adb
===================================================================
--- prj-env.adb	(revision 182654)
+++ prj-env.adb	(working copy)
@@ -115,9 +115,10 @@ 
       Buffer_Last : Natural := 0;
 
       procedure Add
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean);
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean);
       --  Add source dirs of Project to the path
 
       ---------
@@ -125,11 +126,12 @@ 
       ---------
 
       procedure Add
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean)
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean)
       is
-         pragma Unreferenced (Dummy);
+         pragma Unreferenced (Dummy, In_Aggregate_Lib);
       begin
          Add_To_Path
            (Project.Source_Dirs, In_Tree.Shared, Buffer, Buffer_Last);
@@ -185,9 +187,10 @@ 
       Buffer_Last : Natural := 0;
 
       procedure Add
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean);
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean);
       --  Add all the object directories of a project to the path
 
       ---------
@@ -195,11 +198,12 @@ 
       ---------
 
       procedure Add
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean)
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean)
       is
-         pragma Unreferenced (Dummy, In_Tree);
+         pragma Unreferenced (Dummy, In_Tree, In_Aggregate_Lib);
 
          Path : constant Path_Name_Type :=
                   Get_Object_Directory
@@ -472,9 +476,10 @@ 
       Current_Naming : Naming_Id;
 
       procedure Check
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         State   : in out Integer);
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         State            : in out Integer);
       --  Recursive procedure that put in the config pragmas file any non
       --  standard naming schemes, if it is not already in the file, then call
       --  itself for any imported project.
@@ -496,11 +501,12 @@ 
       -----------
 
       procedure Check
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         State   : in out Integer)
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         State            : in out Integer)
       is
-         pragma Unreferenced (State);
+         pragma Unreferenced (State, In_Aggregate_Lib);
 
          Lang   : constant Language_Ptr :=
                     Get_Language_From_Name (Project, "ada");
@@ -786,9 +792,10 @@ 
       --  Put the line contained in the Name_Buffer in the global buffer
 
       procedure Process
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         State   : in out Integer);
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         State            : in out Integer);
       --  Generate the mapping file for Project (not recursively)
 
       ---------------------
@@ -811,11 +818,12 @@ 
       -------------
 
       procedure Process
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         State   : in out Integer)
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         State            : in out Integer)
       is
-         pragma Unreferenced (State);
+         pragma Unreferenced (State, In_Aggregate_Lib);
 
          Source : Source_Id;
          Suffix : File_Name_Type;
@@ -1225,9 +1233,10 @@ 
       Tree    : Project_Tree_Ref)
    is
       procedure For_Project
-        (Prj   : Project_Id;
-         Tree  : Project_Tree_Ref;
-         Dummy : in out Integer);
+        (Prj              : Project_Id;
+         Tree             : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Integer);
       --  Get all object directories of Prj
 
       -----------------
@@ -1235,11 +1244,12 @@ 
       -----------------
 
       procedure For_Project
-        (Prj   : Project_Id;
-         Tree  : Project_Tree_Ref;
-         Dummy : in out Integer)
+        (Prj              : Project_Id;
+         Tree             : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Integer)
       is
-         pragma Unreferenced (Dummy, Tree);
+         pragma Unreferenced (Dummy, Tree, In_Aggregate_Lib);
 
       begin
          --  ??? Set_Ada_Paths has a different behavior for library project
@@ -1270,9 +1280,10 @@ 
       In_Tree : Project_Tree_Ref)
    is
       procedure For_Project
-        (Prj     : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Integer);
+        (Prj              : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Integer);
       --  Get all object directories of Prj
 
       -----------------
@@ -1280,11 +1291,12 @@ 
       -----------------
 
       procedure For_Project
-        (Prj     : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Integer)
+        (Prj              : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Integer)
       is
-         pragma Unreferenced (Dummy);
+         pragma Unreferenced (Dummy, In_Aggregate_Lib);
 
          Current    : String_List_Id := Prj.Source_Dirs;
          The_String : String_Element;
@@ -1642,9 +1654,10 @@ 
       Buffer_Last : Natural := 0;
 
       procedure Recursive_Add
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean);
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean);
       --  Recursive procedure to add the source/object paths of extended/
       --  imported projects.
 
@@ -1653,11 +1666,12 @@ 
       -------------------
 
       procedure Recursive_Add
-        (Project : Project_Id;
-         In_Tree : Project_Tree_Ref;
-         Dummy   : in out Boolean)
+        (Project          : Project_Id;
+         In_Tree          : Project_Tree_Ref;
+         In_Aggregate_Lib : Boolean;
+         Dummy            : in out Boolean)
       is
-         pragma Unreferenced (Dummy, In_Tree);
+         pragma Unreferenced (Dummy, In_Tree, In_Aggregate_Lib);
 
          Path : Path_Name_Type;