From 1ab4a286b7529f0a4f64d13f34df9a4f5a2b41ad Mon Sep 17 00:00:00 2001 From: Emmanuel Briot Date: Thu, 4 Aug 2011 13:21:16 +0000 Subject: [PATCH] make.adb, [...] (Check_Mains): rebuild the list of files on the command line after processing it through... 2011-08-04 Emmanuel Briot * make.adb, makeutl.adb, osint.adb, osint.ads (Check_Mains): rebuild the list of files on the command line after processing it through Complete_Mains. From-SVN: r177380 --- gcc/ada/ChangeLog | 6 +++++ gcc/ada/make.adb | 56 ++++++++++++++++++++++++++++++++++++++++++++- gcc/ada/makeutl.adb | 1 + gcc/ada/osint.adb | 11 ++++++++- gcc/ada/osint.ads | 5 +++- 5 files changed, 76 insertions(+), 3 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 62df17c5acd..12e4b0d54b3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2011-08-04 Emmanuel Briot + + * make.adb, makeutl.adb, osint.adb, osint.ads (Check_Mains): rebuild + the list of files on the command line after processing it through + Complete_Mains. + 2011-08-04 Hristian Kirtchev * exp_ch7.adb (Build_Raise_Statement): Remove the specialized diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index 6d1eaa5e54a..41e787d3192 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -5464,6 +5464,9 @@ package body Make is Current_Main_Index : Int := 0; -- If not zero, the index of the current main unit in its source file + Is_First_Main : Boolean; + -- Whether we are processing the first main + Stand_Alone_Libraries : Boolean := False; -- Set to True when there are Stand-Alone Libraries, so that gnatbind -- is invoked with the -F switch to force checking of elaboration flags. @@ -5526,6 +5529,30 @@ package body Make is Debug_Output ("After checking mains, main project is", Main_Project.Name); + + else + -- For all mains on the command line, make sure they were in + -- osint. In particular, if the user has specified a multi-unit + -- source file, the call to Complete_Mains will have expanded + -- the list of mains to all its units, and we must now put them + -- back on the command line. + -- ??? This will not be necessary when gnatmake shares the same + -- queue as gprbuild and processes the file directly on the queue. + + Mains.Reset; + -- Osint.Reset_Command_Line_Files; + Debug_Output ("Reseting list of mains on the command line"); + + loop + Info := Mains.Next_Main; + exit when Info = No_Main_Info; + + if Info.Index /= 0 then + Debug_Output ("Add to command line index=" + & Info.Index'Img, Name_Id (Info.File)); + Osint.Add_File (Get_Name_String (Info.File), Info.Index); + end if; + end loop; end if; end Check_Mains; @@ -6056,6 +6083,8 @@ package body Make is Queue.Initialize (Main_Project /= No_Project and then One_Compilation_Per_Obj_Dir); + Is_First_Main := True; + Multiple_Main_Loop : for N_File in 1 .. Osint.Number_Of_Files loop if Current_File_Index /= No_Index then Main_Index := Current_File_Index; @@ -6063,14 +6092,39 @@ package body Make is Current_Main_Index := Main_Index; + if Current_Main_Index = 0 + and then Unique_Compile + and then Main_Project /= No_Project + then + -- If this is a multi-unit source, do not compile it as is (ie + -- without specifying which unit to compile) + -- Insert_Project_Sources has added each of the unit separately. + + declare + Source : constant Prj.Source_Id := Find_Source + (In_Tree => Project_Tree, + Project => Main_Project, + Base_Name => Main_Source_File, + Index => Current_Main_Index, + In_Imported_Only => True); + begin + if Source /= No_Source + and then Source.Index /= 0 + then + goto Next_Main; + end if; + end; + end if; + Compute_Switches_For_Main (Main_Source_File, Main_Index, Project_Node_Tree, Root_Environment, - Compute_Builder => N_File = 1, + Compute_Builder => Is_First_Main, Current_Work_Dir => Current_Work_Dir.all); + Is_First_Main := False; Executable_Obsolete := False; Compute_Executable diff --git a/gcc/ada/makeutl.adb b/gcc/ada/makeutl.adb index b51e7fb297f..0be182e7413 100644 --- a/gcc/ada/makeutl.adb +++ b/gcc/ada/makeutl.adb @@ -1529,6 +1529,7 @@ package body Makeutl is end if; Names.Table (J).Source := Source; + Names.Table (J).Index := Source.Index; elsif File.Location /= No_Location then diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index 248845f3fba..408384ca88b 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -2749,6 +2749,15 @@ package body Osint is return new String'(Path); end Relocate_Path; + ------------------------------ + -- Reset_Command_Line_Files -- + ------------------------------ + + procedure Reset_Command_Line_Files is + begin + Number_File_Names := 0; + end Reset_Command_Line_Files; + ----------------- -- Set_Program -- ----------------- diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads index 9ec26bff3b4..9fccd330859 100644 --- a/gcc/ada/osint.ads +++ b/gcc/ada/osint.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -114,6 +114,9 @@ package Osint is function Number_Of_Files return Int; -- Gives the total number of filenames found on the command line + procedure Reset_Command_Line_Files; + -- Reset the list of files specified on the command line to empty. + No_Index : constant := -1; -- Value used in Add_File to indicate no index is specified for main -- 2.30.2