Patchwork [Ada] Properly initialize aggregated projects to compute dependencies

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 29, 2011, 1:31 p.m.
Message ID <20110829133116.GA29633@adacore.com>
Download mbox | patch
Permalink /patch/112048/
State New
Headers show

Comments

Arnaud Charlet - Aug. 29, 2011, 1:31 p.m.
Project dependencies are needed in various cases, for instance because
the linker needs to find all the list of non-Ada objects when building
a global archive in gprbuild. But these project dependencies need to be
explicitly computed initially, and this wasn't done for aggregated
projects.

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

2011-08-29  Emmanuel Briot  <briot@adacore.com>

	* make.adb, prj.adb, prj.ads (Compute_All_Imported_Projects): Also
	initialize aggregated projects.

Patch

Index: make.adb
===================================================================
--- make.adb	(revision 178199)
+++ make.adb	(working copy)
@@ -6621,7 +6621,7 @@ 
          Add_Object_Directories (Main_Project, Project_Tree);
 
          Recursive_Compute_Depth (Main_Project);
-         Compute_All_Imported_Projects (Project_Tree);
+         Compute_All_Imported_Projects (Main_Project, Project_Tree);
 
       else
 
Index: prj.adb
===================================================================
--- prj.adb	(revision 178179)
+++ prj.adb	(working copy)
@@ -1283,72 +1283,97 @@ 
    -- Compute_All_Imported_Projects --
    -----------------------------------
 
-   procedure Compute_All_Imported_Projects (Tree : Project_Tree_Ref) is
-      Project : Project_Id;
+   procedure Compute_All_Imported_Projects
+     (Root_Project : Project_Id;
+      Tree         : Project_Tree_Ref)
+   is
+      procedure Analyze_Tree
+        (Local_Root : Project_Id; Local_Tree : Project_Tree_Ref);
+      --  Process Project and all its aggregated project to analyze their own
+      --  imported projects.
 
-      procedure Recursive_Add
-        (Prj   : Project_Id;
-         Tree  : Project_Tree_Ref;
-         Dummy : in out Boolean);
-      --  Recursively add the projects imported by project Project, but not
-      --  those that are extended.
+      ------------------
+      -- Analyze_Tree --
+      ------------------
 
-      -------------------
-      -- Recursive_Add --
-      -------------------
-
-      procedure Recursive_Add
-        (Prj   : Project_Id;
-         Tree  : Project_Tree_Ref;
-         Dummy : in out Boolean)
+      procedure Analyze_Tree
+        (Local_Root : Project_Id; Local_Tree : Project_Tree_Ref)
       is
-         pragma Unreferenced (Dummy, Tree);
-         List    : Project_List;
-         Prj2    : Project_Id;
+         pragma Unreferenced (Local_Root);
 
-      begin
-         --  A project is not importing itself
+         Project : Project_Id;
 
-         Prj2 := Ultimate_Extending_Project_Of (Prj);
+         procedure Recursive_Add
+           (Prj   : Project_Id;
+            Tree  : Project_Tree_Ref;
+            Dummy : in out Boolean);
+         --  Recursively add the projects imported by project Project, but not
+         --  those that are extended.
 
-         if Project /= Prj2 then
+         -------------------
+         -- Recursive_Add --
+         -------------------
 
-            --  Check that the project is not already in the list. We know the
-            --  one passed to Recursive_Add have never been visited before, but
-            --  the one passed it are the extended projects.
+         procedure Recursive_Add
+           (Prj   : Project_Id;
+            Tree  : Project_Tree_Ref;
+            Dummy : in out Boolean)
+         is
+            pragma Unreferenced (Dummy, Tree);
+            List    : Project_List;
+            Prj2    : Project_Id;
 
-            List := Project.All_Imported_Projects;
-            while List /= null loop
-               if List.Project = Prj2 then
-                  return;
-               end if;
+         begin
+            --  A project is not importing itself
 
-               List := List.Next;
-            end loop;
+            Prj2 := Ultimate_Extending_Project_Of (Prj);
 
-            --  Add it to the list
+            if Project /= Prj2 then
 
-            Project.All_Imported_Projects :=
-              new Project_List_Element'
-                (Project => Prj2,
-                 Next    => Project.All_Imported_Projects);
-         end if;
-      end Recursive_Add;
+               --  Check that the project is not already in the list. We know
+               --  the one passed to Recursive_Add have never been visited
+               --  before, but the one passed it are the extended projects.
 
-      procedure For_All_Projects is
-        new For_Every_Project_Imported (Boolean, Recursive_Add);
+               List := Project.All_Imported_Projects;
+               while List /= null loop
+                  if List.Project = Prj2 then
+                     return;
+                  end if;
 
-      Dummy : Boolean := False;
-      List  : Project_List;
+                  List := List.Next;
+               end loop;
 
+               --  Add it to the list
+
+               Project.All_Imported_Projects :=
+                 new Project_List_Element'
+                   (Project => Prj2,
+                    Next    => Project.All_Imported_Projects);
+            end if;
+         end Recursive_Add;
+
+         procedure For_All_Projects is
+           new For_Every_Project_Imported (Boolean, Recursive_Add);
+
+         Dummy   : Boolean := False;
+         List    : Project_List;
+      begin
+         List := Local_Tree.Projects;
+         while List /= null loop
+            Project := List.Project;
+            Free_List
+              (Project.All_Imported_Projects, Free_Project => False);
+            For_All_Projects
+              (Project, Local_Tree, Dummy, Include_Aggregated => False);
+            List := List.Next;
+         end loop;
+      end Analyze_Tree;
+
+      procedure For_Aggregates is
+        new For_Project_And_Aggregated (Analyze_Tree);
+
    begin
-      List := Tree.Projects;
-      while List /= null loop
-         Project := List.Project;
-         Free_List (Project.All_Imported_Projects, Free_Project => False);
-         For_All_Projects (Project, Tree, Dummy, Include_Aggregated => False);
-         List := List.Next;
-      end loop;
+      For_Aggregates (Root_Project, Tree);
    end Compute_All_Imported_Projects;
 
    -------------------
Index: prj.ads
===================================================================
--- prj.ads	(revision 178179)
+++ prj.ads	(working copy)
@@ -909,9 +909,11 @@ 
    --  If Only_If_Ada is True, then No_Name will be returned when the project
    --  doesn't Ada sources.
 
-   procedure Compute_All_Imported_Projects (Tree : Project_Tree_Ref);
+   procedure Compute_All_Imported_Projects
+     (Root_Project : Project_Id;
+      Tree         : Project_Tree_Ref);
    --  For all projects in the tree, compute the list of the projects imported
-   --  directly or indirectly by project Project. The result is stored in
+   --  directly or indirectly by project Root_Project. The result is stored in
    --  Project.All_Imported_Projects for each project
 
    function Ultimate_Extending_Project_Of