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 <cel...@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.
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,