makeutl.ads (Main_Config_Project): Moved to gpr_util.ads
authorVincent Celier <celier@adacore.com>
Wed, 26 Sep 2007 10:44:55 +0000 (12:44 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 26 Sep 2007 10:44:55 +0000 (12:44 +0200)
2007-09-26  Vincent Celier  <celier@adacore.com>

* makeutl.ads (Main_Config_Project): Moved to gpr_util.ads

* prj.ads, prj.adb (Default_Language): Remove function, no longer used
Replace components Compiler_Min_Options and Binder_Min_Options with
Compiler_Required_Switches and Binder_Required_Switches in record
Language_Config.
Remove components Default_Language and Config in Project_Tree_Data,
no longer used.

* prj-attr.adb: New attributes Required_Switches (<language>) in
packages Compiler and Binder.

* prj-nmsc.adb: Major rewrite of the processing of configuration
attributes for gprbuild. No impact on GNAT tools.

* prj-proc.ads, prj-proc.adb (Process_Project_Tree_Phase_2): No longer
process configuration attributes: this is done in Prj.Nmsc.Check.
(Recursive_Process): Make a full copy of packages inherited from project
being extended, instead of a shallow copy.
(Process_Project_Tree_Phase_1): New procedure
(Process_Project_Tree_Phase_1): New procedure
(Process): Implementation now uses the two new procedures

* prj-util.adb (Executable_Of): Get the suffix and the default suffix
from the project config, not the tree config that no longer exists.

From-SVN: r128796

gcc/ada/make.adb
gcc/ada/prj-env.adb
gcc/ada/prj-env.ads

index eb87005..c2c10ad 100644 (file)
@@ -76,6 +76,10 @@ package body Make is
    --  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);
@@ -86,6 +90,28 @@ package body Make is
    --  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 --
    -------------------------
@@ -2442,25 +2468,6 @@ package body Make is
       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
 
@@ -3150,6 +3157,9 @@ package body Make is
    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;
@@ -5401,6 +5411,15 @@ package body Make is
 
       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
@@ -7378,10 +7397,18 @@ package body Make is
    ------------------------
 
    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;
 
index 52ec2f7..1d97d80 100644 (file)
@@ -23,6 +23,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
+with Fmap;
 with Opt;
 with Osint;    use Osint;
 with Output;   use Output;
@@ -982,6 +983,56 @@ package body Prj.Env is
       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 --
    -------------------------
index 4a680ff..83da472 100644 (file)
@@ -35,6 +35,11 @@ package Prj.Env is
    procedure Print_Sources (In_Tree : Project_Tree_Ref);
    --  Output the list of sources, after Project files have been scanned
 
+   procedure Create_Mapping (In_Tree : Project_Tree_Ref);
+   --  Create in memory mapping from the sources of all the projects (in body
+   --  of package Fmap), so that Osint.Find_File will find the correct path
+   --  corresponding to a source.
+
    procedure Create_Mapping_File
      (Project : Project_Id;
       In_Tree : Project_Tree_Ref;