1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2003 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This package is part of the GNAT driver. It contains a procedure
28 -- VMS_Conversion to convert the command line in VMS form to the equivalent
29 -- command line with switches for the GNAT tools that the GNAT driver will
32 -- The qualifier declarations are contained in package VMS_Data.
35 with VMS_Data
; use VMS_Data
;
37 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
41 -- A table to keep the switches on the command line
43 package Last_Switches
is new Table
.Table
44 (Table_Component_Type
=> String_Access
,
45 Table_Index_Type
=> Integer,
48 Table_Increment
=> 100,
49 Table_Name
=> "Gnatcmd.Last_Switches");
51 Normal_Exit
: exception;
52 -- Raise this exception for normal program termination
54 Error_Exit
: exception;
55 -- Raise this exception if error detected
57 Errors
: Natural := 0;
58 -- Count errors detected
60 Display_Command
: Boolean := False;
61 -- Set true if /? switch causes display of generated command (on VMS)
67 -- The command table contains an entry for each command recognized by
68 -- GNATCmd. The entries are represented by an array of records.
70 type Parameter_Type
is
71 -- A parameter is defined as a whitespace bounded string, not begining
72 -- with a slash. (But see note under FILES_OR_WILDCARD).
74 -- A required file or directory parameter.
77 -- An optional file or directory parameter.
80 -- A parameter that's passed through as is (not canonicalized)
83 -- An unlimited number of whitespace separate file or directory
84 -- parameters including wildcard specifications.
87 -- Un unlimited number of whitespace separated paameters that are
88 -- passed through as is (not canonicalized).
91 -- A comma separated list of files and/or wildcard file specifications.
92 -- A comma preceded by or followed by whitespace is considered as a
93 -- single comma character w/o whitespace.
95 type Parameter_Array
is array (Natural range <>) of Parameter_Type
;
96 type Parameter_Ref
is access all Parameter_Array
;
99 (Bind
, Chop
, Clean
, Compile
, Elim
, Find
, Krunch
, Library
, Link
, List
,
100 Make
, Name
, Preprocess
, Pretty
, Shared
, Stub
, Xref
, Undefined
);
102 type Alternate_Command
is (Comp
, Ls
, Kr
, Pp
, Prep
);
103 -- Alternate command libel for non VMS system
105 Corresponding_To
: constant array (Alternate_Command
) of Command_Type
:=
111 -- Mapping of alternate commands to commands
113 subtype Real_Command_Type
is Command_Type
range Bind
.. Xref
;
115 type Command_Entry
is record
117 -- Command name for GNAT xxx command
120 -- A usage string, used for error messages
122 Unixcmd
: String_Ptr
;
123 -- Corresponding Unix command
125 Unixsws
: Argument_List_Access
;
126 -- Switches for the Unix command
129 -- When True, the command can only be used on VMS
131 Switches
: Switches_Ptr
;
132 -- Pointer to array of switch strings
134 Params
: Parameter_Ref
;
135 -- Describes the allowable types of parameters.
136 -- Params (1) is the type of the first parameter, etc.
137 -- An empty parameter array means this command takes no parameters.
139 Defext
: String (1 .. 3);
140 -- Default extension. If non-blank, then this extension is supplied by
141 -- default as the extension for any file parameter which does not have
142 -- an extension already.
145 -------------------------
146 -- INTERNAL STRUCTURES --
147 -------------------------
149 -- The switches and commands are defined by strings in the previous
150 -- section so that they are easy to modify, but internally, they are
151 -- kept in a more conveniently accessible form described in this
154 -- Commands, command qualifers and options have a similar common format
155 -- so that searching for matching names can be done in a common manner.
157 type Item_Id
is (Id_Command
, Id_Switch
, Id_Option
);
159 type Translation_Type
is
162 -- A qualifier with no options.
163 -- Example: GNAT MAKE /VERBOSE
166 -- A qualifier followed by a list of directories
167 -- Example: GNAT COMPILE /SEARCH=([], [.FOO], [.BAR])
170 -- A qualifier followed by one directory
171 -- Example: GNAT LIBRARY /SET=[.VAXFLOATLIB]
174 -- A qualifier followed by a filename
175 -- Example: GNAT LINK /EXECUTABLE=FOO.EXE
178 -- A qualifier followed by a filename
179 -- Example: GNAT MAKE /PROJECT_FILE=PRJ.GPR
182 -- A qualifier followed by a numeric value.
183 -- Example: GNAT CHOP /FILE_NAME_MAX_LENGTH=39
186 -- A qualifier followed by a quoted string. Only used by
187 -- /IDENTIFICATION qualifier.
188 -- Example: GNAT LINK /IDENTIFICATION="3.14a1 version"
191 -- A qualifier followed by a list of options.
192 -- Example: GNAT COMPILE /REPRESENTATION_INFO=(ARRAYS,OBJECTS)
195 -- A qualifier followed by a list. Only used for
196 -- MAKE /COMPILER_QUALIFIERS /BINDER_QUALIFIERS /LINKER_QUALIFIERS
197 -- (gnatmake -cargs -bargs -largs )
198 -- Example: GNAT MAKE ... /LINKER_QUALIFIERS /VERBOSE FOOBAR.OBJ
201 -- A qualifier passed directly to the linker. Only used
202 -- for LINK and SHARED if no other match is found.
203 -- Example: GNAT LINK FOO.ALI /SYSSHR
206 -- A qualifier followed by a legal linker symbol prefix. Only used
207 -- for BIND /BUILD_LIBRARY (gnatbind -Lxyz).
208 -- Example: GNAT BIND /BUILD_LIBRARY=foobar
211 type Item
(Id
: Item_Id
);
212 type Item_Ptr
is access all Item
;
214 type Item
(Id
: Item_Id
) is record
216 -- Name of the command, switch (with slash) or option
219 -- Pointer to next item on list, always has the same Id value
221 Command
: Command_Type
:= Undefined
;
223 Unix_String
: String_Ptr
:= null;
224 -- Corresponding Unix string. For a command, this is the unix command
225 -- name and possible default switches. For a switch or option it is
226 -- the unix switch string.
233 -- Pointer to list of switch items for the command, linked
234 -- through the Next fields with null terminating the list.
237 -- Usage information, used only for errors and the default
238 -- list of commands output.
240 Params
: Parameter_Ref
;
241 -- Array of parameters
243 Defext
: String (1 .. 3);
244 -- Default extension. If non-blank, then this extension is
245 -- supplied by default as the extension for any file parameter
246 -- which does not have an extension already.
250 Translation
: Translation_Type
;
251 -- Type of switch translation. For all cases, except Options,
252 -- this is the only field needed, since the Unix translation
253 -- is found in Unix_String.
256 -- For the Options case, this field is set to point to a list
257 -- of options item (for this case Unix_String is null in the
258 -- main switch item). The end of the list is marked by null.
263 -- No special fields needed, since Name and Unix_String are
264 -- sufficient to completely described an option.
269 subtype Command_Item
is Item
(Id_Command
);
270 subtype Switch_Item
is Item
(Id_Switch
);
271 subtype Option_Item
is Item
(Id_Option
);
277 -- The switch tables contain an entry for each switch recognized by the
278 -- command processor. It is initialized by procedure Initialize.
280 Command_List
: array (Real_Command_Type
) of Command_Entry
;
286 procedure Initialize
;
287 -- Initialized the switch table Command_List
289 procedure Output_Version
;
290 -- Output the version of this program
292 procedure VMS_Conversion
(The_Command
: out Command_Type
);
293 -- Converts VMS command line to equivalent Unix command line