1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2003-2005, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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 the procedure
28 -- VMS_Conversion to convert a VMS command line to the equivalent command
29 -- line with switches for the GNAT tools that the GNAT driver will invoke.
30 -- The qualifier declarations are contained in package VMS_Data.
33 with VMS_Data
; use VMS_Data
;
35 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
39 -- A table to keep the switches on the command line
41 package Last_Switches
is new Table
.Table
42 (Table_Component_Type
=> String_Access
,
43 Table_Index_Type
=> Integer,
46 Table_Increment
=> 100,
47 Table_Name
=> "Gnatcmd.Last_Switches");
49 Normal_Exit
: exception;
50 -- Raise this exception for normal program termination
52 Error_Exit
: exception;
53 -- Raise this exception if error detected
55 Errors
: Natural := 0;
56 -- Count errors detected
58 Display_Command
: Boolean := False;
59 -- Set true if /? switch causes display of generated command (on VMS)
65 -- The command table contains an entry for each command recognized by
66 -- GNATCmd. The entries are represented by an array of records.
68 type Parameter_Type
is
69 -- A parameter is defined as a whitespace bounded string, not begining
70 -- with a slash. (But see note under FILES_OR_WILDCARD).
72 -- A required file or directory parameter
75 -- An optional file or directory parameter
78 -- A parameter that's passed through as is (not canonicalized)
81 -- An unlimited number of whitespace separate file or directory
82 -- parameters including wildcard specifications.
85 -- Un unlimited number of whitespace separated paameters that are
86 -- passed through as is (not canonicalized).
89 -- A comma separated list of files and/or wildcard file specifications.
90 -- A comma preceded by or followed by whitespace is considered as a
91 -- single comma character w/o whitespace.
93 type Parameter_Array
is array (Natural range <>) of Parameter_Type
;
94 type Parameter_Ref
is access all Parameter_Array
;
118 type Alternate_Command
is (Comp
, Ls
, Kr
, Pp
, Prep
);
119 -- Alternate command label for non VMS system use
121 Corresponding_To
: constant array (Alternate_Command
) of Command_Type
:=
127 -- Mapping of alternate commands to commands
129 subtype Real_Command_Type
is Command_Type
range Bind
.. Xref
;
131 type Command_Entry
is record
133 -- Command name for GNAT xxx command
136 -- A usage string, used for error messages
138 Unixcmd
: String_Ptr
;
139 -- Corresponding Unix command
141 Unixsws
: Argument_List_Access
;
142 -- Switches for the Unix command
145 -- When True, the command can only be used on VMS
147 Switches
: Switches_Ptr
;
148 -- Pointer to array of switch strings
150 Params
: Parameter_Ref
;
151 -- Describes the allowable types of parameters.
152 -- Params (1) is the type of the first parameter, etc.
153 -- An empty parameter array means this command takes no parameters.
155 Defext
: String (1 .. 3);
156 -- Default extension. If non-blank, then this extension is supplied by
157 -- default as the extension for any file parameter which does not have
158 -- an extension already.
161 -------------------------
162 -- Internal Structures --
163 -------------------------
165 -- The switches and commands are defined by strings in the previous
166 -- section so that they are easy to modify, but internally, they are
167 -- kept in a more conveniently accessible form described in this
170 -- Commands, command qualifers and options have a similar common format
171 -- so that searching for matching names can be done in a common manner.
173 type Item_Id
is (Id_Command
, Id_Switch
, Id_Option
);
175 type Translation_Type
is
178 -- A qualifier with no options.
179 -- Example: GNAT MAKE /VERBOSE
182 -- A qualifier followed by a list of directories
183 -- Example: GNAT COMPILE /SEARCH=([], [.FOO], [.BAR])
186 -- A qualifier followed by one directory
187 -- Example: GNAT LIBRARY /SET=[.VAXFLOATLIB]
190 -- A qualifier followed by a filename
191 -- Example: GNAT LINK /EXECUTABLE=FOO.EXE
194 -- A qualifier followed by a filename
195 -- Example: GNAT MAKE /PROJECT_FILE=PRJ.GPR
198 -- A qualifier followed by a numeric value.
199 -- Example: GNAT CHOP /FILE_NAME_MAX_LENGTH=39
202 -- A qualifier followed by a quoted string. Only used by
203 -- /IDENTIFICATION qualifier.
204 -- Example: GNAT LINK /IDENTIFICATION="3.14a1 version"
207 -- A qualifier followed by a list of options.
208 -- Example: GNAT COMPILE /REPRESENTATION_INFO=(ARRAYS,OBJECTS)
211 -- A qualifier followed by a list. Only used for
212 -- MAKE /COMPILER_QUALIFIERS /BINDER_QUALIFIERS /LINKER_QUALIFIERS
213 -- (gnatmake -cargs -bargs -largs )
214 -- Example: GNAT MAKE ... /LINKER_QUALIFIERS /VERBOSE FOOBAR.OBJ
217 -- A qualifier passed directly to the linker. Only used
218 -- for LINK and SHARED if no other match is found.
219 -- Example: GNAT LINK FOO.ALI /SYSSHR
222 -- A qualifier followed by a legal linker symbol prefix. Only used
223 -- for BIND /BUILD_LIBRARY (gnatbind -Lxyz).
224 -- Example: GNAT BIND /BUILD_LIBRARY=foobar
227 type Item
(Id
: Item_Id
);
228 type Item_Ptr
is access all Item
;
230 type Item
(Id
: Item_Id
) is record
232 -- Name of the command, switch (with slash) or option
235 -- Pointer to next item on list, always has the same Id value
237 Command
: Command_Type
:= Undefined
;
239 Unix_String
: String_Ptr
:= null;
240 -- Corresponding Unix string. For a command, this is the unix command
241 -- name and possible default switches. For a switch or option it is
242 -- the unix switch string.
249 -- Pointer to list of switch items for the command, linked
250 -- through the Next fields with null terminating the list.
253 -- Usage information, used only for errors and the default
254 -- list of commands output.
256 Params
: Parameter_Ref
;
257 -- Array of parameters
259 Defext
: String (1 .. 3);
260 -- Default extension. If non-blank, then this extension is
261 -- supplied by default as the extension for any file parameter
262 -- which does not have an extension already.
266 Translation
: Translation_Type
;
267 -- Type of switch translation. For all cases, except Options,
268 -- this is the only field needed, since the Unix translation
269 -- is found in Unix_String.
272 -- For the Options case, this field is set to point to a list
273 -- of options item (for this case Unix_String is null in the
274 -- main switch item). The end of the list is marked by null.
279 -- No special fields needed, since Name and Unix_String are
280 -- sufficient to completely described an option.
285 subtype Command_Item
is Item
(Id_Command
);
286 subtype Switch_Item
is Item
(Id_Switch
);
287 subtype Option_Item
is Item
(Id_Option
);
293 -- The switch tables contain an entry for each switch recognized by the
294 -- command processor. It is initialized by procedure Initialize.
296 Command_List
: array (Real_Command_Type
) of Command_Entry
;
302 procedure Initialize
;
303 -- Initialized the switch table Command_List
305 procedure Output_Version
;
306 -- Output the version of this program
308 procedure VMS_Conversion
(The_Command
: out Command_Type
);
309 -- Converts VMS command line to equivalent Unix command line