1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2008, 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 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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package together with a child package appropriate to the client tool
27 -- scans switches. Note that the body of the appropriate Usage package must be
28 -- coordinated with the switches that are recognized by this package. These
29 -- Usage packages also act as the official documentation for the switches
30 -- that are recognized. In addition, package Debug documents the otherwise
31 -- undocumented debug switches that are also recognized.
34 with Types
; use Types
;
42 -- Common switches for GNU tools
44 Version_Switch
: constant String := "--version";
45 Help_Switch
: constant String := "--help";
53 -- Print tool-specific part of --help message
54 procedure Check_Version_And_Help_G
56 Initial_Year
: String;
57 Version_String
: String := Gnatvsn
.Gnat_Version_String
);
58 -- Check if switches --version or --help is used. If one of this switch is
59 -- used, issue the proper messages and end the process.
61 procedure Display_Version
63 Initial_Year
: String;
64 Version_String
: String := Gnatvsn
.Gnat_Version_String
);
65 -- Display version of a tool when switch --version is used
67 function Is_Switch
(Switch_Chars
: String) return Boolean;
68 -- Returns True iff Switch_Chars is at least two characters long, and the
69 -- first character is an hyphen ('-').
71 function Is_Front_End_Switch
(Switch_Chars
: String) return Boolean;
72 -- Returns True iff Switch_Chars represents a front-end switch, i.e. it
73 -- starts with -I, -gnat or -?RTS.
77 -- This section contains some common routines used by the tool dependent
78 -- child packages (there is one such child package for each tool that
79 -- uses Switches to scan switches - Compiler/gnatbind/gnatmake/.
81 Switch_Max_Value
: constant := 999_999
;
82 -- Maximum value permitted in switches that take a value
85 (Switch_Chars
: String;
90 -- Scan natural integer parameter for switch. On entry, Ptr points just
91 -- past the switch character, on exit it points past the last digit of the
95 (Switch_Chars
: String;
100 -- Scan positive integer parameter for switch. On entry, Ptr points just
101 -- past the switch character, on exit it points past the last digit of the
104 procedure Bad_Switch
(Switch
: Character);
105 procedure Bad_Switch
(Switch
: String);
106 -- Fail with an appropriate message when a switch is not recognized