diff options
Diffstat (limited to 'gcc/ada/make.adb')
-rw-r--r-- | gcc/ada/make.adb | 660 |
1 files changed, 298 insertions, 362 deletions
diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index bc40cba..0e274e8 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -64,6 +64,7 @@ with Ada.Exceptions; use Ada.Exceptions; with Ada.Command_Line; use Ada.Command_Line; with GNAT.Directory_Operations; use GNAT.Directory_Operations; +with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables; with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.OS_Lib; use GNAT.OS_Lib; @@ -795,32 +796,41 @@ package body Make is -- Mapping files ----------------- - type Temp_Path_Names is - array (Project_Id range <>, Positive range <>) of Path_Name_Type; - + type Temp_Path_Names is array (Positive range <>) of Path_Name_Type; type Temp_Path_Ptr is access Temp_Path_Names; - type Indices is array (Project_Id range <>) of Natural; + type Free_File_Indices is array (Positive range <>) of Positive; + type Free_Indices_Ptr is access Free_File_Indices; - type Indices_Ptr is access Indices; + type Project_Compilation_Data is record + Mapping_File_Names : Temp_Path_Ptr; + -- The name ids of the temporary mapping files used. This is indexed + -- on the maximum number of compilation processes we will be spawning + -- (-j parameter) - type Free_File_Indices is array - (Project_Id range <>, Positive range <>) of Positive; + Last_Mapping_File_Names : Natural; + -- Index of the last mapping file created for this project - type Free_Indices_Ptr is access Free_File_Indices; + Free_Mapping_File_Indices : Free_Indices_Ptr; + -- Indices in Mapping_File_Names of the mapping file names that can be + -- reused for subsequent compilations. - The_Mapping_File_Names : Temp_Path_Ptr; - -- For each project, the name ids of the temporary mapping files used + Last_Free_Indices : Natural; + -- Number of mapping files that can be reused + end record; + -- Information necessary when compiling a project - Last_Mapping_File_Names : Indices_Ptr; - -- For each project, the index of the last mapping file created + type Project_Compilation_Access is access Project_Compilation_Data; - The_Free_Mapping_File_Indices : Free_Indices_Ptr; - -- For each project, the indices in The_Mapping_File_Names of the mapping - -- file names that can be reused for subsequent compilations. + package Project_Compilation_Htable is new Simple_HTable + (Header_Num => Prj.Header_Num, + Element => Project_Compilation_Access, + No_Element => null, + Key => Project_Id, + Hash => Prj.Hash, + Equal => "="); - Last_Free_Indices : Indices_Ptr; - -- For each project, the number of mapping files that can be reused + Project_Compilation : Project_Compilation_Htable.Instance; Gnatmake_Mapping_File : String_Access := null; -- The path name of a mapping file specified by switch -C= @@ -830,7 +840,8 @@ package body Make is -- which ensures that Debug_Flag_N is False. procedure Init_Mapping_File - (Project : Project_Id; + (Project : Project_Id; + Data : in out Project_Compilation_Data; File_Index : in out Natural); -- Create a new temporary mapping file, and fill it with the project file -- mappings, when using project file(s). The out parameter File_Index is @@ -1074,8 +1085,7 @@ package body Make is Add_Lib_Search_Dir (Normalize_Pathname (Path)); else - Get_Name_String - (Project_Tree.Projects.Table (Main_Project).Directory.Display_Name); + Get_Name_String (Main_Project.Directory.Display_Name); Add_Lib_Search_Dir (Normalize_Pathname (Path, Name_Buffer (1 .. Name_Len))); end if; @@ -1126,8 +1136,7 @@ package body Make is Add_Src_Search_Dir (Normalize_Pathname (Path)); else - Get_Name_String - (Project_Tree.Projects.Table (Main_Project).Directory.Display_Name); + Get_Name_String (Main_Project.Directory.Display_Name); Add_Src_Search_Dir (Normalize_Pathname (Path, Name_Buffer (1 .. Name_Len))); end if; @@ -1265,8 +1274,7 @@ package body Make is (Source_File => Name_Find, Source_File_Name => File_Name, Source_Index => Index, - Naming => Project_Tree.Projects.Table - (Main_Project).Naming, + Naming => Main_Project.Naming, In_Package => The_Package, Allow_ALI => Program = Binder or else Program = Linker); @@ -1388,16 +1396,14 @@ package body Make is if Project_Of_Current_Object_Directory /= Actual_Project then Project_Of_Current_Object_Directory := Actual_Project; - Object_Directory := - Project_Tree.Projects.Table (Actual_Project).Object_Directory.Name; + Object_Directory := Actual_Project.Object_Directory.Name; -- Set the working directory to the object directory of the actual -- project. if Verbose_Mode then Write_Str ("Changing to object directory of """); - Write_Name - (Project_Tree.Projects.Table (Actual_Project).Display_Name); + Write_Name (Actual_Project.Display_Name); Write_Str (""": """); Write_Name (Object_Directory); Write_Line (""""); @@ -1412,11 +1418,9 @@ package body Make is when Directory_Error => Make_Failed ("unable to change to object directory """ & Path_Or_File_Name - (Project_Tree.Projects.Table - (Actual_Project).Object_Directory.Name) & + (Actual_Project.Object_Directory.Name) & """ of project " & - Get_Name_String (Project_Tree.Projects.Table - (Actual_Project).Display_Name)); + Get_Name_String (Actual_Project.Display_Name)); end Change_To_Object_Directory; ----------- @@ -1982,13 +1986,10 @@ package body Make is Obj_Dir := Name_Find; - while ALI_Project /= No_Project and then - Obj_Dir /= - Project_Tree.Projects.Table - (ALI_Project).Object_Directory.Name + while ALI_Project /= No_Project + and then Obj_Dir /= ALI_Project.Object_Directory.Name loop - ALI_Project := - Project_Tree.Projects.Table (ALI_Project).Extended_By; + ALI_Project := ALI_Project.Extended_By; end loop; end; @@ -2003,9 +2004,7 @@ package body Make is -- If the ALI project is not extended, then it must be in -- the correct object directory. - if Project_Tree.Projects.Table (ALI_Project).Extended_By = - No_Project - then + if ALI_Project.Extended_By = No_Project then return; end if; @@ -2019,7 +2018,7 @@ package body Make is Num_Ext := 0; Proj := ALI_Project; loop - Proj := Project_Tree.Projects.Table (Proj).Extended_By; + Proj := Proj.Extended_By; exit when Proj = No_Project; Num_Ext := Num_Ext + 1; end loop; @@ -2034,7 +2033,7 @@ package body Make is begin Proj := ALI_Project; for J in Projects'Range loop - Proj := Project_Tree.Projects.Table (Proj).Extended_By; + Proj := Proj.Extended_By; Projects (J) := Proj; end loop; @@ -2328,7 +2327,6 @@ package body Make is Get_Name_String (Source_File); Compiler_Package : Prj.Package_Id; Switches : Prj.Variable_Value; - Data : Project_Data; begin Prj.Env. @@ -2345,20 +2343,19 @@ package body Make is if Arguments_Project = No_Project then Add_Arguments (The_Saved_Gcc_Switches.all); - elsif not Project_Tree.Projects.Table - (Arguments_Project).Externally_Built - then + elsif not Arguments_Project.Externally_Built then -- We get the project directory for the relative path -- switches and arguments. Arguments_Project := Ultimate_Extending_Project_Of - (Arguments_Project, Project_Tree); - Data := Project_Tree.Projects.Table (Arguments_Project); + (Arguments_Project); -- If building a dynamic or relocatable library, compile with -- PIC option, if it exists. - if Data.Library and then Data.Library_Kind /= Static then + if Arguments_Project.Library + and then Arguments_Project.Library_Kind /= Static + then declare PIC : constant String := MLib.Tgt.PIC_Option; @@ -2375,7 +2372,7 @@ package body Make is Compiler_Package := Prj.Util.Value_Of (Name => Name_Compiler, - In_Packages => Data.Decl.Packages, + In_Packages => Arguments_Project.Decl.Packages, In_Tree => Project_Tree); if Compiler_Package /= No_Package then @@ -2389,7 +2386,7 @@ package body Make is (Source_File => Source_File, Source_File_Name => Source_File_Name, Source_Index => Source_Index, - Naming => Data.Naming, + Naming => Arguments_Project.Naming, In_Package => Compiler_Package, Allow_ALI => False); @@ -2418,8 +2415,8 @@ package body Make is declare New_Args : Argument_List (1 .. Number); Last_New : Natural := 0; - Dir_Path : constant String := - Get_Name_String (Data.Directory.Name); + Dir_Path : constant String := Get_Name_String + (Arguments_Project.Directory.Name); begin Current := Switches.Values; @@ -2461,7 +2458,7 @@ package body Make is (1 => new String' (Name_Buffer (1 .. Name_Len))); Dir_Path : constant String := - Get_Name_String (Data.Directory.Name); + Get_Name_String (Arguments_Project.Directory.Name); begin Test_If_Relative_Path @@ -2705,6 +2702,7 @@ package body Make is is Pid : Process_Id; Project : Project_Id; + Data : Project_Compilation_Access; begin pragma Assert (Outstanding_Compiles > 0); @@ -2740,10 +2738,10 @@ package body Make is -- get its file name for reuse by a subsequent compilation if Running_Compile (J).Mapping_File /= No_Mapping_File then - Last_Free_Indices (Project) := - Last_Free_Indices (Project) + 1; - The_Free_Mapping_File_Indices - (Project, Last_Free_Indices (Project)) := + Data := Project_Compilation_Htable.Get + (Project_Compilation, Project); + Data.Last_Free_Indices := Data.Last_Free_Indices + 1; + Data.Free_Mapping_File_Indices (Data.Last_Free_Indices) := Running_Compile (J).Mapping_File; end if; @@ -2853,33 +2851,23 @@ package body Make is -- check for an eventual library project, and use the full path. if Arguments_Project /= No_Project then - if not Project_Tree.Projects.Table - (Arguments_Project).Externally_Built - then + if not Arguments_Project.Externally_Built then Prj.Env.Set_Ada_Paths (Arguments_Project, Project_Tree, True); if not Unique_Compile and then MLib.Tgt.Support_For_Libraries /= Prj.None then declare - The_Data : Project_Data := - Project_Tree.Projects.Table - (Arguments_Project); - - Prj : Project_Id := Arguments_Project; + Prj : constant Project_Id := + Ultimate_Extending_Project_Of (Arguments_Project); begin - while The_Data.Extended_By /= No_Project loop - Prj := The_Data.Extended_By; - The_Data := Project_Tree.Projects.Table (Prj); - end loop; - - if The_Data.Library - and then not The_Data.Externally_Built - and then not The_Data.Need_To_Build_Lib + if Prj.Library + and then not Prj.Externally_Built + and then not Prj.Need_To_Build_Lib then -- Add to the Q all sources of the project that - -- have not been marked + -- have not been marked. Insert_Project_Sources (The_Project => Prj, @@ -2888,8 +2876,7 @@ package body Make is -- Now mark the project as processed - Project_Tree.Projects.Table - (Prj).Need_To_Build_Lib := True; + Prj.Need_To_Build_Lib := True; end if; end; end if; @@ -3130,18 +3117,22 @@ package body Make is ---------------------- procedure Get_Mapping_File (Project : Project_Id) is + Data : Project_Compilation_Access; + begin + Data := Project_Compilation_Htable.Get (Project_Compilation, Project); + -- If there is a mapping file ready to be reused, reuse it - if Last_Free_Indices (Project) > 0 then - Mfile := The_Free_Mapping_File_Indices - (Project, Last_Free_Indices (Project)); - Last_Free_Indices (Project) := Last_Free_Indices (Project) - 1; + if Data.Last_Free_Indices > 0 then + Mfile := Data.Free_Mapping_File_Indices (Data.Last_Free_Indices); + Data.Last_Free_Indices := Data.Last_Free_Indices - 1; -- Otherwise, create and initialize a new one else - Init_Mapping_File (Project => Project, File_Index => Mfile); + Init_Mapping_File + (Project => Project, Data => Data.all, File_Index => Mfile); end if; -- Put the name in the mapping file argument for the invocation @@ -3150,9 +3141,7 @@ package body Make is Free (Mapping_File_Arg); Mapping_File_Arg := new String'("-gnatem=" & - Get_Name_String - (The_Mapping_File_Names (Project, Mfile))); - + Get_Name_String (Data.Mapping_File_Names (Mfile))); end Get_Mapping_File; ----------------------- @@ -3355,8 +3344,7 @@ package body Make is -- Do nothing if project of source is externally built if Arguments_Project = No_Project - or else not Project_Tree.Projects.Table - (Arguments_Project).Externally_Built + or else not Arguments_Project.Externally_Built then -- Don't waste any time if we have to recompile anyway @@ -3748,9 +3736,7 @@ package body Make is else declare Parent_Directory : constant String := - Get_Name_String - (Project_Tree.Projects.Table - (Project).Directory.Display_Name); + Get_Name_String (Project.Directory.Display_Name); begin if Parent_Directory (Parent_Directory'Last) = @@ -3772,18 +3758,12 @@ package body Make is Prj.Env.Create_Config_Pragmas_File (For_Project, Main_Project, Project_Tree); - if Project_Tree.Projects.Table - (For_Project).Config_File_Name /= No_Path - then - Temporary_Config_File := - Project_Tree.Projects.Table (For_Project).Config_File_Temp; + if For_Project.Config_File_Name /= No_Path then + Temporary_Config_File := For_Project.Config_File_Temp; Last := 1; Result (1) := new String' - ("-gnatec=" & - Get_Name_String - (Project_Tree.Projects.Table - (For_Project).Config_File_Name)); + ("-gnatec=" & Get_Name_String (For_Project.Config_File_Name)); else Temporary_Config_File := False; @@ -3791,8 +3771,7 @@ package body Make is -- Check for attribute Builder'Global_Configuration_Pragmas - The_Packages := Project_Tree.Projects.Table - (Main_Project).Decl.Packages; + The_Packages := Main_Project.Decl.Packages; Gnatmake := Prj.Util.Value_Of (Name => Name_Builder, @@ -3835,8 +3814,7 @@ package body Make is -- Check for attribute Compiler'Local_Configuration_Pragmas - The_Packages := - Project_Tree.Projects.Table (For_Project).Decl.Packages; + The_Packages := For_Project.Decl.Packages; Compiler := Prj.Util.Value_Of (Name => Name_Compiler, @@ -3927,21 +3905,29 @@ package body Make is Success : Boolean; pragma Warnings (Off, Success); + Proj : Project_List; + Data : Project_Compilation_Access; + begin -- The caller is responsible for ensuring that Debug_Flag_N is False pragma Assert (not Debug.Debug_Flag_N); - if The_Mapping_File_Names /= null then - for Project in The_Mapping_File_Names'Range (1) loop - for Index in 1 .. Last_Mapping_File_Names (Project) loop + Proj := Project_Tree.Projects; + while Proj /= null loop + Data := Project_Compilation_Htable.Get + (Project_Compilation, Proj.Project); + + if Data /= null and then Data.Mapping_File_Names /= null then + for Index in 1 .. Data.Last_Mapping_File_Names loop Delete_File - (Name => Get_Name_String - (The_Mapping_File_Names (Project, Index)), + (Name => Get_Name_String (Data.Mapping_File_Names (Index)), Success => Success); end loop; - end loop; - end if; + end if; + + Proj := Proj.Next; + end loop; end Delete_Mapping_Files; ------------------------------ @@ -3950,6 +3936,7 @@ package body Make is procedure Delete_Temp_Config_Files is Success : Boolean; + Proj : Project_List; pragma Warnings (Off, Success); begin @@ -3958,24 +3945,17 @@ package body Make is pragma Assert (not Debug.Debug_Flag_N); if Main_Project /= No_Project then - for Project in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - if - Project_Tree.Projects.Table (Project).Config_File_Temp - then + Proj := Project_Tree.Projects; + while Proj /= null loop + if Proj.Project.Config_File_Temp then if Verbose_Mode then Write_Str ("Deleting temp configuration file """); - Write_Str (Get_Name_String - (Project_Tree.Projects.Table - (Project).Config_File_Name)); + Write_Str (Get_Name_String (Proj.Project.Config_File_Name)); Write_Line (""""); end if; Delete_File - (Name => Get_Name_String - (Project_Tree.Projects.Table - (Project).Config_File_Name), + (Name => Get_Name_String (Proj.Project.Config_File_Name), Success => Success); -- Make sure that we don't have a config file for this project, @@ -3983,13 +3963,11 @@ package body Make is -- recreate another config file: we cannot reuse the one that -- we just deleted! - Project_Tree.Projects.Table (Project). - Config_Checked := False; - Project_Tree.Projects.Table (Project). - Config_File_Name := No_Path; - Project_Tree.Projects.Table (Project). - Config_File_Temp := False; + Proj.Project.Config_Checked := False; + Proj.Project.Config_File_Name := No_Path; + Proj.Project.Config_File_Temp := False; end if; + Proj := Proj.Next; end loop; end if; end Delete_Temp_Config_Files; @@ -4247,8 +4225,6 @@ package body Make is Proj : Project_Id := No_Project; -- The project of the current main - Data : Project_Data; - Real_Path : String_Access; begin @@ -4286,25 +4262,23 @@ package body Make is -- is the actual path of a source of a project. if Main /= File_Name then - Data := - Project_Tree.Projects.Table (Main_Project); - Real_Path := Locate_Regular_File (Main & - Body_Suffix_Of (Project_Tree, "ada", Data.Naming), + Body_Suffix_Of + (Project_Tree, "ada", Main_Project.Naming), ""); if Real_Path = null then Real_Path := Locate_Regular_File (Main & - Spec_Suffix_Of (Project_Tree, "ada", Data.Naming), + Spec_Suffix_Of + (Project_Tree, "ada", Main_Project.Naming), ""); end if; if Real_Path = null then - Real_Path := - Locate_Regular_File (Main, ""); + Real_Path := Locate_Regular_File (Main, ""); end if; -- Fail if the file cannot be found @@ -4365,9 +4339,7 @@ package body Make is Make_Failed ("""" & Main & """ is not a source of project " & - Get_Name_String - (Project_Tree.Projects.Table - (Real_Main_Project).Name)); + Get_Name_String (Real_Main_Project.Name)); end if; end if; end if; @@ -4470,12 +4442,8 @@ package body Make is -- extending project obj dir. if ALI_Name /= No_File - and then - Project_Tree.Projects.Table - (ALI_Project).Extended_By = No_Project - and then - Project_Tree.Projects.Table - (ALI_Project).Extends = No_Project + and then ALI_Project.Extended_By = No_Project + and then ALI_Project.Extends = No_Project then -- First check if the ALI file exists. If it does not, -- do not put the unit in the mapping file. @@ -4483,17 +4451,16 @@ package body Make is declare ALI : constant String := Get_Name_String (ALI_Name); - PD : Project_Data renames - Project_Tree.Projects.Table (ALI_Project); begin -- For library projects, use the library directory, -- for other projects, use the object directory. - if PD.Library then - Get_Name_String (PD.Library_Dir.Name); + if ALI_Project.Library then + Get_Name_String (ALI_Project.Library_Dir.Name); else - Get_Name_String (PD.Object_Directory.Name); + Get_Name_String + (ALI_Project.Object_Directory.Name); end if; if Name_Buffer (Name_Len) /= @@ -4623,7 +4590,7 @@ package body Make is -- And the project file cannot be a library project file - elsif Project_Tree.Projects.Table (Main_Project).Library then + elsif Main_Project.Library then Make_Failed ("-B cannot be used for a library project file"); else @@ -4664,7 +4631,7 @@ package body Make is -- cannot be specified on the command line. if Osint.Number_Of_Files /= 0 then - if Project_Tree.Projects.Table (Main_Project).Library + if Main_Project.Library and then not Unique_Compile and then ((not Make_Steps) or else Bind_Only or else Link_Only) then @@ -4691,8 +4658,7 @@ package body Make is end if; declare - Value : String_List_Id := - Project_Tree.Projects.Table (Main_Project).Mains; + Value : String_List_Id := Main_Project.Mains; begin -- The attribute Main is an empty list or not specified, @@ -4701,8 +4667,7 @@ package body Make is if Value = Prj.Nil_String or else Unique_Compile then if (not Make_Steps) or else Compile_Only - or else not Project_Tree.Projects.Table - (Main_Project).Library + or else not Main_Project.Library then -- First make sure that the binder and the linker -- will not be invoked. @@ -4740,13 +4705,10 @@ package body Make is -- all the sources of the project. declare - Data : constant Project_Data := - Project_Tree.Projects.Table (Main_Project); - Languages : constant Variable_Value := Prj.Util.Value_Of (Name_Languages, - Data.Decl.Attributes, + Main_Project.Decl.Attributes, Project_Tree); Current : String_List_Id; @@ -4832,8 +4794,7 @@ package body Make is end if; if Main_Project /= No_Project - and then Project_Tree.Projects.Table - (Main_Project).Externally_Built + and then Main_Project.Externally_Built then Make_Failed ("nothing to do for a main project that is externally built"); @@ -4841,11 +4802,10 @@ package body Make is if Osint.Number_Of_Files = 0 then if Main_Project /= No_Project - and then Project_Tree.Projects.Table (Main_Project).Library + and then Main_Project.Library then if Do_Bind_Step - and then not Project_Tree.Projects.Table - (Main_Project).Standalone_Library + and then not Main_Project.Standalone_Library then Make_Failed ("only stand-alone libraries may be bound"); end if; @@ -4939,9 +4899,7 @@ package body Make is if Main_Project /= No_Project then - if Project_Tree.Projects.Table - (Main_Project).Object_Directory /= No_Path_Information - then + if Main_Project.Object_Directory /= No_Path_Information then -- Change current directory to object directory of main project Project_Of_Current_Object_Directory := No_Project; @@ -4967,8 +4925,7 @@ package body Make is not Unique_Compile); The_Packages : constant Package_Id := - Project_Tree.Projects.Table - (Main_Project).Decl.Packages; + Main_Project.Decl.Packages; Builder_Package : constant Prj.Package_Id := Prj.Util.Value_Of @@ -5316,51 +5273,52 @@ package body Make is if not Unique_Compile and then MLib.Tgt.Support_For_Libraries /= Prj.None then - for Proj in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - if Project_Tree.Projects.Table (Proj).Library then - Project_Tree.Projects.Table - (Proj).Need_To_Build_Lib := - (not MLib.Tgt.Library_Exists_For (Proj, Project_Tree)) - and then (not Project_Tree.Projects.Table - (Proj).Externally_Built); - - if Project_Tree.Projects.Table (Proj).Need_To_Build_Lib then + declare + Proj : Project_List; - -- If there is no object directory, then it will be - -- impossible to build the library. So fail immediately. + begin + Proj := Project_Tree.Projects; + while Proj /= null loop + if Proj.Project.Library then + Proj.Project.Need_To_Build_Lib := + not MLib.Tgt.Library_Exists_For + (Proj.Project, Project_Tree) + and then not Proj.Project.Externally_Built; + + if Proj.Project.Need_To_Build_Lib then + + -- If there is no object directory, then it will be + -- impossible to build the library. So fail + -- immediately. + + if + Proj.Project.Object_Directory = No_Path_Information + then + Make_Failed + ("no object files to build library for project """ + & Get_Name_String (Proj.Project.Name) + & """"); + Proj.Project.Need_To_Build_Lib := False; - if Project_Tree.Projects.Table (Proj).Object_Directory = - No_Path_Information - then - Make_Failed - ("no object files to build library for project """ - & Get_Name_String - (Project_Tree.Projects.Table (Proj).Name) - & """"); - Project_Tree.Projects.Table - (Proj).Need_To_Build_Lib := False; + else + if Verbose_Mode then + Write_Str + ("Library file does not exist for project """); + Write_Str (Get_Name_String (Proj.Project.Name)); + Write_Line (""""); + end if; - else - if Verbose_Mode then - Write_Str - ("Library file does not exist for project """); - Write_Str - (Get_Name_String - (Project_Tree.Projects.Table - (Proj).Name)); - Write_Line (""""); + Insert_Project_Sources + (The_Project => Proj.Project, + All_Projects => False, + Into_Q => True); end if; - - Insert_Project_Sources - (The_Project => Proj, - All_Projects => False, - Into_Q => True); end if; end if; - end if; - end loop; + + Proj := Proj.Next; + end loop; + end; end if; -- If a relative path output file has been specified, we add @@ -5374,9 +5332,7 @@ package body Make is begin if not Is_Absolute_Path (Exec_File_Name) then - Get_Name_String - (Project_Tree.Projects.Table - (Main_Project).Exec_Directory.Name); + Get_Name_String (Main_Project.Exec_Directory.Name); if Name_Buffer (Name_Len) /= Directory_Separator then Name_Len := Name_Len + 1; @@ -5403,9 +5359,7 @@ package body Make is declare Dir_Path : constant String := - Get_Name_String - (Project_Tree.Projects.Table - (Main_Project).Directory.Name); + Get_Name_String (Main_Project.Directory.Name); begin for J in 1 .. Binder_Switches.Last loop Test_If_Relative_Path @@ -5525,29 +5479,40 @@ package body Make is -- Allocate as many temporary mapping file names as the maximum -- number of compilation processed, for each possible project. - The_Mapping_File_Names := - new Temp_Path_Names - (No_Project .. Project_Table.Last (Project_Tree.Projects), - 1 .. Saved_Maximum_Processes); - Last_Mapping_File_Names := - new Indices' - (No_Project .. Project_Table.Last (Project_Tree.Projects) - => 0); - - The_Free_Mapping_File_Indices := - new Free_File_Indices - (No_Project .. Project_Table.Last (Project_Tree.Projects), - 1 .. Saved_Maximum_Processes); - Last_Free_Indices := - new Indices'(No_Project .. Project_Table.Last - (Project_Tree.Projects) => 0); + declare + Data : Project_Compilation_Access; + Proj : Project_List := Project_Tree.Projects; + begin + while Proj /= null loop + Data := new Project_Compilation_Data' + (Mapping_File_Names => new Temp_Path_Names + (1 .. Saved_Maximum_Processes), + Last_Mapping_File_Names => 0, + Free_Mapping_File_Indices => new Free_File_Indices + (1 .. Saved_Maximum_Processes), + Last_Free_Indices => 0); + Project_Compilation_Htable.Set + (Project_Compilation, Proj.Project, Data); + Proj := Proj.Next; + end loop; + + Data := new Project_Compilation_Data' + (Mapping_File_Names => new Temp_Path_Names + (1 .. Saved_Maximum_Processes), + Last_Mapping_File_Names => 0, + Free_Mapping_File_Indices => new Free_File_Indices + (1 .. Saved_Maximum_Processes), + Last_Free_Indices => 0); + Project_Compilation_Htable.Set + (Project_Compilation, No_Project, Data); + end; Bad_Compilation.Init; - -- If project files are used, create the mapping of all the sources, - -- so that the correct paths will be found. Otherwise, if there is - -- a file which is not a source with the same name in a source directory - -- this file may be incorrectly found. + -- If project files are used, create the mapping of all the sources, so + -- that the correct paths will be found. Otherwise, if there is a file + -- which is not a source with the same name in a source directory this + -- file may be incorrectly found. if Main_Project /= No_Project then Prj.Env.Create_Mapping (Project_Tree); @@ -5617,9 +5582,7 @@ package body Make is end if; if Main_Project /= No_Project - and then - Project_Tree.Projects.Table - (Main_Project).Exec_Directory /= No_Path_Information + and then Main_Project.Exec_Directory /= No_Path_Information then declare Exec_File_Name : constant String := @@ -5627,9 +5590,7 @@ package body Make is begin if not Is_Absolute_Path (Exec_File_Name) then - Get_Name_String - (Project_Tree.Projects.Table - (Main_Project).Exec_Directory.Display_Name); + Get_Name_String (Main_Project.Exec_Directory.Display_Name); if Name_Buffer (Name_Len) /= Directory_Separator then Name_Len := Name_Len + 1; @@ -5721,6 +5682,7 @@ package body Make is declare Depth : Natural; Current : Natural; + Proj1 : Project_List; procedure Add_To_Library_Projs (Proj : Project_Id); -- Add project Project to table Library_Projs in @@ -5735,7 +5697,7 @@ package body Make is begin Library_Projs.Increment_Last; - Depth := Project_Tree.Projects.Table (Proj).Depth; + Depth := Proj.Depth; -- Put the projects in decreasing depth order, so that -- if libA depends on libB, libB is first in order. @@ -5743,8 +5705,7 @@ package body Make is Current := Library_Projs.Last; while Current > 1 loop Prj := Library_Projs.Table (Current - 1); - exit when Project_Tree.Projects.Table - (Prj).Depth >= Depth; + exit when Prj.Depth >= Depth; Library_Projs.Table (Current) := Prj; Current := Current - 1; end loop; @@ -5759,41 +5720,34 @@ package body Make is -- Put in Library_Projs table all library project -- file ids when the library need to be rebuilt. - for Proj1 in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - if Project_Tree.Projects.Table - (Proj1).Standalone_Library - then + Proj1 := Project_Tree.Projects; + while Proj1 /= null loop + if Proj1.Project.Standalone_Library then Stand_Alone_Libraries := True; end if; - if Project_Tree.Projects.Table (Proj1).Library then - MLib.Prj.Check_Library (Proj1, Project_Tree); + if Proj1.Project.Library then + MLib.Prj.Check_Library + (Proj1.Project, Project_Tree); end if; - if Project_Tree.Projects.Table - (Proj1).Need_To_Build_Lib - then - Add_To_Library_Projs (Proj1); + if Proj1.Project.Need_To_Build_Lib then + Add_To_Library_Projs (Proj1.Project); end if; + + Proj1 := Proj1.Next; end loop; -- Check if importing libraries should be regenerated -- because at least an imported library will be -- regenerated or is more recent. - for Proj1 in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - if Project_Tree.Projects.Table (Proj1).Library - and then - Project_Tree.Projects.Table (Proj1).Library_Kind /= - Static - and then not Project_Tree.Projects.Table - (Proj1).Need_To_Build_Lib - and then not Project_Tree.Projects.Table - (Proj1).Externally_Built + Proj1 := Project_Tree.Projects; + while Proj1 /= null loop + if Proj1.Project.Library + and then Proj1.Project.Library_Kind /= Static + and then not Proj1.Project.Need_To_Build_Lib + and then not Proj1.Project.Externally_Built then declare List : Project_List; @@ -5801,24 +5755,17 @@ package body Make is Rebuild : Boolean := False; Lib_Timestamp1 : constant Time_Stamp_Type := - Project_Tree.Projects.Table - (Proj1).Library_TS; + Proj1.Project.Library_TS; begin - List := Project_Tree.Projects.Table (Proj1). - All_Imported_Projects; + List := Proj1.Project.All_Imported_Projects; while List /= null loop Proj2 := List.Project; - if - Project_Tree.Projects.Table (Proj2).Library - then - if Project_Tree.Projects.Table (Proj2). - Need_To_Build_Lib + if Proj2.Library then + if Proj2.Need_To_Build_Lib or else - (Lib_Timestamp1 < - Project_Tree.Projects.Table - (Proj2).Library_TS) + (Lib_Timestamp1 < Proj2.Library_TS) then Rebuild := True; exit; @@ -5829,22 +5776,22 @@ package body Make is end loop; if Rebuild then - Project_Tree.Projects.Table - (Proj1).Need_To_Build_Lib := True; - Add_To_Library_Projs (Proj1); + Proj1.Project.Need_To_Build_Lib := True; + Add_To_Library_Projs (Proj1.Project); end if; end; end if; + + Proj1 := Proj1.Next; end loop; -- Reset the flags Need_To_Build_Lib for the next main, -- to avoid rebuilding libraries uselessly. - for Proj1 in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - Project_Tree.Projects.Table - (Proj1).Need_To_Build_Lib := False; + Proj1 := Project_Tree.Projects; + while Proj1 /= null loop + Proj1.Project.Need_To_Build_Lib := False; + Proj1 := Proj1.Next; end loop; end; @@ -6051,6 +5998,8 @@ package body Make is -- Set to True when there are shared library project files or -- when gnatbind is invoked with -shared. + Proj : Project_List; + begin -- Check if there are shared libraries, so that gnatbind is -- called with -shared. Check also if gnatbind is called with @@ -6060,17 +6009,16 @@ package body Make is if Main_Project /= No_Project and then MLib.Tgt.Support_For_Libraries /= Prj.None then - for Proj in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - if Project_Tree.Projects.Table (Proj).Library - and then Project_Tree.Projects.Table - (Proj).Library_Kind /= Static + Proj := Project_Tree.Projects; + while Proj /= null loop + if Proj.Project.Library + and then Proj.Project.Library_Kind /= Static then Shared_Libs := True; Bind_Shared := Shared_Switch'Access; exit; end if; + Proj := Proj.Next; end loop; end if; @@ -6157,6 +6105,7 @@ package body Make is Current : Natural; Proj2 : Project_Id; Depth : Natural; + Proj1 : Project_List; begin if not Run_Path_Option then @@ -6173,17 +6122,15 @@ package body Make is -- Check for library projects - for Proj1 in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - if Proj1 /= Main_Project - and then - Project_Tree.Projects.Table (Proj1).Library + Proj1 := Project_Tree.Projects; + while Proj1 /= null loop + if Proj1.Project /= Main_Project + and then Proj1.Project.Library then -- Add this project to table Library_Projs Libraries_Present := True; - Depth := Project_Tree.Projects.Table (Proj1).Depth; + Depth := Proj1.Project.Depth; Library_Projs.Increment_Last; Current := Library_Projs.Last; @@ -6192,29 +6139,28 @@ package body Make is while Current > 1 loop Proj2 := Library_Projs.Table (Current - 1); - exit when Project_Tree.Projects.Table - (Proj2).Depth <= Depth; + exit when Proj2.Depth <= Depth; Library_Projs.Table (Current) := Proj2; Current := Current - 1; end loop; - Library_Projs.Table (Current) := Proj1; + Library_Projs.Table (Current) := Proj1.Project; -- If it is not a static library and path option -- is set, add it to the Library_Paths table. - if Project_Tree.Projects.Table - (Proj1).Library_Kind /= Static + if Proj1.Project.Library_Kind /= Static and then Path_Option /= null then Library_Paths.Increment_Last; Library_Paths.Table (Library_Paths.Last) := new String' (Get_Name_String - (Project_Tree.Projects.Table - (Proj1).Library_Dir.Display_Name)); + (Proj1.Project.Library_Dir.Display_Name)); end if; end if; + + Proj1 := Proj1.Next; end loop; for Index in 1 .. Library_Projs.Last loop @@ -6225,9 +6171,8 @@ package body Make is Linker_Switches.Table (Linker_Switches.Last) := new String'("-L" & Get_Name_String - (Project_Tree.Projects.Table - (Library_Projs.Table (Index)). - Library_Dir.Display_Name)); + (Library_Projs.Table (Index). + Library_Dir.Display_Name)); -- Add the -l switch @@ -6235,9 +6180,8 @@ package body Make is Linker_Switches.Table (Linker_Switches.Last) := new String'("-l" & Get_Name_String - (Project_Tree.Projects.Table - (Library_Projs.Table (Index)). - Library_Name)); + (Library_Projs.Table (Index). + Library_Name)); end loop; end if; @@ -6471,8 +6415,7 @@ package body Make is not Unique_Compile); The_Packages : constant Package_Id := - Project_Tree.Projects.Table - (Main_Project).Decl.Packages; + Main_Project.Decl.Packages; Binder_Package : constant Prj.Package_Id := Prj.Util.Value_Of @@ -6572,8 +6515,7 @@ package body Make is declare Dir_Path : constant String := Get_Name_String - (Project_Tree.Projects.Table - (Main_Project).Directory.Name); + (Main_Project.Directory.Name); begin for @@ -6687,6 +6629,7 @@ package body Make is procedure Init_Mapping_File (Project : Project_Id; + Data : in out Project_Compilation_Data; File_Index : in out Natural) is FD : File_Descriptor; @@ -6696,8 +6639,7 @@ package body Make is begin -- Increase the index of the last mapping file for this project - Last_Mapping_File_Names (Project) := - Last_Mapping_File_Names (Project) + 1; + Data.Last_Mapping_File_Names := Data.Last_Mapping_File_Names + 1; -- If there is a project file, call Create_Mapping_File with -- the project id. @@ -6707,24 +6649,22 @@ package body Make is (Project, In_Tree => Project_Tree, Language => No_Name, - Name => The_Mapping_File_Names - (Project, Last_Mapping_File_Names (Project))); + Name => Data.Mapping_File_Names + (Data.Last_Mapping_File_Names)); -- Otherwise, just create an empty file else Tempdir.Create_Temp_File (FD, - The_Mapping_File_Names - (No_Project, Last_Mapping_File_Names (No_Project))); + Data.Mapping_File_Names (Data.Last_Mapping_File_Names)); if FD = Invalid_FD then Make_Failed ("disk full"); else Record_Temp_File - (The_Mapping_File_Names - (No_Project, Last_Mapping_File_Names (No_Project))); + (Data.Mapping_File_Names (Data.Last_Mapping_File_Names)); end if; Close (FD, Status); @@ -6736,7 +6676,7 @@ package body Make is -- And return the index of the newly created file - File_Index := Last_Mapping_File_Names (Project); + File_Index := Data.Last_Mapping_File_Names; end Init_Mapping_File; ------------ @@ -6958,18 +6898,22 @@ package body Make is -- to the search paths. Add_Source_Directories (Main_Project, Project_Tree); - Add_Object_Directories (Main_Project, Project_Tree); + Add_Object_Directories (Main_Project); Recursive_Compute_Depth (Main_Project); -- For each project compute the list of the projects it imports -- directly or indirectly. - for Proj in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - Compute_All_Imported_Projects (Proj, Project_Tree); - end loop; + declare + Proj : Project_List; + begin + Proj := Project_Tree.Projects; + while Proj /= null loop + Compute_All_Imported_Projects (Proj.Project); + Proj := Proj.Next; + end loop; + end; else @@ -7015,9 +6959,7 @@ package body Make is Sfile : File_Name_Type; Index : Int; - Extending : constant Boolean := - Project_Tree.Projects.Table - (The_Project).Extends /= No_Project; + Extending : constant Boolean := The_Project.Extends /= No_Project; function Check_Project (P : Project_Id) return Boolean; -- Returns True if P is The_Project or a project extended by The_Project @@ -7033,17 +6975,16 @@ package body Make is elsif Extending then declare - Data : Project_Data := - Project_Tree.Projects.Table (The_Project); + Proj : Project_Id; begin - loop - if P = Data.Extends then + Proj := The_Project; + while Proj /= null loop + if P = Proj.Extends then return True; end if; - Data := Project_Tree.Projects.Table (Data.Extends); - exit when Data.Extends = No_Project; + Proj := Proj.Extends; end loop; end; end if; @@ -7064,7 +7005,7 @@ package body Make is Index := 0; -- If there is a source for the body, and the body has not been - -- locally removed, + -- locally removed. if Unit.File_Names (Body_Part).Name /= No_File and then Unit.File_Names (Body_Part).Path.Name /= Slash @@ -7074,7 +7015,7 @@ package body Make is if Check_Project (Unit.File_Names (Body_Part).Project) then -- If we don't have a spec, we cannot consider the source - -- if it is a subunit + -- if it is a subunit. if Unit.File_Names (Specification).Name = No_File then declare @@ -7261,7 +7202,6 @@ package body Make is Get_Name_String (Source_File); Saved_Verbosity : constant Verbosity := Current_Verbosity; Project : Project_Id := No_Project; - Data : Project_Data; Path_Name : Path_Name_Type := No_Path; pragma Warnings (Off, Path_Name); @@ -7284,13 +7224,12 @@ package body Make is -- ALI file will not be skipped. if Project /= No_Project then - Data := Project_Tree.Projects.Table (Project); - declare Object_Directory : constant String := Normalize_Pathname (Get_Name_String - (Data.Object_Directory.Display_Name)); + (Project. + Object_Directory.Display_Name)); Olast : Natural := Object_Directory'Last; @@ -7482,10 +7421,7 @@ package body Make is declare Real_Path : constant String := Normalize_Pathname - (Dir, - Get_Name_String - (Project_Tree.Projects.Table - (Main_Project).Directory.Display_Name)); + (Dir, Get_Name_String (Main_Project.Directory.Display_Name)); begin if Real_Path'Length = 0 then @@ -7528,13 +7464,12 @@ package body Make is ------------- procedure Recurse (Prj : Project_Id; Depth : Natural) is - Data : Project_Data renames Project_Tree.Projects.Table (Prj); List : Project_List; Proj : Project_Id; begin - if Data.Depth >= Depth - or Get (Seen, Prj) + if Prj.Depth >= Depth + or Get (Seen, Prj) -- or needed instead of or else ??? then return; end if; @@ -7545,11 +7480,11 @@ package body Make is Set (Seen, Prj, True); - Data.Depth := Depth; + Prj.Depth := Depth; -- Visit each imported project - List := Data.Imported_Projects; + List := Prj.Imported_Projects; while List /= null loop Proj := List.Project; List := List.Next; @@ -7564,11 +7499,12 @@ package body Make is -- Start of processing for Recursive_Compute_Depth + Proj : Project_List; begin - for Proj in Project_Table.First .. - Project_Table.Last (Project_Tree.Projects) - loop - Project_Tree.Projects.Table (Proj).Depth := 0; + Proj := Project_Tree.Projects; + while Proj /= null loop + Proj.Project.Depth := 0; + Proj := Proj.Next; end loop; Recurse (Project, Depth => 1); |