diff mbox

[Ada] gnatmake performance enhancement

Message ID 20100617122647.GA9166@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 17, 2010, 12:26 p.m. UTC
gnatmake with project files no longer provides an include path file to
the compiler, except when -x is specified. There is no functionality
change, so no test.

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-06-17  Vincent Celier  <celier@adacore.com>

	* make.adb (Collect_Arguments_And_Compile): Create include path file
	only when -x is specified.
	(Gnatmake): Ditto
	* opt.ads (Use_Include_Path_File): New Boolean flag, initialized to
	False.
	* prj-env.adb (Set_Ada_Paths): New Boolean parameters Include_Path and
	Objects_Path, defaulted to True. Only create include path file if
	Include_Path is True, only create objects path file if Objects_Path is
	True.
	* prj-env.ads (Set_Ada_Paths): New Boolean parameters Include_Path and
	Objects_Path, defaulted to True.
	* switch-m.adb (Scan_Make_Switches): Set Use_Include_Path_File to True
	when -x is used.
diff mbox

Patch

Index: make.adb
===================================================================
--- make.adb	(revision 160834)
+++ make.adb	(working copy)
@@ -2723,7 +2723,8 @@  package body Make is
                Prj.Env.Set_Ada_Paths
                  (Arguments_Project,
                   Project_Tree,
-                  Including_Libraries => True);
+                  Including_Libraries => True,
+                  Include_Path        => Use_Include_Path_File);
 
                if not Unique_Compile
                  and then MLib.Tgt.Support_For_Libraries /= Prj.None
@@ -6026,7 +6027,8 @@  package body Make is
                   --  and all the object directories in ADA_OBJECTS_PATH,
                   --  except those of library projects.
 
-                  Prj.Env.Set_Ada_Paths (Main_Project, Project_Tree, False);
+                  Prj.Env.Set_Ada_Paths
+                    (Main_Project, Project_Tree, Use_Include_Path_File);
 
                   --  If switch -C was specified, create a binder mapping file
 
@@ -6253,7 +6255,11 @@  package body Make is
 
                   --  Put the object directories in ADA_OBJECTS_PATH
 
-                  Prj.Env.Set_Ada_Paths (Main_Project, Project_Tree, False);
+                  Prj.Env.Set_Ada_Paths
+                    (Main_Project,
+                     Project_Tree,
+                     Including_Libraries => False,
+                     Include_Path        => False);
 
                   --  Check for attributes Linker'Linker_Options in projects
                   --  other than the main project
Index: switch-m.adb
===================================================================
--- switch-m.adb	(revision 160834)
+++ switch-m.adb	(working copy)
@@ -839,6 +839,7 @@  package body Switch.M is
 
                when 'x' =>
                   External_Unit_Compilation_Allowed := True;
+                  Use_Include_Path_File := True;
 
                   --  Processing for z switch
 
Index: opt.ads
===================================================================
--- opt.ads	(revision 160834)
+++ opt.ads	(working copy)
@@ -1229,6 +1229,11 @@  package Opt is
    --  set True, and upper half characters in the source indicate the start of
    --  a wide character sequence. Set by -gnatW or -W switches.
 
+   Use_Include_Path_File : Boolean := False;
+   --  GNATMAKE, GPRBUILD
+   --  When True, create a source search path file, even when a mapping file
+   --  is used.
+
    Usage_Requested : Boolean := False;
    --  GNAT, GNATBIND, GNATMAKE
    --  Set to True if -h (-gnath for the compiler) switch encountered
Index: prj-env.adb
===================================================================
--- prj-env.adb	(revision 160834)
+++ prj-env.adb	(working copy)
@@ -1498,7 +1498,9 @@  package body Prj.Env is
    procedure Set_Ada_Paths
      (Project             : Project_Id;
       In_Tree             : Project_Tree_Ref;
-      Including_Libraries : Boolean)
+      Including_Libraries : Boolean;
+      Include_Path        : Boolean := True;
+      Objects_Path        : Boolean := True)
 
    is
       Source_Paths : Source_Path_Table.Instance;
