[Ada] gnatmake fails with incorrect default config project file

Submitted by Arnaud Charlet on Aug. 2, 2011, 10:36 a.m.

Details

Message ID 20110802103640.GA13408@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 2, 2011, 10:36 a.m.
When a default config project file (for example default.cgpr in
.../share/gpr) exists, gnatmake was parsing it, and would fail if, for
example, Default_Language was not declared.
This patch ensures that an existing config project file is never taken
into account by gnatmake.
The test is to invoke gnatmake with an empty config project file
default.cgpr in the project directory: gnatmake should not fail because
of the presence of this empty config project file.

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

2011-08-02  Vincent Celier  <celier@adacore.com>

	* prj-conf.adb (Get_Or_Create_Configuration_File): If On_Load_Config is
	not null, call it to create the in memory config project file without
	parsing an existing default config project file.

Patch hide | download patch | download mbox

Index: prj-conf.adb
===================================================================
--- prj-conf.adb	(revision 177054)
+++ prj-conf.adb	(working copy)
@@ -1107,7 +1107,12 @@ 
          Write_Line (Config_File_Path.all);
       end if;
 
-      if Config_File_Path /= null then
+      if On_Load_Config /= null then
+         On_Load_Config
+           (Config_File       => Config_Project_Node,
+            Project_Node_Tree => Project_Node_Tree);
+
+      elsif Config_File_Path /= null then
          Prj.Part.Parse
            (In_Tree                => Project_Node_Tree,
             Project                => Config_Project_Node,
@@ -1119,16 +1124,9 @@ 
             Flags                  => Flags,
             Target_Name            => Target_Name);
       else
-         --  Maybe the user will want to create his own configuration file
          Config_Project_Node := Empty_Node;
       end if;
 
-      if On_Load_Config /= null then
-         On_Load_Config
-           (Config_File       => Config_Project_Node,
-            Project_Node_Tree => Project_Node_Tree);
-      end if;
-
       if Config_Project_Node /= Empty_Node then
          Prj.Proc.Process_Project_Tree_Phase_1
            (In_Tree                => Project_Tree,