make.adb, [...] (Check_Mains): rebuild the list of files on the command line after processing it through...

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

	* 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
This commit is contained in:
Emmanuel Briot 2011-08-04 13:21:16 +00:00 committed by Arnaud Charlet
parent 7ae0d98c02
commit 1ab4a286b7
5 changed files with 76 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2011-08-04 Emmanuel Briot <briot@adacore.com>
* 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 <kirtchev@adacore.com>
* exp_ch7.adb (Build_Raise_Statement): Remove the specialized

View File

@ -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

View File

@ -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

View File

@ -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 --
-----------------

View File

@ -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