gcc:
[official-gcc.git] / gcc / ada / osint.ads
blobcda8e828573c79010a5dbaf891b70027cd1b57d2
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- O S I N T --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2006 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 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- This package contains the low level, operating system routines used in the
28 -- compiler and binder for command line processing and file input output.
30 with GNAT.OS_Lib; use GNAT.OS_Lib;
31 with System; use System;
32 with Types; use Types;
34 pragma Elaborate (GNAT.OS_Lib);
36 package Osint is
38 Multi_Unit_Index_Character : Character := '~';
39 -- The character before the index of the unit in a multi-unit source, in
40 -- ALI and object file names. This is not a constant, because it is changed
41 -- to '$' on VMS.
43 Ada_Include_Path : constant String := "ADA_INCLUDE_PATH";
44 Ada_Objects_Path : constant String := "ADA_OBJECTS_PATH";
45 Project_Include_Path_File : constant String := "ADA_PRJ_INCLUDE_FILE";
46 Project_Objects_Path_File : constant String := "ADA_PRJ_OBJECTS_FILE";
48 procedure Initialize;
49 -- Initialize internal tables
51 function Normalize_Directory_Name (Directory : String) return String_Ptr;
52 -- Verify and normalize a directory name. If directory name is invalid,
53 -- this will return an empty string. Otherwise it will insure a trailing
54 -- slash and make other normalizations.
56 type File_Type is (Source, Library, Config, Definition, Preprocessing_Data);
58 function Find_File
59 (N : File_Name_Type;
60 T : File_Type) return File_Name_Type;
61 -- Finds a source, library or config file depending on the value of T
62 -- following the directory search order rules unless N is the name of the
63 -- file just read with Next_Main_File and already contains directiory
64 -- information, in which case just look in the Primary_Directory. Returns
65 -- File_Name_Type of the full file name if found, No_File if file not
66 -- found. Note that for the special case of gnat.adc, only the compilation
67 -- environment directory is searched, i.e. the directory where the ali and
68 -- object files are written. Another special case is Debug_Generated_Code
69 -- set and the file name ends on ".dg", in which case we look for the
70 -- generated file only in the current directory, since that is where it is
71 -- always built.
73 function Get_File_Names_Case_Sensitive return Int;
74 pragma Import (C, Get_File_Names_Case_Sensitive,
75 "__gnat_get_file_names_case_sensitive");
76 File_Names_Case_Sensitive : constant Boolean :=
77 Get_File_Names_Case_Sensitive /= 0;
78 -- Set to indicate whether the operating system convention is for file
79 -- names to be case sensitive (e.g., in Unix, set True), or non case
80 -- sensitive (e.g., in OS/2, set False).
82 procedure Canonical_Case_File_Name (S : in out String);
83 -- Given a file name, converts it to canonical case form. For systems
84 -- where file names are case sensitive, this procedure has no effect.
85 -- If file names are not case sensitive (i.e. for example if you have
86 -- the file "xyz.adb", you can refer to it as XYZ.adb or XyZ.AdB), then
87 -- this call converts the given string to canonical all lower case form,
88 -- so that two file names compare equal if they refer to the same file.
90 function Number_Of_Files return Int;
91 -- Gives the total number of filenames found on the command line
93 No_Index : constant := -1;
94 -- Value used in Add_File to indicate no index is specified for main
96 procedure Add_File (File_Name : String; Index : Int := No_Index);
97 -- Called by the subprogram processing the command line for each file name
98 -- found. The index, when not defaulted to No_Index is the index of the
99 -- subprogram in its source, zero indicating that the source is not
100 -- multi-unit.
102 procedure Find_Program_Name;
103 -- Put simple name of current program being run (excluding the directory
104 -- path) in Name_Buffer, with the length in Name_Len.
106 function Program_Name (Nam : String) return String_Access;
107 -- In the native compilation case, Create a string containing Nam. In the
108 -- cross compilation case, looks at the prefix of the current program being
109 -- run and prepend it to Nam. For instance if the program being run is
110 -- <target>-gnatmake and Nam is "gcc", the returned value will be a pointer
111 -- to "<target>-gcc". This function clobbers Name_Buffer and Name_Len.
113 procedure Write_Program_Name;
114 -- Writes name of program as invoked to the current output
115 -- (normally standard output).
117 procedure Fail (S1 : String; S2 : String := ""; S3 : String := "");
118 pragma No_Return (Fail);
119 -- Outputs error messages S1 & S2 & S3 preceded by the name of the
120 -- executing program and exits with E_Fatal. The output goes to standard
121 -- error, except if special output is in effect (see Output).
123 function Is_Directory_Separator (C : Character) return Boolean;
124 -- Returns True if C is a directory separator
126 function Get_Directory (Name : File_Name_Type) return File_Name_Type;
127 -- Get the prefix directory name (if any) from Name. The last separator
128 -- is preserved. Return the normalized current directory if there is no
129 -- directory part in the name.
131 function Is_Readonly_Library (File : File_Name_Type) return Boolean;
132 -- Check if this library file is a read-only file
134 function Strip_Directory (Name : File_Name_Type) return File_Name_Type;
135 -- Strips the prefix directory name (if any) from Name. Returns the
136 -- stripped name. Name cannot end with a directory separator.
138 function Strip_Suffix (Name : File_Name_Type) return File_Name_Type;
139 -- Strips the suffix (the last '.' and whatever comes after it) from Name.
140 -- Returns the stripped name.
142 function Executable_Name (Name : File_Name_Type) return File_Name_Type;
143 -- Given a file name it adds the appropriate suffix at the end so that
144 -- it becomes the name of the executable on the system at end. For
145 -- instance under DOS it adds the ".exe" suffix, whereas under UNIX no
146 -- suffix is added.
148 function Executable_Name (Name : String) return String;
149 -- Same as above, with String parameters
151 function File_Stamp (Name : File_Name_Type) return Time_Stamp_Type;
152 -- Returns the time stamp of file Name. Name should include relative
153 -- path information in order to locate it. If the source file cannot be
154 -- opened, or Name = No_File, and all blank time stamp is returned (this is
155 -- not an error situation).
157 type String_Access_List is array (Positive range <>) of String_Access;
158 -- Deferenced type used to return a list of file specs in
159 -- To_Canonical_File_List.
161 type String_Access_List_Access is access all String_Access_List;
162 -- Type used to return a String_Access_List without dragging in secondary
163 -- stack.
165 function To_Canonical_File_List
166 (Wildcard_Host_File : String;
167 Only_Dirs : Boolean) return String_Access_List_Access;
168 -- Expand a wildcard host syntax file or directory specification (e.g. on
169 -- a VMS host, any file or directory spec that contains:
170 -- "*", or "%", or "...")
171 -- and return a list of valid Unix syntax file or directory specs.
172 -- If Only_Dirs is True, then only return directories.
174 function To_Canonical_Dir_Spec
175 (Host_Dir : String;
176 Prefix_Style : Boolean) return String_Access;
177 -- Convert a host syntax directory specification (e.g. on a VMS host:
178 -- "SYS$DEVICE:[DIR]") to canonical (Unix) syntax (e.g. "/sys$device/dir").
179 -- If Prefix_Style then make it a valid file specification prefix. A file
180 -- specification prefix is a directory specification that can be appended
181 -- with a simple file specification to yield a valid absolute or relative
182 -- path to a file. On a conversion to Unix syntax this simply means the
183 -- spec has a trailing slash ("/").
185 function To_Canonical_File_Spec
186 (Host_File : String) return String_Access;
187 -- Convert a host syntax file specification (e.g. on a VMS host:
188 -- "SYS$DEVICE:[DIR]FILE.EXT;69 to canonical (Unix) syntax (e.g.
189 -- "/sys$device/dir/file.ext.69").
191 function To_Canonical_Path_Spec
192 (Host_Path : String) return String_Access;
193 -- Convert a host syntax Path specification (e.g. on a VMS host:
194 -- "SYS$DEVICE:[BAR],DISK$USER:[FOO] to canonical (Unix) syntax (e.g.
195 -- "/sys$device/foo:disk$user/foo").
197 function To_Host_Dir_Spec
198 (Canonical_Dir : String;
199 Prefix_Style : Boolean) return String_Access;
200 -- Convert a canonical syntax directory specification to host syntax.
201 -- The Prefix_Style flag is currently ignored but should be set to
202 -- False.
204 function To_Host_File_Spec
205 (Canonical_File : String) return String_Access;
206 -- Convert a canonical syntax file specification to host syntax
208 function Relocate_Path
209 (Prefix : String;
210 Path : String) return String_Ptr;
211 -- Given an absolute path and a prefix, if Path starts with Prefix,
212 -- replace the Prefix substring with the root installation directory.
213 -- By default, try to compute the root installation directory by looking
214 -- at the executable name as it was typed on the command line and, if
215 -- needed, use the PATH environment variable. If the above computation
216 -- fails, return Path. This function assumes Prefix'First = Path'First.
218 function Shared_Lib (Name : String) return String;
219 -- Returns the runtime shared library in the form -l<name>-<version> where
220 -- version is the GNAT runtime library option for the platform. For example
221 -- this routine called with Name set to "gnat" will return "-lgnat-5.02"
222 -- on UNIX and Windows and -lgnat_5_02 on VMS.
224 -------------------------
225 -- Search Dir Routines --
226 -------------------------
228 function Include_Dir_Default_Prefix return String;
229 -- Return the directory of the run-time library sources, as modified
230 -- by update_path.
232 function Object_Dir_Default_Prefix return String;
233 -- Return the directory of the run-time library ALI and object files, as
234 -- modified by update_path.
236 procedure Add_Default_Search_Dirs;
237 -- This routine adds the default search dirs indicated by the
238 -- environment variables and sdefault package.
240 procedure Add_Lib_Search_Dir (Dir : String);
241 -- Add Dir at the end of the library file search path
243 procedure Add_Src_Search_Dir (Dir : String);
244 -- Add Dir at the end of the source file search path
246 procedure Get_Next_Dir_In_Path_Init
247 (Search_Path : String_Access);
248 function Get_Next_Dir_In_Path
249 (Search_Path : String_Access) return String_Access;
250 -- These subprograms are used to parse out the directory names in a
251 -- search path specified by a Search_Path argument. The procedure
252 -- initializes an internal pointer to point to the initial directory
253 -- name, and calls to the function return successive directory names,
254 -- with a null pointer marking the end of the list.
256 type Search_File_Type is (Include, Objects);
258 procedure Add_Search_Dirs
259 (Search_Path : String_Ptr;
260 Path_Type : Search_File_Type);
261 -- These procedure adds all the search directories that are in Search_Path
262 -- in the proper file search path (library or source)
264 function Get_Primary_Src_Search_Directory return String_Ptr;
265 -- Retrieved the primary directory (directory containing the main source
266 -- file for Gnatmake.
268 function Nb_Dir_In_Src_Search_Path return Natural;
269 function Dir_In_Src_Search_Path (Position : Natural) return String_Ptr;
270 -- Functions to access the directory names in the source search path
272 function Nb_Dir_In_Obj_Search_Path return Natural;
273 function Dir_In_Obj_Search_Path (Position : Natural) return String_Ptr;
274 -- Functions to access the directory names in the Object search path
276 Include_Search_File : constant String_Access :=
277 new String'("ada_source_path");
278 Objects_Search_File : constant String_Access :=
279 new String'("ada_object_path");
280 -- Names of the files containg the default include or objects search
281 -- directories. These files, located in Sdefault.Search_Dir_Prefix, do
282 -- not necessarily exist.
284 Exec_Name : String_Ptr;
285 -- Executable name as typed by the user (used to compute the
286 -- executable prefix).
288 function Read_Default_Search_Dirs
289 (Search_Dir_Prefix : String_Access;
290 Search_File : String_Access;
291 Search_Dir_Default_Name : String_Access) return String_Access;
292 -- Read and return the default search directories from the file located
293 -- in Search_Dir_Prefix (as modified by update_path) and named Search_File.
294 -- If no such file exists or an error occurs then instead return the
295 -- Search_Dir_Default_Name (as modified by update_path).
297 function Get_RTS_Search_Dir
298 (Search_Dir : String;
299 File_Type : Search_File_Type) return String_Ptr;
300 -- This function retrieves the paths to the search (resp. lib) dirs and
301 -- return them. The search dir can be absolute or relative. If the search
302 -- dir contains Include_Search_File (resp. Object_Search_File), then this
303 -- function reads and returns the default search directories from the file.
304 -- Otherwise, if the directory is absolute, it will try to find 'adalib'
305 -- (resp. 'adainclude'). If found, null is returned. If the directory is
306 -- relative, the following directories for the directories 'adalib' and
307 -- 'adainclude' will be scanned:
309 -- - current directory (from which the tool has been spawned)
310 -- - $GNAT_ROOT/gcc/gcc-lib/$targ/$vers/
311 -- - $GNAT_ROOT/gcc/gcc-lib/$targ/$vers/rts-
313 -- The scan will stop as soon as the directory being searched for (adalib
314 -- or adainclude) is found. If the scan fails, null is returned.
316 -----------------------
317 -- Source File Input --
318 -----------------------
320 -- Source file input routines are used by the compiler to read the main
321 -- source files and the subsidiary source files (e.g. with'ed units), and
322 -- also by the binder to check presence/time stamps of sources.
324 procedure Read_Source_File
325 (N : File_Name_Type;
326 Lo : Source_Ptr;
327 Hi : out Source_Ptr;
328 Src : out Source_Buffer_Ptr;
329 T : File_Type := Source);
330 -- Allocates a Source_Buffer of appropriate length and then reads the
331 -- entire contents of the source file N into the buffer. The address of
332 -- the allocated buffer is returned in Src.
334 -- Each line of text is terminated by one of the sequences:
336 -- CR
337 -- CR/LF
338 -- LF/CR
339 -- LF
341 -- The source is terminated by an EOF (16#1A#) character, which is
342 -- the last charcater of the returned source bufer (note that any
343 -- EOF characters in positions other than the last source character
344 -- are treated as representing blanks).
346 -- The logical lower bound of the source buffer is the input value of Lo,
347 -- and on exit Hi is set to the logical upper bound of the source buffer.
348 -- Note that the returned value in Src points to an array with a physical
349 -- lower bound of zero. This virtual origin addressing approach means that
350 -- a constrained array pointer can be used with a low bound of zero which
351 -- results in more efficient code.
353 -- If the given file cannot be opened, then the action depends on whether
354 -- this file is the current main unit (i.e. its name matches the name
355 -- returned by the most recent call to Next_Main_Source). If so, then the
356 -- failure to find the file is a fatal error, an error message is output,
357 -- and program execution is terminated. Otherwise (for the case of a
358 -- subsidiary source loaded directly or indirectly using with), a file
359 -- not found condition causes null to be set as the result value.
361 -- Note that the name passed to this function is the simple file name,
362 -- without any directory information. The implementation is responsible
363 -- for searching for the file in the appropriate directories.
365 -- Note the special case that if the file name is gnat.adc, then the
366 -- search for the file is done ONLY in the directory corresponding to
367 -- the current compilation environment, i.e. in the same directory
368 -- where the ali and object files will be written.
370 function Full_Source_Name return File_Name_Type;
371 function Current_Source_File_Stamp return Time_Stamp_Type;
372 -- Returns the full name/time stamp of the source file most recently read
373 -- using Read_Source_File. Calling this routine entails no source file
374 -- directory lookup penalty.
376 function Full_Source_Name (N : File_Name_Type) return File_Name_Type;
377 function Source_File_Stamp (N : File_Name_Type) return Time_Stamp_Type;
378 -- Returns the full name/time stamp of the source file whose simple name is
379 -- N which should not include path information. Note that if the file
380 -- cannot be located No_File is returned for the first routine and an all
381 -- blank time stamp is returned for the second (this is not an error
382 -- situation). The full name includes appropriate directory information.
383 -- The source file directory lookup penalty is incurred every single time
384 -- the routines are called unless you have previously called
385 -- Source_File_Data (Cache => True). See below.
387 function Current_File_Index return Int;
388 -- Return the index in its source file of the current main unit
390 function Matching_Full_Source_Name
391 (N : File_Name_Type;
392 T : Time_Stamp_Type) return File_Name_Type;
393 -- Same semantics than Full_Source_Name but will search on the source path
394 -- until a source file with time stamp matching T is found. If none is
395 -- found returns No_File.
397 procedure Source_File_Data (Cache : Boolean);
398 -- By default source file data (full source file name and time stamp)
399 -- are looked up every time a call to Full_Source_Name (N) or
400 -- Source_File_Stamp (N) is made. This may be undesirable in certain
401 -- applications as this is uselessly slow if source file data does not
402 -- change during program execution. When this procedure is called with
403 -- Cache => True access to source file data does not encurr a penalty if
404 -- this data was previously retrieved.
406 -------------------------------------------
407 -- Representation of Library Information --
408 -------------------------------------------
410 -- Associated with each compiled source file is library information,
411 -- a string of bytes whose exact format is described in the body of
412 -- Lib.Writ. Compiling a source file generates this library information
413 -- for the compiled unit, and access the library information for units
414 -- that were compiled previously on which the unit being compiled depends.
416 -- How this information is stored is up to the implementation of this
417 -- package. At the interface level, this information is simply associated
418 -- with its corresponding source.
420 -- Several different implementations are possible:
422 -- 1. The information could be directly associated with the source file,
423 -- e.g. placed in a resource fork of this file on the Mac, or on
424 -- MS-DOS, written to the source file after the end of file mark.
426 -- 2. The information could be written into the generated object module
427 -- if the system supports the inclusion of arbitrary informational
428 -- byte streams into object files. In this case there must be a naming
429 -- convention that allows object files to be located given the name of
430 -- the corresponding source file.
432 -- 3. The information could be written to a separate file, whose name is
433 -- related to the name of the source file by a fixed convention.
435 -- Which of these three methods is chosen depends on the constraints of the
436 -- host operating system. The interface described here is independent of
437 -- which of these approaches is used. Currently all versions of GNAT use
438 -- the third approach with a file name of xxx.ali where xxx is the source
439 -- file name.
441 -------------------------------
442 -- Library Information Input --
443 -------------------------------
445 -- These subprograms are used by the binder to read library information
446 -- files, see section above for representation of these files.
448 function Read_Library_Info
449 (Lib_File : File_Name_Type;
450 Fatal_Err : Boolean := False) return Text_Buffer_Ptr;
451 -- Allocates a Text_Buffer of appropriate length and reads in the entire
452 -- source of the library information from the library information file
453 -- whose name is given by the parameter Name.
455 -- See description of Read_Source_File for details on the format of the
456 -- returned text buffer (the format is identical). THe lower bound of
457 -- the Text_Buffer is always zero
459 -- If the specified file cannot be opened, then the action depends on
460 -- Fatal_Err. If Fatal_Err is True, an error message is given and the
461 -- compilation is abandoned. Otherwise if Fatal_Err is False, then null
462 -- is returned. Note that the Lib_File is a simple name which does not
463 -- include any directory information. The implementation is responsible
464 -- for searching for the file in appropriate directories.
466 -- If Opt.Check_Object_Consistency is set to True then this routine
467 -- checks whether the object file corresponding to the Lib_File is
468 -- consistent with it. The object file is inconsistent if the object
469 -- does not exist or if it has an older time stamp than Lib_File.
470 -- This check is not performed when the Lib_File is "locked" (i.e.
471 -- read/only) because in this case the object file may be buried
472 -- in a library. In case of inconsistencies Read_Library_Info
473 -- behaves as if it did not find Lib_File (namely if Fatal_Err is
474 -- False, null is returned).
476 function Full_Library_Info_Name return File_Name_Type;
477 function Full_Object_File_Name return File_Name_Type;
478 -- Returns the full name of the library/object file most recently read
479 -- using Read_Library_Info, including appropriate directory information.
480 -- Calling this routine entails no library file directory lookup
481 -- penalty. Note that the object file corresponding to a library file
482 -- is not actually read. Its time stamp is fected when the flag
483 -- Opt.Check_Object_Consistency is set.
485 function Current_Library_File_Stamp return Time_Stamp_Type;
486 function Current_Object_File_Stamp return Time_Stamp_Type;
487 -- The time stamps of the files returned by the previous two routines.
488 -- It is an error to call Current_Object_File_Stamp if
489 -- Opt.Check_Object_Consistency is set to False.
491 function Full_Lib_File_Name (N : File_Name_Type) return File_Name_Type;
492 function Library_File_Stamp (N : File_Name_Type) return Time_Stamp_Type;
493 -- Returns the full name/time stamp of library file N. N should not
494 -- include path information. Note that if the file cannot be located
495 -- No_File is returned for the first routine and an all blank time stamp
496 -- is returned for the second (this is not an error situation). The
497 -- full name includes the appropriate directory information. The library
498 -- file directory lookup penalty is incurred every single time this
499 -- routine is called.
501 function Lib_File_Name
502 (Source_File : File_Name_Type;
503 Munit_Index : Nat := 0) return File_Name_Type;
504 -- Given the name of a source file, returns the name of the corresponding
505 -- library information file. This may be the name of the object file, or
506 -- of a separate file used to store the library information. In either case
507 -- the returned result is suitable for use in a call to Read_Library_Info.
508 -- The Munit_Index is the unit index in multiple unit per file mode, or
509 -- zero in normal single unit per file mode (used to add ~nnn suffix).
510 -- Note: this subprogram is in this section because it is used by the
511 -- compiler to determine the proper library information names to be placed
512 -- in the generated library information file.
514 -----------------
515 -- Termination --
516 -----------------
518 type Exit_Code_Type is (
519 E_Success, -- No warnings or errors
520 E_Warnings, -- Compiler warnings generated
521 E_No_Code, -- No code generated
522 E_No_Compile, -- Compilation not needed (smart recompilation)
523 E_Errors, -- Compiler error messages generated
524 E_Fatal, -- Fatal (serious) error, e.g. source file not found
525 E_Abort); -- Internally detected compiler error
527 procedure Exit_Program (Exit_Code : Exit_Code_Type);
528 pragma No_Return (Exit_Program);
529 -- A call to Exit_Program terminates execution with the given status. A
530 -- status of zero indicates normal completion, a non-zero status indicates
531 -- abnormal termination.
533 -------------------------
534 -- Command Line Access --
535 -------------------------
537 -- Direct interface to command line parameters. (We don't want to use
538 -- the predefined command line package because it defines functions
539 -- returning string)
541 function Arg_Count return Natural;
542 pragma Import (C, Arg_Count, "__gnat_arg_count");
543 -- Get number of arguments (note: optional globbing may be enabled)
545 procedure Fill_Arg (A : System.Address; Arg_Num : Integer);
546 pragma Import (C, Fill_Arg, "__gnat_fill_arg");
547 -- Store one argument
549 function Len_Arg (Arg_Num : Integer) return Integer;
550 pragma Import (C, Len_Arg, "__gnat_len_arg");
551 -- Get length of argument
553 private
555 ALI_Suffix : constant String_Ptr := new String'("ali");
556 -- The suffix used for the library files (also known as ALI files)
558 Current_Main : File_Name_Type := No_File;
559 -- Used to save a simple file name between calls to Next_Main_Source and
560 -- Read_Source_File. If the file name argument to Read_Source_File is
561 -- No_File, that indicates that the file whose name was returned by the
562 -- last call to Next_Main_Source (and stored here) is to be read.
564 Target_Object_Suffix : constant String := Get_Target_Object_Suffix.all;
565 -- The suffix used for the target object files
567 Output_FD : File_Descriptor;
568 -- File descriptor for current library info, list, tree, or binder output
570 Output_File_Name : File_Name_Type;
571 -- File_Name_Type for name of open file whose FD is in Output_FD, the name
572 -- stored does not include the trailing NUL character.
574 Argument_Count : constant Integer := Arg_Count - 1;
575 -- Number of arguments (excluding program name)
577 type File_Name_Array is array (Int range <>) of String_Ptr;
578 type File_Name_Array_Ptr is access File_Name_Array;
579 File_Names : File_Name_Array_Ptr :=
580 new File_Name_Array (1 .. Int (Argument_Count) + 2);
581 -- As arguments are scanned, file names are stored in this array The
582 -- strings do not have terminating NUL files. The array is extensible,
583 -- because when using project files, there may be more files than
584 -- arguments on the command line.
586 type File_Index_Array is array (Int range <>) of Int;
587 type File_Index_Array_Ptr is access File_Index_Array;
588 File_Indexes : File_Index_Array_Ptr :=
589 new File_Index_Array (1 .. Int (Argument_Count) + 2);
591 Current_File_Name_Index : Int := 0;
592 -- The index in File_Names of the last file opened by Next_Main_Source
593 -- or Next_Main_Lib_File. The value 0 indicates that no files have been
594 -- opened yet.
596 procedure Create_File_And_Check
597 (Fdesc : out File_Descriptor;
598 Fmode : Mode);
599 -- Create file whose name (NUL terminated) is in Name_Buffer (with the
600 -- length in Name_Len), and place the resulting descriptor in Fdesc. Issue
601 -- message and exit with fatal error if file cannot be created. The Fmode
602 -- parameter is set to either Text or Binary (for details see description
603 -- of GNAT.OS_Lib.Create_File).
605 type Program_Type is (Compiler, Binder, Make, Gnatls, Unspecified);
606 -- Program currently running
607 procedure Set_Program (P : Program_Type);
608 -- Indicates to the body of Osint the program currently running. This
609 -- procedure is called by the child packages of Osint. A check is made
610 -- that this procedure is not called more than once.
612 function More_Files return Boolean;
613 -- Implements More_Source_Files and More_Lib_Files
615 function Next_Main_File return File_Name_Type;
616 -- Implements Next_Main_Source and Next_Main_Lib_File
618 function Object_File_Name (N : File_Name_Type) return File_Name_Type;
619 -- Constructs the name of the object file corresponding to library file N.
620 -- If N is a full file name than the returned file name will also be a full
621 -- file name. Note that no lookup in the library file directories is done
622 -- for this file. This routine merely constructs the name.
624 procedure Write_Info (Info : String);
625 -- Implementation of Write_Binder_Info, Write_Debug_Info and
626 -- Write_Library_Info (identical)
628 procedure Write_With_Check (A : Address; N : Integer);
629 -- Writes N bytes from buffer starting at address A to file whose FD is
630 -- stored in Output_FD, and whose file name is stored as a File_Name_Type
631 -- in Output_File_Name. A check is made for disk full, and if this is
632 -- detected, the file being written is deleted, and a fatal error is
633 -- signalled.
635 end Osint;