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.
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;
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;
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
-- --
-- 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- --
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 --
-----------------
-- --
-- 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- --
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