public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Vincent Celier <celier@adacore.com>
Subject: [Ada] GNAT driver with a project file and a single main - switches
Date: Thu, 03 Jan 2013 11:13:00 -0000	[thread overview]
Message-ID: <20130103111300.GA27599@adacore.com> (raw)

[-- 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,

                 reply	other threads:[~2013-01-03 11:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130103111300.GA27599@adacore.com \
    --to=charlet@adacore.com \
    --cc=celier@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).