diff mbox

[Ada] GNAT driver, ASIS tools and switch -files=

Message ID 20100614091741.GA18447@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 14, 2010, 9:17 a.m. UTC
When the gnat driver is invoked for gnatpp, gnatmetric or gnatstack with
a project file, if switch -files is used, then the ASIS tool is invoked
without the list of all sources of the project, even if no source is
specified in the gnat driver invocation.
The test for this is to invoke the gnat driver with a project file and
-files= and to check that the ASIS tool is called with only one switch
-files.

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

2010-06-14  Vincent Celier  <celier@adacore.com>

	* gnatcmd.adb (Check_Files): Do not invoke the tool with all the
	sources of the project if a switch -files= is used.
diff mbox

Patch

Index: gnatcmd.adb
===================================================================
--- gnatcmd.adb	(revision 160705)
+++ gnatcmd.adb	(working copy)
@@ -209,9 +209,9 @@  procedure GNATCmd is
 
    procedure Check_Files;
    --  For GNAT LIST, GNAT PRETTY, GNAT METRIC, and GNAT STACK, check if a
-   --  project file is specified, without any file arguments. If it is the
-   --  case, invoke the GNAT tool with the proper list of files, derived from
-   --  the sources of the project.
+   --  project file is specified, without any file arguments and without a
+   --  switch -files=. If it is the case, invoke the GNAT tool with the proper
+   --  list of files, derived from the sources of the project.
 
    function Check_Project
      (Project      : Project_Id;
@@ -314,10 +314,17 @@  procedure GNATCmd is
       Success     : Boolean;
 
    begin
-      --  Check if there is at least one argument that is not a switch
+      --  Check if there is at least one argument that is not a switch or if
+      --  there is a -files= switch.
 
       for Index in 1 .. Last_Switches.Last loop
-         if Last_Switches.Table (Index) (1) /= '-' then
+         if Last_Switches.Table (Index).all'Length > 7 and then
+           Last_Switches.Table (Index) (1 .. 7) = "-files="
+         then
+            Add_Sources := False;
+            exit;
+
+         elsif Last_Switches.Table (Index) (1) /= '-' then
             if Index = 1
               or else
                 (The_Command = Check
@@ -346,8 +353,8 @@  procedure GNATCmd is
          end if;
       end loop;
 
-      --  If all arguments were switches, add the path names of all the sources
-      --  of the main project.
+      --  If all arguments are switchesand there is no switch -files=, add the
+      --  path names of all the sources of the main project.
 
       if Add_Sources then