Patchwork [Ada] New gnatls switch -aPdir

login
register
mail settings
Submitter Arnaud Charlet
Date April 24, 2013, 2:33 p.m.
Message ID <20130424143330.GA21253@adacore.com>
Download mbox | patch
Permalink /patch/239214/
State New
Headers show

Comments

Arnaud Charlet - April 24, 2013, 2:33 p.m.
A new switch -aPdir is added to gnatls. When gnatls is called with one
or several switches -aPdir and also switch -v, the directories specified
in the -aP switches are displayed immediately after the current directory
in the Project Search Path.
A new warning is issued by gnatls for switches that are not recognized by
gnatls.
The GNAT driver when called as "gnat ls/list -aPdir ..." will also used
the switch -aPdir in its invocation of gnatls.

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

2013-04-24  Vincent Celier  <celier@adacore.com>

	* gnat_ugn.texi: Document new gnatls switch -aPdir.
	* gnatcmd.adb: Pass switch -aP<dir> to gnatls.
	* gnatls.adb (Scan_Ls_Arg): Process new switch -aP<dir>. Issue
	a warning for unknown switches.
	(Usage): Add line for new switch -aPdir.

Patch

Index: gnatcmd.adb
===================================================================
--- gnatcmd.adb	(revision 198226)
+++ gnatcmd.adb	(working copy)
@@ -1766,8 +1766,17 @@ 
                        (Root_Environment.Project_Path,
                         Argv (Argv'First + 3 .. Argv'Last));
 
-                     Remove_Switch (Arg_Num);
+                     --  Pass -aPdir to gnatls
 
+                     if The_Command = List then
+                        Arg_Num := Arg_Num + 1;
+
+                     --  but not to other tools
+
+                     else
+                        Remove_Switch (Arg_Num);
+                     end if;
+
                   --  -eL  Follow links for files
 
                   elsif Argv.all = "-eL" then
Index: gnat_ugn.texi
===================================================================
--- gnat_ugn.texi	(revision 198236)
+++ gnat_ugn.texi	(working copy)
@@ -16393,6 +16393,10 @@ 
 Source path manipulation. Same meaning as the equivalent @command{gnatmake}
 flags (@pxref{Switches for gnatmake}).
 
+@item ^-aP^/ADD_PROJECT_SEARCH_DIR=^@var{dir}
+@cindex @option{^-aP^/ADD_PROJECT_SEARCH_DIR=^} (@code{gnatls})
+Add @var{dir} at the beginning of the project search dir.
+
 @item --RTS=@var{rts-path}
 @cindex @option{--RTS} (@code{gnatls})
 Specifies the default location of the runtime library. Same meaning as the
Index: gnatls.adb
===================================================================
--- gnatls.adb	(revision 198221)
+++ gnatls.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -1253,6 +1253,8 @@ 
       FD  : File_Descriptor;
       Len : Integer;
 
+      OK : Boolean;
+
    begin
       pragma Assert (Argv'First = 1);
 
@@ -1260,6 +1262,7 @@ 
          return;
       end if;
 
+      OK := True;
       if Argv (1) = '-' then
          if Argv'Length = 1 then
             Fail ("switch character cannot be followed by a blank");
@@ -1297,6 +1300,11 @@ 
          elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aL" then
             Add_Lib_Dir (Argv (4 .. Argv'Last));
 
+         --  Processing for -aP<dir>
+
+         elsif Argv'Length > 3 and then Argv (1 .. 3) = "-aP" then
+            Add_Directories (Prj_Path, Argv (4 .. Argv'Last));
+
          --  Processing for -nostdinc
 
          elsif Argv (2 .. Argv'Last) = "nostdinc" then
@@ -1316,7 +1324,7 @@ 
                when 'l' => License                   := True;
                when 'V' => Very_Verbose_Mode         := True;
 
-               when others => null;
+               when others => OK := False;
             end case;
 
          --  Processing for -files=file
@@ -1396,6 +1404,9 @@ 
                Opt.No_Stdinc := True;
                Opt.RTS_Switch := True;
             end if;
+
+         else
+            OK := False;
          end if;
 
       --  If not a switch, it must be a file name
@@ -1403,6 +1414,13 @@ 
       else
          Add_File (Argv);
       end if;
+
+      if not OK then
+         Write_Str ("warning: unknown switch """);
+         Write_Str (Argv);
+         Write_Line ("""");
+      end if;
+
    end Scan_Ls_Arg;
 
    -----------
@@ -1484,6 +1502,11 @@ 
       Write_Str ("  -aOdir     specify object files search path");
       Write_Eol;
 
+      --  Line for -aP switch
+
+      Write_Str ("  -aPdir     specify project search path");
+      Write_Eol;
+
       --  Line for -I switch
 
       Write_Str ("  -Idir      like -aIdir -aOdir");