-- Every program depends on this package, that must then be checked,
-- especially when -f and -a are used.
+ procedure Kill (Pid : Process_Id; Sig_Num : Integer; Close : Integer);
+ pragma Import (C, Kill, "__gnat_kill");
+ -- Called by Sigint_Intercepted to kill all spawned compilation processes
+
type Sigint_Handler is access procedure;
procedure Install_Int_Handler (Handler : Sigint_Handler);
-- Called when the program is interrupted by Ctrl-C to delete the
-- temporary mapping files and configuration pragmas files.
+ No_Mapping_File : constant Natural := 0;
+
+ type Compilation_Data is record
+ Pid : Process_Id;
+ Full_Source_File : File_Name_Type;
+ Lib_File : File_Name_Type;
+ Source_Unit : Unit_Name_Type;
+ Mapping_File : Natural := No_Mapping_File;
+ Project : Project_Id := No_Project;
+ Syntax_Only : Boolean := False;
+ Output_Is_Object : Boolean := True;
+ end record;
+ -- Data recorded for each compilation process spawned
+
+ type Comp_Data_Arr is array (Positive range <>) of Compilation_Data;
+ type Comp_Data_Ptr is access Comp_Data_Arr;
+ Running_Compile : Comp_Data_Ptr;
+ -- Used to save information about outstanding compilations
+
+ Outstanding_Compiles : Natural := 0;
+ -- Current number of outstanding compiles
+
-------------------------
-- Note on terminology --
-------------------------
Initialize_ALI_Data : Boolean := True;
Max_Process : Positive := 1)
is
- No_Mapping_File : constant Natural := 0;
-
- type Compilation_Data is record
- Pid : Process_Id;
- Full_Source_File : File_Name_Type;
- Lib_File : File_Name_Type;
- Source_Unit : Unit_Name_Type;
- Mapping_File : Natural := No_Mapping_File;
- Project : Project_Id := No_Project;
- Syntax_Only : Boolean := False;
- Output_Is_Object : Boolean := True;
- end record;
-
- Running_Compile : array (1 .. Max_Process) of Compilation_Data;
- -- Used to save information about outstanding compilations
-
- Outstanding_Compiles : Natural := 0;
- -- Current number of outstanding compiles
-
Source_Unit : Unit_Name_Type;
-- Current source unit
begin
pragma Assert (Args'First = 1);
+ Outstanding_Compiles := 0;
+ Running_Compile := new Comp_Data_Arr (1 .. Max_Process);
+
-- Package and Queue initializations
Good_ALI.Init;
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 Main_Project /= No_Project then
+ Prj.Env.Create_Mapping (Project_Tree);
+ end if;
+
Current_Main_Index := Main_Index;
-- Here is where the make process is started
------------------------
procedure Sigint_Intercepted is
+ SIGINT : constant := 2;
begin
Set_Standard_Error;
Write_Line ("*** Interrupted ***");
Delete_All_Temp_Files;
+
+ -- Send SIGINT to all oustanding compilation processes spawned
+
+ for J in 1 .. Outstanding_Compiles loop
+ Kill (Running_Compile (J).Pid, SIGINT, 1);
+ end loop;
+
OS_Exit (1);
end Sigint_Intercepted;
-- --
------------------------------------------------------------------------------
+with Fmap;
with Opt;
with Osint; use Osint;
with Output; use Output;
end if;
end Create_Config_Pragmas_File;
+ --------------------
+ -- Create_Mapping --
+ --------------------
+
+ procedure Create_Mapping (In_Tree : Project_Tree_Ref) is
+ The_Unit_Data : Unit_Data;
+ Data : File_Name_Data;
+
+ begin
+ Fmap.Reset_Tables;
+
+ for Unit in 1 .. Unit_Table.Last (In_Tree.Units) loop
+ The_Unit_Data := In_Tree.Units.Table (Unit);
+
+ -- Process only if the unit has a valid name
+
+ if The_Unit_Data.Name /= No_Name then
+ Data := The_Unit_Data.File_Names (Specification);
+
+ -- If there is a spec, put it in the mapping
+
+ if Data.Name /= No_File then
+ if Data.Path = Slash then
+ Fmap.Add_Forbidden_File_Name (Data.Name);
+ else
+ Fmap.Add_To_File_Map
+ (Unit_Name => Unit_Name_Type (The_Unit_Data.Name),
+ File_Name => Data.Name,
+ Path_Name => File_Name_Type (Data.Path));
+ end if;
+ end if;
+
+ Data := The_Unit_Data.File_Names (Body_Part);
+
+ -- If there is a body (or subunit) put it in the mapping
+
+ if Data.Name /= No_File then
+ if Data.Path = Slash then
+ Fmap.Add_Forbidden_File_Name (Data.Name);
+ else
+ Fmap.Add_To_File_Map
+ (Unit_Name => Unit_Name_Type (The_Unit_Data.Name),
+ File_Name => Data.Name,
+ Path_Name => File_Name_Type (Data.Path));
+ end if;
+ end if;
+ end if;
+ end loop;
+ end Create_Mapping;
+
-------------------------
-- Create_Mapping_File --
-------------------------