1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 2001-2002 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 ------------------------------------------------------------------------------
28 with Debug
; use Debug
;
29 with Osint
; use Osint
;
32 with System
.WCh_Con
; use System
.WCh_Con
;
34 package body Switch
.B
is
36 --------------------------
37 -- Scan_Binder_Switches --
38 --------------------------
40 procedure Scan_Binder_Switches
(Switch_Chars
: String) is
41 Ptr
: Integer := Switch_Chars
'First;
42 Max
: Integer := Switch_Chars
'Last;
46 -- Skip past the initial character (must be the switch character)
54 -- A little check, "gnat" at the start of a switch is not allowed
55 -- except for the compiler
57 if Switch_Chars
'Last >= Ptr
+ 3
58 and then Switch_Chars
(Ptr
.. Ptr
+ 3) = "gnat"
60 Osint
.Fail
("invalid switch: """, Switch_Chars
, """"
61 & " (gnat not needed here)");
65 -- Loop to scan through switches given in switch string
68 C
:= Switch_Chars
(Ptr
);
72 -- Processing for A switch
77 Ada_Bind_File
:= True;
79 -- Processing for b switch
85 -- Processing for c switch
92 -- Processing for C switch
97 Ada_Bind_File
:= False;
99 -- Processing for d switch
103 -- Note: for the debug switch, the remaining characters in this
104 -- switch field must all be debug flags, since all valid switch
105 -- characters are also valid debug characters. This switch is not
106 -- documented on purpose because it is only used by the
109 -- Loop to scan out debug flags
113 C
:= Switch_Chars
(Ptr
);
114 exit when C
= ASCII
.NUL
or else C
= '/' or else C
= '-';
116 if C
in '1' .. '9' or else
117 C
in 'a' .. 'z' or else
126 -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This
127 -- is for backwards compatibility with old versions and usage.
129 if Debug_Flag_XX
then
130 Zero_Cost_Exceptions_Set
:= True;
131 Zero_Cost_Exceptions_Val
:= True;
136 -- Processing for e switch
140 Elab_Dependency_Output
:= True;
142 -- Processing for E switch
146 Exception_Tracebacks
:= True;
148 -- Processing for f switch
152 Force_RM_Elaboration_Order
:= True;
154 -- Processing for g switch
160 C
:= Switch_Chars
(Ptr
);
162 if C
in '0' .. '3' then
165 (Switch_Chars
(Ptr
)) - Character'Pos ('0');
173 -- Processing for h switch
177 Usage_Requested
:= True;
179 -- Processing for i switch
187 C
:= Switch_Chars
(Ptr
);
196 Identifier_Character_Set
:= C
;
202 -- Processing for K switch
206 Output_Linker_Option_List
:= True;
208 -- Processing for l switch
212 Elab_Order_Output
:= True;
214 -- Processing for m switch
218 Scan_Pos
(Switch_Chars
, Max
, Ptr
, Maximum_Errors
);
220 -- Processing for n switch
224 Bind_Main_Program
:= False;
226 -- Note: The -L option of the binder also implies -n, so
227 -- any change here must also be reflected in the processing
228 -- for -L that is found in Gnatbind.Scan_Bind_Arg.
230 -- Processing for o switch
235 if Output_File_Name_Present
then
236 raise Too_Many_Output_Files
;
239 Output_File_Name_Present
:= True;
242 -- Processing for O switch
246 Output_Object_List
:= True;
248 -- Processing for p switch
252 Pessimistic_Elab_Order
:= True;
254 -- Processing for q switch
258 Quiet_Output
:= True;
260 -- Processing for r switch
264 List_Restrictions
:= True;
266 -- Processing for s switch
271 Check_Source_Files
:= True;
273 -- Processing for t switch
277 Tolerate_Consistency_Errors
:= True;
279 -- Processing for T switch
283 Time_Slice_Set
:= True;
284 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Time_Slice_Value
);
286 -- Processing for v switch
290 Verbose_Mode
:= True;
292 -- Processing for w switch
296 -- For the binder we only allow suppress/error cases
300 case Switch_Chars
(Ptr
) is
303 Warning_Mode
:= Treat_As_Error
;
306 Warning_Mode
:= Suppress
;
314 -- Processing for W switch
319 for J
in WC_Encoding_Method
loop
320 if Switch_Chars
(Ptr
) = WC_Encoding_Letters
(J
) then
321 Wide_Character_Encoding_Method
:= J
;
324 elsif J
= WC_Encoding_Method
'Last then
329 Upper_Half_Encoding
:=
330 Wide_Character_Encoding_Method
in
331 WC_Upper_Half_Encoding_Method
;
335 -- Processing for x switch
339 All_Sources
:= False;
340 Check_Source_Files
:= False;
342 -- Processing for z switch
346 No_Main_Subprogram
:= True;
348 -- Ignore extra switch character
353 -- Ignore '-' extra switch caracter, only if it isn't followed by
354 -- 'RTS'. If it is, then we must process the 'RTS' switch
358 if Ptr
+ 3 <= Max
and then
359 Switch_Chars
(Ptr
+ 1 .. Ptr
+ 3) = "RTS"
363 if Switch_Chars
(Ptr
+ 3) /= '=' or else
364 (Switch_Chars
(Ptr
+ 3) = '='
365 and then Ptr
+ 4 > Max
)
367 Osint
.Fail
("missing path for --RTS");
370 -- valid --RTS switch
371 Opt
.No_Stdinc
:= True;
372 Opt
.RTS_Switch
:= True;
375 Src_Path_Name
: String_Ptr
:= Get_RTS_Search_Dir
376 (Switch_Chars
(Ptr
+ 4 .. Switch_Chars
'Last), Include
);
377 Lib_Path_Name
: String_Ptr
:= Get_RTS_Search_Dir
378 (Switch_Chars
(Ptr
+ 4 .. Switch_Chars
'Last), Objects
);
380 if Src_Path_Name
/= null and then
381 Lib_Path_Name
/= null
383 Add_Search_Dirs
(Src_Path_Name
, Include
);
384 Add_Search_Dirs
(Lib_Path_Name
, Objects
);
385 -- we can exit as there can not be another switch
388 elsif Src_Path_Name
= null
389 and Lib_Path_Name
= null then
390 Osint
.Fail
("RTS path not valid: missing " &
391 "adainclude and adalib directories");
392 elsif Src_Path_Name
= null then
393 Osint
.Fail
("RTS path not valid: missing " &
394 "adainclude directory");
395 elsif Lib_Path_Name
= null then
396 Osint
.Fail
("RTS path not valid: missing " &
406 -- Anything else is an error (illegal switch character)
415 Osint
.Fail
("invalid switch: ", (1 => C
));
417 when Bad_Switch_Value
=>
418 Osint
.Fail
("numeric value too big for switch: ", (1 => C
));
420 when Missing_Switch_Value
=>
421 Osint
.Fail
("missing numeric value for switch: ", (1 => C
));
423 when Too_Many_Output_Files
=>
424 Osint
.Fail
("duplicate -o switch");
425 end Scan_Binder_Switches
;