When a runtime specified as a relative or full path in package Builder
of the main project, instead of failing the program immediately, the
Project Manager raises an exception.

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

2014-07-31  Vincent Celier  <cel...@adacore.com>

        * prj-pars.adb, prj-conf.ads, prj-conf.adb (Locate_Runtime): Move spec
        to package body, as it is not called from outside. Remove argument
        Project_Tree, no longer used. When runtime cannot be found,
        call Raise_Invalid_Config instead of failing the program.

Index: prj-conf.adb
===================================================================
--- prj-conf.adb        (revision 213263)
+++ prj-conf.adb        (working copy)
@@ -64,6 +64,14 @@
    --  Stores the runtime names for the various languages. This is in general
    --  set from a --RTS command line option.
 
+   procedure Locate_Runtime
+     (Language     : Name_Id;
+      Env          : Prj.Tree.Environment);
+   --  If RTS_Name is a base name (a name without path separator), then
+   --  do nothing. Otherwise, convert it to an absolute path (possibly by
+   --  searching it in the project path) and call Set_Runtime_For with the
+   --  absolute path. Raise Invalid_Config if the path does not exist.
+
    -----------------------
    -- Local_Subprograms --
    -----------------------
@@ -721,7 +729,7 @@
                               Set_Runtime_For
                                 (Name_Ada,
                                  Name_Buffer (7 .. Name_Len));
-                              Locate_Runtime (Name_Ada, Project_Tree, Env);
+                              Locate_Runtime (Name_Ada, Env);
                            end if;
 
                         elsif Name_Len > 7
@@ -748,7 +756,7 @@
 
                                  if not Runtime_Name_Set_For (Lang) then
                                     Set_Runtime_For (Lang, RTS);
-                                    Locate_Runtime (Lang, Project_Tree, Env);
+                                    Locate_Runtime (Lang, Env);
                                  end if;
                               end;
                            end if;
@@ -1518,7 +1526,6 @@
 
    procedure Locate_Runtime
      (Language     : Name_Id;
-      Project_Tree : Prj.Project_Tree_Ref;
       Env          : Prj.Tree.Environment)
    is
       function Is_Base_Name (Path : String) return Boolean;
@@ -1555,7 +1562,7 @@
            Find_Rts_In_Path (Env.Project_Path, RTS_Name);
 
          if Full_Path = null then
-            Fail_Program (Project_Tree, "cannot find RTS " & RTS_Name);
+            Raise_Invalid_Config ("cannot find RTS " & RTS_Name);
          end if;
 
          Set_Runtime_For (Language, Normalize_Pathname (Full_Path.all));
Index: prj-conf.ads
===================================================================
--- prj-conf.ads        (revision 213263)
+++ prj-conf.ads        (working copy)
@@ -216,13 +216,4 @@
    function Runtime_Name_Set_For (Language : Name_Id) return Boolean;
    --  Returns True only if Set_Runtime_For has been called for the Language
 
-   procedure Locate_Runtime
-     (Language     : Name_Id;
-      Project_Tree : Prj.Project_Tree_Ref;
-      Env          : Prj.Tree.Environment);
-   --  If RTS_Name is a base name (a name without path separator), then
-   --  do nothing. Otherwise, convert it to an absolute path (possibly by
-   --  searching it in the project path) and call Set_Runtime_For with the
-   --  absolute path. Fail the program if the path does not exist.
-
 end Prj.Conf;
Index: prj-pars.adb
===================================================================
--- prj-pars.adb        (revision 213263)
+++ prj-pars.adb        (working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -103,8 +103,8 @@
             Success := The_Project /= No_Project;
 
          exception
-            when Invalid_Config =>
-               Success := False;
+            when E : Invalid_Config =>
+               Osint.Fail (Exception_Message (E));
          end;
 
          Prj.Err.Finalize;

Reply via email to