1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2002 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 with Debug
; use Debug
;
28 with Osint
; use Osint
;
31 with System
.WCh_Con
; use System
.WCh_Con
;
33 package body Switch
.B
is
35 --------------------------
36 -- Scan_Binder_Switches --
37 --------------------------
39 procedure Scan_Binder_Switches
(Switch_Chars
: String) is
40 Ptr
: Integer := Switch_Chars
'First;
41 Max
: Integer := Switch_Chars
'Last;
45 -- Skip past the initial character (must be the switch character)
53 -- A little check, "gnat" at the start of a switch is not allowed
54 -- except for the compiler
56 if Switch_Chars
'Last >= Ptr
+ 3
57 and then Switch_Chars
(Ptr
.. Ptr
+ 3) = "gnat"
59 Osint
.Fail
("invalid switch: """, Switch_Chars
, """"
60 & " (gnat not needed here)");
64 -- Loop to scan through switches given in switch string
67 C
:= Switch_Chars
(Ptr
);
71 -- Processing for A switch
76 Ada_Bind_File
:= True;
78 -- Processing for b switch
84 -- Processing for c switch
91 -- Processing for C switch
96 Ada_Bind_File
:= False;
98 -- Processing for d switch
102 -- Note: for the debug switch, the remaining characters in this
103 -- switch field must all be debug flags, since all valid switch
104 -- characters are also valid debug characters. This switch is not
105 -- documented on purpose because it is only used by the
108 -- Loop to scan out debug flags
112 C
:= Switch_Chars
(Ptr
);
113 exit when C
= ASCII
.NUL
or else C
= '/' or else C
= '-';
115 if C
in '1' .. '9' or else
116 C
in 'a' .. 'z' or else
125 -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This
126 -- is for backwards compatibility with old versions and usage.
128 if Debug_Flag_XX
then
129 Zero_Cost_Exceptions_Set
:= True;
130 Zero_Cost_Exceptions_Val
:= True;
135 -- Processing for e switch
139 Elab_Dependency_Output
:= True;
141 -- Processing for E switch
145 Exception_Tracebacks
:= True;
147 -- Processing for f switch
151 Force_RM_Elaboration_Order
:= True;
153 -- Processing for g switch
159 C
:= Switch_Chars
(Ptr
);
161 if C
in '0' .. '3' then
164 (Switch_Chars
(Ptr
)) - Character'Pos ('0');
172 -- Processing for h switch
176 Usage_Requested
:= True;
178 -- Processing for i switch
186 C
:= Switch_Chars
(Ptr
);
195 Identifier_Character_Set
:= C
;
201 -- Processing for K switch
205 Output_Linker_Option_List
:= True;
207 -- Processing for l switch
211 Elab_Order_Output
:= True;
213 -- Processing for m switch
217 Scan_Pos
(Switch_Chars
, Max
, Ptr
, Maximum_Errors
);
219 -- Processing for n switch
223 Bind_Main_Program
:= False;
225 -- Note: The -L option of the binder also implies -n, so
226 -- any change here must also be reflected in the processing
227 -- for -L that is found in Gnatbind.Scan_Bind_Arg.
229 -- Processing for o switch
234 if Output_File_Name_Present
then
235 raise Too_Many_Output_Files
;
238 Output_File_Name_Present
:= True;
241 -- Processing for O switch
245 Output_Object_List
:= True;
247 -- Processing for p switch
251 Pessimistic_Elab_Order
:= True;
253 -- Processing for q switch
257 Quiet_Output
:= True;
259 -- Processing for r switch
263 List_Restrictions
:= True;
265 -- Processing for s switch
270 Check_Source_Files
:= True;
272 -- Processing for t switch
276 Tolerate_Consistency_Errors
:= True;
278 -- Processing for T switch
282 Time_Slice_Set
:= True;
283 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Time_Slice_Value
);
285 -- Processing for v switch
289 Verbose_Mode
:= True;
291 -- Processing for w switch
295 -- For the binder we only allow suppress/error cases
299 case Switch_Chars
(Ptr
) is
302 Warning_Mode
:= Treat_As_Error
;
305 Warning_Mode
:= Suppress
;
313 -- Processing for W switch
318 for J
in WC_Encoding_Method
loop
319 if Switch_Chars
(Ptr
) = WC_Encoding_Letters
(J
) then
320 Wide_Character_Encoding_Method
:= J
;
323 elsif J
= WC_Encoding_Method
'Last then
328 Upper_Half_Encoding
:=
329 Wide_Character_Encoding_Method
in
330 WC_Upper_Half_Encoding_Method
;
334 -- Processing for x switch
338 All_Sources
:= False;
339 Check_Source_Files
:= False;
341 -- Processing for z switch
345 No_Main_Subprogram
:= True;
347 -- Ignore extra switch character
352 -- Ignore '-' extra switch caracter, only if it isn't followed by
353 -- 'RTS'. If it is, then we must process the 'RTS' switch
357 if Ptr
+ 3 <= Max
and then
358 Switch_Chars
(Ptr
+ 1 .. Ptr
+ 3) = "RTS"
362 if Switch_Chars
(Ptr
+ 3) /= '=' or else
363 (Switch_Chars
(Ptr
+ 3) = '='
364 and then Ptr
+ 4 > Max
)
366 Osint
.Fail
("missing path for --RTS");
369 -- valid --RTS switch
370 Opt
.No_Stdinc
:= True;
371 Opt
.RTS_Switch
:= True;
374 Src_Path_Name
: String_Ptr
:= Get_RTS_Search_Dir
375 (Switch_Chars
(Ptr
+ 4 .. Switch_Chars
'Last), Include
);
376 Lib_Path_Name
: String_Ptr
:= Get_RTS_Search_Dir
377 (Switch_Chars
(Ptr
+ 4 .. Switch_Chars
'Last), Objects
);
379 if Src_Path_Name
/= null and then
380 Lib_Path_Name
/= null
382 Add_Search_Dirs
(Src_Path_Name
, Include
);
383 Add_Search_Dirs
(Lib_Path_Name
, Objects
);
384 -- we can exit as there can not be another switch
387 elsif Src_Path_Name
= null
388 and Lib_Path_Name
= null then
389 Osint
.Fail
("RTS path not valid: missing " &
390 "adainclude and adalib directories");
391 elsif Src_Path_Name
= null then
392 Osint
.Fail
("RTS path not valid: missing " &
393 "adainclude directory");
394 elsif Lib_Path_Name
= null then
395 Osint
.Fail
("RTS path not valid: missing " &
405 -- Anything else is an error (illegal switch character)
414 Osint
.Fail
("invalid switch: ", (1 => C
));
416 when Bad_Switch_Value
=>
417 Osint
.Fail
("numeric value too big for switch: ", (1 => C
));
419 when Missing_Switch_Value
=>
420 Osint
.Fail
("missing numeric value for switch: ", (1 => C
));
422 when Too_Many_Output_Files
=>
423 Osint
.Fail
("duplicate -o switch");
424 end Scan_Binder_Switches
;