1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2003 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 Max : constant Integer := Switch_Chars'Last;
41 Ptr : Integer := Switch_Chars'First;
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 F switch
157 Force_Checking_Of_Elaboration_Flags := True;
159 -- Processing for g switch
165 C := Switch_Chars (Ptr);
167 if C in '0' .. '3' then
170 (Switch_Chars (Ptr)) - Character'Pos ('0');
178 -- Processing for h switch
182 Usage_Requested := True;
184 -- Processing for i switch
192 C := Switch_Chars (Ptr);
201 Identifier_Character_Set := C;
207 -- Processing for K switch
211 Output_Linker_Option_List := True;
213 -- Processing for l switch
217 Elab_Order_Output := True;
219 -- Processing for m switch
223 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
225 -- Processing for n switch
229 Bind_Main_Program := False;
231 -- Note: The -L option of the binder also implies -n, so
232 -- any change here must also be reflected in the processing
233 -- for -L that is found in Gnatbind.Scan_Bind_Arg.
235 -- Processing for o switch
240 if Output_File_Name_Present then
241 raise Too_Many_Output_Files;
244 Output_File_Name_Present := True;
247 -- Processing for O switch
251 Output_Object_List := True;
253 -- Processing for p switch
257 Pessimistic_Elab_Order := True;
259 -- Processing for q switch
263 Quiet_Output := True;
265 -- Processing for r switch
269 List_Restrictions := True;
271 -- Processing for s switch
276 Check_Source_Files := True;
278 -- Processing for t switch
282 Tolerate_Consistency_Errors := True;
284 -- Processing for T switch
288 Time_Slice_Set := True;
289 Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value);
290 Time_Slice_Value := Time_Slice_Value * 1_000;
292 -- Processing for v switch
296 Verbose_Mode := True;
298 -- Processing for w switch
302 -- For the binder we only allow suppress/error cases
306 case Switch_Chars (Ptr) is
309 Warning_Mode := Treat_As_Error;
312 Warning_Mode := Suppress;
320 -- Processing for W switch
325 for J in WC_Encoding_Method loop
326 if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then
327 Wide_Character_Encoding_Method := J;
330 elsif J = WC_Encoding_Method'Last then
335 Upper_Half_Encoding :=
336 Wide_Character_Encoding_Method in
337 WC_Upper_Half_Encoding_Method;
341 -- Processing for x switch
345 All_Sources := False;
346 Check_Source_Files := False;
348 -- Processing for z switch
352 No_Main_Subprogram := True;
354 -- Ignore extra switch character
359 -- Ignore '-' extra switch caracter, only if it isn't followed by
360 -- 'RTS'. If it is, then we must process the 'RTS' switch
364 if Ptr + 3 <= Max and then
365 Switch_Chars (Ptr + 1 .. Ptr + 3) = "RTS"
369 if Switch_Chars (Ptr + 3) /= '=' or else
370 (Switch_Chars (Ptr + 3) = '='
371 and then Ptr + 4 > Max)
373 Osint.Fail ("missing path for --RTS");
376 -- valid --RTS switch
377 Opt.No_Stdinc := True;
378 Opt.RTS_Switch := True;
381 Src_Path_Name : constant String_Ptr :=
384 (Ptr + 4 .. Switch_Chars'Last),
386 Lib_Path_Name : constant String_Ptr :=
389 (Ptr + 4 .. Switch_Chars'Last),
393 if Src_Path_Name /= null and then
394 Lib_Path_Name /= null
396 -- Set the RTS_*_Path_Name variables, so that the
397 -- correct directories will be set when
398 -- Osint.Add_Default_Search_Dirs will be called later.
400 RTS_Src_Path_Name := Src_Path_Name;
401 RTS_Lib_Path_Name := Lib_Path_Name;
403 -- We can exit as there can not be another switch
408 elsif Src_Path_Name = null
409 and then Lib_Path_Name = null
411 Osint.Fail ("RTS path not valid: missing " &
412 "adainclude and adalib directories");
413 elsif Src_Path_Name = null then
414 Osint.Fail ("RTS path not valid: missing " &
415 "adainclude directory");
416 elsif Lib_Path_Name = null then
417 Osint.Fail ("RTS path not valid: missing " &
427 -- Anything else is an error (illegal switch character)
436 Osint.Fail ("invalid switch: ", (1 => C));
438 when Bad_Switch_Value =>
439 Osint.Fail ("numeric value out of range for switch: ", (1 => C));
441 when Missing_Switch_Value =>
442 Osint.Fail ("missing numeric value for switch: ", (1 => C));
444 when Too_Many_Output_Files =>
445 Osint.Fail ("duplicate -o switch");
446 end Scan_Binder_Switches;