@@ -1570,7 +1572,7 @@  package body Prj.Env is
       --  If it is the first time we call this procedure for this project,
       --  compute the source path and/or the object path.
 
-      if Project.Include_Path_File = No_Path then
+      if Include_Path and then Project.Include_Path_File = No_Path then
          Source_Path_Table.Init (Source_Paths);
          Process_Source_Dirs := True;
          Create_New_Path_File
@@ -1580,7 +1582,7 @@  package body Prj.Env is
       --  For the object path, we make a distinction depending on
       --  Including_Libraries.
 
-      if Including_Libraries then
+      if Objects_Path and Including_Libraries then
          if Project.Objects_Path_File_With_Libs = No_Path then
             Object_Path_Table.Init (Object_Paths);
             Process_Object_Dirs := True;
@@ -1588,7 +1590,7 @@  package body Prj.Env is
               (In_Tree, Object_FD, Project.Objects_Path_File_With_Libs);
          end if;
 
-      else
+      elsif Objects_Path then
          if Project.Objects_Path_File_Without_Libs = No_Path then
             Object_Path_Table.Init (Object_Paths);
             Process_Object_Dirs := True;
@@ -1662,7 +1664,8 @@  package body Prj.Env is
       --  Set the env vars, if they need to be changed, and set the
       --  corresponding flags.
 
-      if In_Tree.Private_Part.Current_Source_Path_File /=
+      if Include_Path and then
+         In_Tree.Private_Part.Current_Source_Path_File /=
            Project.Include_Path_File
       then
          In_Tree.Private_Part.Current_Source_Path_File :=
@@ -1672,28 +1675,30 @@  package body Prj.Env is
             Get_Name_String (In_Tree.Private_Part.Current_Source_Path_File));
       end if;
 
-      if Including_Libraries then
-         if In_Tree.Private_Part.Current_Object_Path_File /=
-            Project.Objects_Path_File_With_Libs
-         then
-            In_Tree.Private_Part.Current_Object_Path_File :=
-              Project.Objects_Path_File_With_Libs;
-            Set_Path_File_Var
-              (Project_Objects_Path_File,
-               Get_Name_String
-                 (In_Tree.Private_Part.Current_Object_Path_File));
-         end if;
+      if Objects_Path then
+         if Including_Libraries then
+            if In_Tree.Private_Part.Current_Object_Path_File /=
+              Project.Objects_Path_File_With_Libs
+            then
+               In_Tree.Private_Part.Current_Object_Path_File :=
+                 Project.Objects_Path_File_With_Libs;
+               Set_Path_File_Var
+                 (Project_Objects_Path_File,
+                  Get_Name_String
+                    (In_Tree.Private_Part.Current_Object_Path_File));
+            end if;
 
-      else
-         if In_Tree.Private_Part.Current_Object_Path_File /=
-            Project.Objects_Path_File_Without_Libs
-         then
-            In_Tree.Private_Part.Current_Object_Path_File :=
-              Project.Objects_Path_File_Without_Libs;
-            Set_Path_File_Var
-              (Project_Objects_Path_File,
-               Get_Name_String
-                 (In_Tree.Private_Part.Current_Object_Path_File));
+         else
+            if In_Tree.Private_Part.Current_Object_Path_File /=
+              Project.Objects_Path_File_Without_Libs
+            then
+               In_Tree.Private_Part.Current_Object_Path_File :=
+                 Project.Objects_Path_File_Without_Libs;
+               Set_Path_File_Var
+                 (Project_Objects_Path_File,
+                  Get_Name_String
+                    (In_Tree.Private_Part.Current_Object_Path_File));
+            end if;
          end if;
       end if;
 
Index: prj-env.ads
===================================================================
--- prj-env.ads	(revision 160834)
+++ prj-env.ads	(working copy)
@@ -94,7 +94,9 @@  package Prj.Env is
    procedure Set_Ada_Paths
      (Project             : Project_Id;
       In_Tree             : Project_Tree_Ref;
-      Including_Libraries : Boolean);
+      Including_Libraries : Boolean;
+      Include_Path        : Boolean := True;
+      Objects_Path        : Boolean := True);
    --  Set the environment variables for additional project path files, after
    --  creating the path files if necessary.