1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- V M S _ C O N V --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 2003-2008, Free Software Foundation, Inc. --
|
10 |
|
|
-- --
|
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 3, 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 COPYING3. If not, go to --
|
19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
20 |
|
|
-- --
|
21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
23 |
|
|
-- --
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- This package is part of the GNAT driver. It contains the procedure
|
27 |
|
|
-- VMS_Conversion to convert a VMS command line to the equivalent command
|
28 |
|
|
-- line with switches for the GNAT tools that the GNAT driver will invoke.
|
29 |
|
|
-- The qualifier declarations are contained in package VMS_Data.
|
30 |
|
|
|
31 |
|
|
with Table;
|
32 |
|
|
with VMS_Data; use VMS_Data;
|
33 |
|
|
|
34 |
|
|
with GNAT.OS_Lib; use GNAT.OS_Lib;
|
35 |
|
|
|
36 |
|
|
package VMS_Conv is
|
37 |
|
|
|
38 |
|
|
-- A table to keep the switches on the command line
|
39 |
|
|
|
40 |
|
|
package Last_Switches is new Table.Table
|
41 |
|
|
(Table_Component_Type => String_Access,
|
42 |
|
|
Table_Index_Type => Integer,
|
43 |
|
|
Table_Low_Bound => 1,
|
44 |
|
|
Table_Initial => 20,
|
45 |
|
|
Table_Increment => 100,
|
46 |
|
|
Table_Name => "Gnatcmd.Last_Switches");
|
47 |
|
|
|
48 |
|
|
Normal_Exit : exception;
|
49 |
|
|
-- Raise this exception for normal program termination
|
50 |
|
|
|
51 |
|
|
Error_Exit : exception;
|
52 |
|
|
-- Raise this exception if error detected
|
53 |
|
|
|
54 |
|
|
Errors : Natural := 0;
|
55 |
|
|
-- Count errors detected
|
56 |
|
|
|
57 |
|
|
Display_Command : Boolean := False;
|
58 |
|
|
-- Set true if /? switch causes display of generated command (on VMS)
|
59 |
|
|
|
60 |
|
|
-------------------
|
61 |
|
|
-- Command Table --
|
62 |
|
|
-------------------
|
63 |
|
|
|
64 |
|
|
-- The command table contains an entry for each command recognized by
|
65 |
|
|
-- GNATCmd. The entries are represented by an array of records.
|
66 |
|
|
|
67 |
|
|
type Parameter_Type is
|
68 |
|
|
-- A parameter is defined as a whitespace bounded string, not beginning
|
69 |
|
|
-- with a slash. (But see note under FILES_OR_WILDCARD).
|
70 |
|
|
(File,
|
71 |
|
|
-- A required file or directory parameter
|
72 |
|
|
|
73 |
|
|
Optional_File,
|
74 |
|
|
-- An optional file or directory parameter
|
75 |
|
|
|
76 |
|
|
Other_As_Is,
|
77 |
|
|
-- A parameter that's passed through as is (not canonicalized)
|
78 |
|
|
|
79 |
|
|
Unlimited_Files,
|
80 |
|
|
-- An unlimited number of whitespace separate file or directory
|
81 |
|
|
-- parameters including wildcard specifications.
|
82 |
|
|
|
83 |
|
|
Unlimited_As_Is,
|
84 |
|
|
-- An unlimited number of whitespace separated parameters that are
|
85 |
|
|
-- passed through as is (not canonicalized).
|
86 |
|
|
|
87 |
|
|
Files_Or_Wildcard);
|
88 |
|
|
-- A comma separated list of files and/or wildcard file specifications.
|
89 |
|
|
-- A comma preceded by or followed by whitespace is considered as a
|
90 |
|
|
-- single comma character w/o whitespace.
|
91 |
|
|
|
92 |
|
|
type Parameter_Array is array (Natural range <>) of Parameter_Type;
|
93 |
|
|
type Parameter_Ref is access all Parameter_Array;
|
94 |
|
|
|
95 |
|
|
type Command_Type is
|
96 |
|
|
(Bind,
|
97 |
|
|
Chop,
|
98 |
|
|
Clean,
|
99 |
|
|
Compile,
|
100 |
|
|
Check,
|
101 |
|
|
Sync,
|
102 |
|
|
Elim,
|
103 |
|
|
Find,
|
104 |
|
|
Krunch,
|
105 |
|
|
Link,
|
106 |
|
|
List,
|
107 |
|
|
Make,
|
108 |
|
|
Metric,
|
109 |
|
|
Name,
|
110 |
|
|
Preprocess,
|
111 |
|
|
Pretty,
|
112 |
|
|
Shared,
|
113 |
|
|
Stack,
|
114 |
|
|
Stub,
|
115 |
|
|
Xref,
|
116 |
|
|
Undefined);
|
117 |
|
|
|
118 |
|
|
type Alternate_Command is (Comp, Ls, Kr, Pp, Prep);
|
119 |
|
|
-- Alternate command label for non VMS system use
|
120 |
|
|
|
121 |
|
|
Corresponding_To : constant array (Alternate_Command) of Command_Type :=
|
122 |
|
|
(Comp => Compile,
|
123 |
|
|
Ls => List,
|
124 |
|
|
Kr => Krunch,
|
125 |
|
|
Prep => Preprocess,
|
126 |
|
|
Pp => Pretty);
|
127 |
|
|
-- Mapping of alternate commands to commands
|
128 |
|
|
|
129 |
|
|
subtype Real_Command_Type is Command_Type range Bind .. Xref;
|
130 |
|
|
|
131 |
|
|
type Command_Entry is record
|
132 |
|
|
Cname : String_Ptr;
|
133 |
|
|
-- Command name for GNAT xxx command
|
134 |
|
|
|
135 |
|
|
Usage : String_Ptr;
|
136 |
|
|
-- A usage string, used for error messages
|
137 |
|
|
|
138 |
|
|
Unixcmd : String_Ptr;
|
139 |
|
|
-- Corresponding Unix command
|
140 |
|
|
|
141 |
|
|
Unixsws : Argument_List_Access;
|
142 |
|
|
-- Switches for the Unix command
|
143 |
|
|
|
144 |
|
|
VMS_Only : Boolean;
|
145 |
|
|
-- When True, the command can only be used on VMS
|
146 |
|
|
|
147 |
|
|
Switches : Switches_Ptr;
|
148 |
|
|
-- Pointer to array of switch strings
|
149 |
|
|
|
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.
|
154 |
|
|
|
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.
|
159 |
|
|
end record;
|
160 |
|
|
|
161 |
|
|
-------------------
|
162 |
|
|
-- Switch Tables --
|
163 |
|
|
-------------------
|
164 |
|
|
|
165 |
|
|
-- The switch tables contain an entry for each switch recognized by the
|
166 |
|
|
-- command processor. It is initialized by procedure Initialize.
|
167 |
|
|
|
168 |
|
|
Command_List : array (Real_Command_Type) of Command_Entry;
|
169 |
|
|
|
170 |
|
|
----------------
|
171 |
|
|
-- Procedures --
|
172 |
|
|
----------------
|
173 |
|
|
|
174 |
|
|
procedure Initialize;
|
175 |
|
|
-- Initialized the switch table Command_List
|
176 |
|
|
|
177 |
|
|
procedure Output_Version;
|
178 |
|
|
-- Output the version of this program
|
179 |
|
|
|
180 |
|
|
procedure VMS_Conversion (The_Command : out Command_Type);
|
181 |
|
|
-- Converts VMS command line to equivalent Unix command line
|
182 |
|
|
|
183 |
|
|
end VMS_Conv;
|