When the same projec is imported by several projects in the project tree through different paths that includes symbolic links, the Project Manager may reported an error indicating that two different projects have the same name. This is corrected by this patch.
Tested on x86_64-pc-linux-gnu, committed on trunk 2014-02-19 Vincent Celier <cel...@adacore.com> * prj-part.adb (Parse_Single_Project): Use the fully resolved project path, with all symbolic links resolved, to check if the same project is imported with a different unresolved path. * prj-tree.ads (Project_Name_And_Node): Component Canonical_Path changed to Resolved_Path to reflect that all symbolic links are resolved.
Index: prj-part.adb =================================================================== --- prj-part.adb (revision 207879) +++ prj-part.adb (working copy) @@ -1126,8 +1126,8 @@ if Project_Qualifier_Of (Imported, In_Tree) = Aggregate then Error_Msg_Name_1 := Name_Id (Path_Name_Of (Imported, In_Tree)); - Error_Msg - (Flags, "cannot import aggregate project %%", Token_Ptr); + Error_Msg + (Flags, "cannot import aggregate project %%", Token_Ptr); exit; end if; @@ -1280,6 +1280,7 @@ Normed_Path_Name : Path_Name_Type; Canonical_Path_Name : Path_Name_Type; + Resolved_Path_Name : Path_Name_Type; Project_Directory : Path_Name_Type; Project_Scan_State : Saved_Project_Scan_State; Source_Index : Source_File_Index; @@ -1329,6 +1330,20 @@ Name_Len := Canonical_Path'Length; Name_Buffer (1 .. Name_Len) := Canonical_Path; Canonical_Path_Name := Name_Find; + + if Opt.Follow_Links_For_Files then + Resolved_Path_Name := Canonical_Path_Name; + + else + Name_Len := 0; + Add_Str_To_Name_Buffer + (Normalize_Pathname + (Canonical_Path, + Resolve_Links => True, + Case_Sensitive => False)); + Resolved_Path_Name := Name_Find; + end if; + end; if Has_Circular_Dependencies @@ -1351,7 +1366,7 @@ while A_Project_Name_And_Node /= Tree_Private_Part.No_Project_Name_And_Node loop - if A_Project_Name_And_Node.Canonical_Path = Canonical_Path_Name then + if A_Project_Name_And_Node.Resolved_Path = Resolved_Path_Name then if Extended then if A_Project_Name_And_Node.Extended then @@ -1773,6 +1788,17 @@ if Present (Extended_Project) then + if Project_Qualifier_Of (Extended_Project, In_Tree) = + Aggregate + then + Error_Msg_Name_1 := + Name_Id (Path_Name_Of (Extended_Project, In_Tree)); + Error_Msg + (Env.Flags, + "cannot extend aggregate project %%", + Location_Of (Project, In_Tree)); + end if; + -- A project that extends an extending-all project is -- also an extending-all project. @@ -1987,7 +2013,7 @@ E => (Name => Name_Of_Project, Display_Name => Display_Name_Of_Project, Node => Project, - Canonical_Path => Canonical_Path_Name, + Resolved_Path => Resolved_Path_Name, Extended => Extended, From_Extended => From_Extended /= None, Proj_Qualifier => Project_Qualifier_Of (Project, In_Tree))); Index: prj-tree.adb =================================================================== --- prj-tree.adb (revision 207893) +++ prj-tree.adb (working copy) @@ -2922,7 +2922,7 @@ Prj.Tree.Tree_Private_Part.Project_Name_And_Node' (Name => Name, Display_Name => Name, - Canonical_Path => No_Path, + Resolved_Path => No_Path, Node => Project, Extended => False, From_Extended => False, Index: prj-tree.ads =================================================================== --- prj-tree.ads (revision 207879) +++ prj-tree.ads (working copy) @@ -1469,7 +1469,7 @@ Node : Project_Node_Id; -- Node of the project in table Project_Nodes - Canonical_Path : Path_Name_Type; + Resolved_Path : Path_Name_Type; -- Resolved and canonical path of a real project file. -- No_Name in case of virtual projects. @@ -1488,7 +1488,7 @@ (Name => No_Name, Display_Name => No_Name, Node => Empty_Node, - Canonical_Path => No_Path, + Resolved_Path => No_Path, Extended => True, From_Extended => False, Proj_Qualifier => Unspecified);