2009-08-17 Emmanuel Briot <briot@adacore.com>
authorEmmanuel Briot <briot@adacore.com>
Mon, 17 Aug 2009 09:42:19 +0000 (11:42 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 17 Aug 2009 09:42:19 +0000 (11:42 +0200)
* prj-part.adb, prj.adb, prj.ads, prj-nmsc.adb, prj-conf.adb
(Processing_Flags.Require_Obj_Dirs): new field, which controls whether
object directories must be present. In the case of gprclean at least,
these are optional (if they do not exist there is nothing to clean)

From-SVN: r150827

gcc/ada/prj-conf.adb
gcc/ada/prj-nmsc.adb
gcc/ada/prj-part.adb
gcc/ada/prj.adb
gcc/ada/prj.ads

index 9258cd4c5de93fa785372c95f876321bc9b4ad8a..879178de1228faf5fd207d4974f324de210f30a8 100644 (file)
@@ -29,6 +29,7 @@ with Makeutl;          use Makeutl;
 with MLib.Tgt;
 with Opt;              use Opt;
 with Output;           use Output;
+with Prj.Err;
 with Prj.Part;
 with Prj.PP;
 with Prj.Proc;         use Prj.Proc;
@@ -722,8 +723,17 @@ package body Prj.Conf is
             end if;
 
             if not Is_Directory (Obj_Dir) then
-               raise Invalid_Config
-                 with "object directory " & Obj_Dir & " does not exist";
+               case Flags.Require_Obj_Dirs is
+                  when Error =>
+                     raise Invalid_Config
+                       with "object directory " & Obj_Dir & " does not exist";
+                  when Warning =>
+                     Prj.Err.Error_Msg
+                       (Flags,
+                        "?object directory " & Obj_Dir & " does not exist");
+                  when Silent =>
+                     null;
+               end case;
             end if;
 
             --  Invoke gprconfig
index 75e4c6ea7174ca4eefae61a578b6200e96d5f9f7..1a0371855c5f2d04824767f00485720604027673 100644 (file)
@@ -5148,10 +5148,21 @@ package body Prj.Nmsc is
 
                Err_Vars.Error_Msg_File_1 :=
                  File_Name_Type (Object_Dir.Value);
-               Error_Msg
-                 (Data.Flags,
-                  "object directory { not found",
-                  Project.Location, Project);
+
+               case Data.Flags.Require_Obj_Dirs is
+                  when Error =>
+                     Error_Msg
+                       (Data.Flags,
+                        "object directory { not found",
+                        Project.Location, Project);
+                  when Warning =>
+                     Error_Msg
+                       (Data.Flags,
+                        "?object directory { not found",
+                        Project.Location, Project);
+                  when Silent =>
+                     null;
+               end case;
             end if;
          end if;
 
index 8a0f6a52c15d9aec95958607f66bc616a34d3fbf..84e3f6dab7fd37d3e89769b00cb07519fb63886a 100644 (file)
@@ -583,6 +583,10 @@ package body Prj.Part is
 
          if No (Project) or else Always_Errout_Finalize then
             Prj.Err.Finalize;
+
+            --  Reinitialize to avoid duplicate warnings later on
+
+            Prj.Err.Initialize;
          end if;
       end;
 
index 2ad790324a79398c0b8a54784fe604d536d02436..2bed1a81dc29a09fbf0a8d235c1567fea2420442 100644 (file)
@@ -1189,7 +1189,9 @@ package body Prj is
       Require_Sources_Other_Lang : Boolean := True;
       Allow_Duplicate_Basenames  : Boolean := True;
       Compiler_Driver_Mandatory  : Boolean := False;
-      Error_On_Unknown_Language  : Boolean := True) return Processing_Flags
+      Error_On_Unknown_Language  : Boolean := True;
+      Require_Obj_Dirs           : Error_Warning := Error)
+      return Processing_Flags
    is
    begin
       return Processing_Flags'
@@ -1198,7 +1200,8 @@ package body Prj is
          Require_Sources_Other_Lang => Require_Sources_Other_Lang,
          Allow_Duplicate_Basenames  => Allow_Duplicate_Basenames,
          Error_On_Unknown_Language  => Error_On_Unknown_Language,
-         Compiler_Driver_Mandatory  => Compiler_Driver_Mandatory);
+         Compiler_Driver_Mandatory  => Compiler_Driver_Mandatory,
+         Require_Obj_Dirs           => Require_Obj_Dirs);
    end Create_Flags;
 
 begin
index 8f95c08b59ff8dffa0b9ef7e4634f0a0a65a3ad1..76eb59aecbb1e7368f032d13499c3a24cb8a6fa8 100644 (file)
@@ -1386,7 +1386,9 @@ package Prj is
       Require_Sources_Other_Lang : Boolean := True;
       Allow_Duplicate_Basenames  : Boolean := True;
       Compiler_Driver_Mandatory  : Boolean := False;
-      Error_On_Unknown_Language  : Boolean := True) return Processing_Flags;
+      Error_On_Unknown_Language  : Boolean := True;
+      Require_Obj_Dirs           : Error_Warning := Error)
+      return Processing_Flags;
    --  Function used to create Processing_Flags structure
    --
    --  If Allow_Duplicate_Basenames, then files with the same base names are
@@ -1410,8 +1412,13 @@ package Prj is
    --
    --  If Error_On_Unknown_Language is true, an error is displayed if some of
    --  the source files listed in the project do not match any naming scheme
+   --
+   --  If Require_Obj_Dirs is true, then all object directories must exist
+   --  (possibly after they have been created automatically if the appropriate
+   --  switches were specified), or an error is raised.
 
    Gprbuild_Flags : constant Processing_Flags;
+   Gprclean_Flags : constant Processing_Flags;
    Gnatmake_Flags : constant Processing_Flags;
    --  Flags used by the various tools. They all display the error messages
    --  through Prj.Err.
@@ -1516,6 +1523,7 @@ private
       Allow_Duplicate_Basenames  : Boolean;
       Compiler_Driver_Mandatory  : Boolean;
       Error_On_Unknown_Language  : Boolean;
+      Require_Obj_Dirs           : Error_Warning;
    end record;
 
    Gprbuild_Flags : constant Processing_Flags :=
@@ -1524,7 +1532,17 @@ private
       Require_Sources_Other_Lang => True,
       Allow_Duplicate_Basenames  => False,
       Compiler_Driver_Mandatory  => True,
-      Error_On_Unknown_Language  => True);
+      Error_On_Unknown_Language  => True,
+      Require_Obj_Dirs           => Error);
+
+   Gprclean_Flags : constant Processing_Flags :=
+     (Report_Error               => null,
+      When_No_Sources            => Warning,
+      Require_Sources_Other_Lang => True,
+      Allow_Duplicate_Basenames  => False,
+      Compiler_Driver_Mandatory  => True,
+      Error_On_Unknown_Language  => True,
+      Require_Obj_Dirs           => Warning);
 
    Gnatmake_Flags : constant Processing_Flags :=
      (Report_Error               => null,
@@ -1532,6 +1550,7 @@ private
       Require_Sources_Other_Lang => False,
       Allow_Duplicate_Basenames  => False,
       Compiler_Driver_Mandatory  => False,
-      Error_On_Unknown_Language  => False);
+      Error_On_Unknown_Language  => False,
+      Require_Obj_Dirs           => Error);
 
 end Prj;