make.adb (Gnatmake): Do not fail when the main project has no object directory.
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 10 Feb 2005 13:54:58 +0000 (14:54 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 10 Feb 2005 13:54:58 +0000 (14:54 +0100)
* make.adb (Gnatmake): Do not fail when the main project has no object
directory.

From-SVN: r94817

gcc/ada/make.adb

index eb57773..e799e05 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2004 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2005 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- --
@@ -4079,63 +4079,65 @@ package body Make is
 
       if Main_Project /= No_Project then
 
-         if Projects.Table (Main_Project).Object_Directory = No_Name then
-            Make_Failed ("no sources to compile");
-         end if;
+         if Projects.Table (Main_Project).Object_Directory /= No_Name then
 
-         --  Change the current directory to the object directory of the main
-         --  project.
+            --  Change the current directory to the object directory of
+            --  the main project.
 
-         begin
-            Project_Object_Directory := No_Project;
-            Change_To_Object_Directory (Main_Project);
+            begin
+               Project_Object_Directory := No_Project;
+               Change_To_Object_Directory (Main_Project);
 
-         exception
-            when Directory_Error =>
+            exception
+               when Directory_Error =>
 
-               --  This should never happen. But, if it does, display the
-               --  content of the parent directory of the obj dir.
+                  --  This should never happen. But, if it does, display the
+                  --  content of the parent directory of the obj dir.
 
-               declare
-                  Parent : constant Dir_Name_Str :=
-                    Dir_Name
-                      (Get_Name_String
-                           (Projects.Table (Main_Project).Object_Directory));
-                  Dir : Dir_Type;
-                  Str : String (1 .. 200);
-                  Last : Natural;
+                  declare
+                     Parent : constant Dir_Name_Str :=
+                                Dir_Name
+                                  (Get_Name_String
+                                     (Projects.Table
+                                        (Main_Project).Object_Directory));
 
-               begin
-                  Write_Str ("Contents of directory """);
-                  Write_Str (Parent);
-                  Write_Line (""":");
+                     Dir  : Dir_Type;
+                     Str  : String (1 .. 200);
+                     Last : Natural;
 
-                  Open (Dir, Parent);
+                  begin
+                     Write_Str ("Contents of directory """);
+                     Write_Str (Parent);
+                     Write_Line (""":");
 
-                  loop
-                     Read (Dir, Str, Last);
-                     exit when Last = 0;
-                     Write_Str ("   ");
-                     Write_Line (Str (1 .. Last));
-                  end loop;
+                     Open (Dir, Parent);
 
-                  Close (Dir);
+                     loop
+                        Read (Dir, Str, Last);
+                        exit when Last = 0;
+                        Write_Str ("   ");
+                        Write_Line (Str (1 .. Last));
+                     end loop;
 
-               exception
-                  when X : others =>
-                     Write_Line ("(unexpected exception)");
-                     Write_Line (Exception_Information (X));
+                     Close (Dir);
 
-                     if Is_Open (Dir) then
-                        Close (Dir);
-                     end if;
-               end;
+                  exception
+                     when X : others =>
+                        Write_Line ("(unexpected exception)");
+                        Write_Line (Exception_Information (X));
 
-               Make_Failed ("unable to change working directory to """,
-                            Get_Name_String
-                             (Projects.Table (Main_Project).Object_Directory),
-                            """");
-         end;
+                        if Is_Open (Dir) then
+                           Close (Dir);
+                        end if;
+                  end;
+
+                  Make_Failed
+                    ("unable to change working directory to """,
+                     Get_Name_String
+                       (Projects.Table (Main_Project).Object_Directory),
+                     """");
+            end;
+         end if;
 
          --  Source file lookups should be cached for efficiency.
          --  Source files are not supposed to change.