Patchwork [Ada] Correct project search path when using switch -aP

login
register
mail settings
Submitter Arnaud Charlet
Date April 24, 2013, 1:13 p.m.
Message ID <20130424131337.GA14973@adacore.com>
Download mbox | patch
Permalink /patch/239204/
State New
Headers show

Comments

Arnaud Charlet - April 24, 2013, 1:13 p.m.
gnatmake, gnatclean and the GNAT driver were incorrectly putting
directories that are specified with switches -aP<dir> after the default
project search directories in the project search path.
This patch ensures that the default project search directories are
always at the end of the project search path.

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

2013-04-24  Vincent Celier  <celier@adacore.com>

	* clean.adb (Gnatclean): Add the default project search
	directories in the project search path after scanning the
	switches on the command line.
	(Initialize): Do not put the default project search directories in the
	project search path.
	* gnatcmd.adb (GNATcmd): Add the default project search
	directories in the project search path after scanning the switches
	on the command line.
	* make.adb (Initialize): Add the default project search
	directories in the project search path after scanning the switches
	on the command line.

Patch

Index: gnatcmd.adb
===================================================================
--- gnatcmd.adb	(revision 198221)
+++ gnatcmd.adb	(working copy)
@@ -1395,9 +1395,6 @@ 
    Snames.Initialize;
 
    Prj.Tree.Initialize (Root_Environment, Gnatmake_Flags);
-   Prj.Env.Initialize_Default_Project_Path
-     (Root_Environment.Project_Path,
-      Target_Name => Sdefault.Target_Name.all);
 
    Project_Node_Tree := new Project_Node_Tree_Data;
    Prj.Tree.Initialize (Project_Node_Tree);
@@ -1911,6 +1908,13 @@ 
          end Inspect_Switches;
       end if;
 
+      --  Add the default project search directories now, after the directories
+      --  that have been specified by switches -aP<dir>.
+
+      Prj.Env.Initialize_Default_Project_Path
+        (Root_Environment.Project_Path,
+         Target_Name => Sdefault.Target_Name.all);
+
       --  If there is a project file specified, parse it, get the switches
       --  for the tool and setup PATH environment variables.
 
Index: make.adb
===================================================================
--- make.adb	(revision 198221)
+++ make.adb	(working copy)
@@ -6392,8 +6392,6 @@ 
       --  the command line switches
 
       Prj.Tree.Initialize (Env, Gnatmake_Flags);
-      Prj.Env.Initialize_Default_Project_Path
-        (Env.Project_Path, Target_Name => Sdefault.Target_Name.all);
 
       Project_Node_Tree := new Project_Node_Tree_Data;
       Prj.Tree.Initialize (Project_Node_Tree);
@@ -6492,6 +6490,12 @@ 
          Usage;
       end if;
 
+      --  Add the default project search directories now, after the directories
+      --  that have been specified by switches -aP<dir>.
+
+      Prj.Env.Initialize_Default_Project_Path
+        (Env.Project_Path, Target_Name => Sdefault.Target_Name.all);
+
       --  Test for trailing -P switch
 
       if Project_File_Name_Present and then Project_File_Name = null then
Index: clean.adb
===================================================================
--- clean.adb	(revision 198221)
+++ clean.adb	(working copy)
@@ -1377,6 +1377,13 @@ 
 
       Parse_Cmd_Line;
 
+      --  Add the default project search directories now, after the directories
+      --  that have been specified by switches -aP<dir>.
+
+      Prj.Env.Initialize_Default_Project_Path
+        (Root_Environment.Project_Path,
+         Target_Name => Sdefault.Target_Name.all);
+
       if Verbose_Mode then
          Display_Copyright;
       end if;
@@ -1550,9 +1557,6 @@ 
          Snames.Initialize;
 
          Prj.Tree.Initialize (Root_Environment, Gnatmake_Flags);
-         Prj.Env.Initialize_Default_Project_Path
-            (Root_Environment.Project_Path,
-             Target_Name => Sdefault.Target_Name.all);
 
          Project_Node_Tree := new Project_Node_Tree_Data;
          Prj.Tree.Initialize (Project_Node_Tree);