public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] GNAT driver with a project file and a single main - switches
@ 2013-01-03 11:13 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2013-01-03 11:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Vincent Celier

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

When the GNAT driver is called with a project file and a single main
specified as an absolute path, the specific switches that are declared
for the main source were not taken into account. This patch fixes this.
The specific switches are now taken into account.

Example:

prj.gpr:
project Prj is
   package Pretty_Printer is
      for Default_Switches ("Ada") use ("-nD");
      for Switches ("pkg.ads") use ("-kU");
   end Pretty_Printer;
end Prj;

Invoking "gnat pretty -P prj.gpr /path/to/pkg.ads" should result in
gnatpp invoked with -aU, not -nD.

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

2013-01-03  Vincent Celier  <celier@adacore.com>

	* gnatcmd.adb (GNATCmd): If a single main has been specified
	as an absolute path, use its simple file name to find specific
	switches, instead of the absolute path.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1156 bytes --]

Index: gnatcmd.adb
===================================================================
--- gnatcmd.adb	(revision 194841)
+++ gnatcmd.adb	(working copy)
@@ -1999,7 +1999,19 @@
                           In_Arrays => Element.Decl.Arrays,
                           Shared    => Project_Tree.Shared);
                      Name_Len := 0;
-                     Add_Str_To_Name_Buffer (Main.all);
+
+                     --  If the single main has been specified as an absolute
+                     --  path, we use only the simple file name. If the
+                     --  absolute path is incorrect, an error will be reported
+                     --  by the underlying tool and it does not make a
+                     --  difference what switches are used.
+
+                     if Is_Absolute_Path (Main.all) then
+                        Add_Str_To_Name_Buffer (File_Name (Main.all));
+                     else
+                        Add_Str_To_Name_Buffer (Main.all);
+                     end if;
+
                      The_Switches := Prj.Util.Value_Of
                        (Index     => Name_Find,
                         Src_Index => 0,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-03 11:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-03 11:13 [Ada] GNAT driver with a project file and a single main - switches Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).