Patchwork [Ada] gnatmake --subdirs without project file, binding and linking

login
register
mail settings
Submitter Arnaud Charlet
Date July 12, 2012, 10:33 a.m.
Message ID <20120712103335.GA17650@adacore.com>
Download mbox | patch
Permalink /patch/170633/
State New
Headers show

Comments

Arnaud Charlet - July 12, 2012, 10:33 a.m.
When gnatmake is invoked with --subdirs=, but without -P, the binder
generated files and the executable are put by default in the specified
subdirectory.

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

2012-07-12  Vincent Celier  <celier@adacore.com>

	* make.adb (Binding_Phase): If --subdirs was used, but not
	-P, change the working directory to the specified subdirectory
	before invoking gnatbind.
	(Linking_Phase): If --subdirs was used, but not -P, change the working
	directory to the specified subdirectory before invoking gnatlink.

Patch

Index: make.adb
===================================================================
--- make.adb	(revision 189432)
+++ make.adb	(working copy)
@@ -4435,6 +4435,13 @@ 
          declare
             Success : Boolean := False;
          begin
+            --  If gnatmake was invoked with --subdirs and no project file,
+            --  put the executable in the subdirectory specified.
+
+            if Prj.Subdirs /= null and then Main_Project = No_Project then
+               Change_Dir (Object_Directory_Path.all);
+            end if;
+
             Link (Main_ALI_File,
                   Link_With_Shared_Libgcc.all &
                   Args (Args'First .. Last_Arg),
@@ -4571,6 +4578,13 @@ 
          end if;
       end if;
 
+      --  If gnatmake was invoked with --subdirs and no project file, put the
+      --  binder generated files in the subdirectory specified.
+
+      if Main_Project = No_Project and then Prj.Subdirs /= null then
+         Change_Dir (Object_Directory_Path.all);
+      end if;
+
       begin
          Bind (Main_ALI_File,
                Bind_Shared.all & Args (Args'First .. Last_Arg));