Patchwork [Ada] Do not create object/exec dir for projects with no sources

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 4, 2010, 1:43 p.m.
Message ID <20101004134339.GA19684@adacore.com>
Download mbox | patch
Permalink /patch/66654/
State New
Headers show

Comments

Arnaud Charlet - Oct. 4, 2010, 1:43 p.m.
For a non extending project that declare no sources, non existent
object or exec directories are not created if gnatmake switch -p
or --create-missing-dirs is used.

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

2010-10-04  Vincent Celier  <celier@adacore.com>

	* prj-nmsc.adb (Get_Directories): For non extending projects that
	declare that they have no sources, do not create a non existing object
	or exec directory if builder switch -p is used.

Patch

Index: prj-nmsc.adb
===================================================================
--- prj-nmsc.adb	(revision 164906)
+++ prj-nmsc.adb	(working copy)
@@ -5280,10 +5280,18 @@  package body Prj.Nmsc is
          Recursive_Dirs.Reset (Visited);
       end Find_Source_Dirs;
 
-   --  Start of processing for Get_Directories
-
       Dir_Exists : Boolean;
 
+      No_Sources : constant Boolean :=
+        (((not Source_Files.Default) and then Source_Files.Values = Nil_String)
+         or else
+         ((not Source_Dirs.Default) and then Source_Dirs.Values = Nil_String)
+         or else
+         ((not Languages.Default) and then Languages.Values = Nil_String))
+        and then Project.Extends = No_Project;
+
+   --  Start of processing for Get_Directories
+
    begin
       if Current_Verbosity = High then
          Write_Line ("Starting to look for directories");
@@ -5292,14 +5300,7 @@  package body Prj.Nmsc is
       --  Set the object directory to its default which may be nil, if there
       --  is no sources in the project.
 
-      if (((not Source_Files.Default)
-             and then Source_Files.Values = Nil_String)
-          or else
-           ((not Source_Dirs.Default) and then Source_Dirs.Values = Nil_String)
-              or else
-           ((not Languages.Default) and then Languages.Values = Nil_String))
-        and then Project.Extends = No_Project
-      then
+      if No_Sources then
          Project.Object_Directory := No_Path_Information;
       else
          Project.Object_Directory := Project.Directory;
@@ -5316,7 +5317,7 @@  package body Prj.Nmsc is
                "Object_Dir cannot be empty",
                Object_Dir.Location, Project);
 
-         else
+         elsif not No_Sources then
             --  We check that the specified object directory does exist.
             --  However, even when it doesn't exist, we set it to a default
             --  value. This is for the benefit of tools that recover from
@@ -5348,9 +5349,7 @@  package body Prj.Nmsc is
             end if;
          end if;
 
-      elsif Project.Object_Directory /= No_Path_Information
-        and then Subdirs /= null
-      then
+      elsif not No_Sources and then Subdirs /= null then
          Name_Len := 1;
          Name_Buffer (1) := '.';
          Locate_Directory
@@ -5389,7 +5388,7 @@  package body Prj.Nmsc is
                "Exec_Dir cannot be empty",
                Exec_Dir.Location, Project);
 
-         else
+         elsif not No_Sources then
             --  We check that the specified exec directory does exist
 
             Locate_Directory