1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2004-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 with Namet
; use Namet
;
29 with Types
; use Types
;
31 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
35 type Fail_Proc
is access procedure (S
: String);
36 Do_Fail
: Fail_Proc
:= Osint
.Fail
'Access;
37 -- Failing procedure called from procedure Test_If_Relative_Path below.
40 Project_Tree
: constant Project_Tree_Ref
:= new Project_Tree_Data
;
44 (Option
: String_Access
;
45 To
: in out String_List_Access
;
46 Last
: in out Natural);
49 To
: in out String_List_Access
;
50 Last
: in out Natural);
51 -- Add a string to a list of strings
53 function Create_Name
(Name
: String) return File_Name_Type
;
54 function Create_Name
(Name
: String) return Name_Id
;
55 function Create_Name
(Name
: String) return Path_Name_Type
;
56 -- Get the Name_Id of a name
58 function Executable_Prefix_Path
return String;
59 -- Return the absolute path parent directory of the directory where the
60 -- current executable resides, if its directory is named "bin", otherwise
61 -- return an empty string.
63 procedure Inform
(N
: Name_Id
:= No_Name
; Msg
: String);
64 procedure Inform
(N
: File_Name_Type
; Msg
: String);
65 -- Prints out the program name followed by a colon, N and S
67 function Is_External_Assignment
(Argv
: String) return Boolean;
68 -- Verify that an external assignment switch is syntactically correct
73 -- -X"name=other value"
75 -- Assumptions: 'First = 1, Argv (1 .. 2) = "-X"
76 -- When this function returns True, the external assignment has
77 -- been entered by a call to Prj.Ext.Add, so that in a project
78 -- file, External ("name") will return "value".
80 function Linker_Options_Switches
81 (Project
: Project_Id
;
82 In_Tree
: Project_Tree_Ref
) return String_List
;
83 -- Collect the options specified in the Linker'Linker_Options attributes
84 -- of project Project, in project tree In_Tree, and in the projects that
85 -- it imports directly or indirectly, and returns the result.
87 -- Package Mains is used to store the mains specified on the command line
88 -- and to retrieve them when a project file is used, to verify that the
89 -- files exist and that they belong to a project file.
91 function Unit_Index_Of
(ALI_File
: File_Name_Type
) return Int
;
92 -- Find the index of a unit in a source file. Return zero if the file
93 -- is not a multi-unit source file.
97 -- Mains are stored in a table. An index is used to retrieve the mains
100 procedure Add_Main
(Name
: String);
101 -- Add one main to the table
103 procedure Set_Location
(Location
: Source_Ptr
);
104 -- Set the location of the last main added. By default, the location is
111 -- Reset the index to the beginning of the table
113 function Next_Main
return String;
114 -- Increase the index and return the next main.
115 -- If table is exhausted, return an empty string.
117 function Get_Location
return Source_Ptr
;
118 -- Get the location of the current main
120 procedure Update_Main
(Name
: String);
121 -- Update the file name of the current main
123 function Number_Of_Mains
return Natural;
124 -- Returns the number of mains added with Add_Main since the last call
129 procedure Test_If_Relative_Path
130 (Switch
: in out String_Access
;
131 Parent
: String_Access
;
132 Including_L_Switch
: Boolean := True;
133 Including_Non_Switch
: Boolean := True);
134 -- Test if Switch is a relative search path switch.
135 -- If it is, fail if Parent is null, otherwise prepend the path with
136 -- Parent. This subprogram is only called when using project files.
137 -- For gnatbind switches, Including_L_Switch is False, because the
138 -- argument of the -L switch is not a path.
140 function Path_Or_File_Name
(Path
: Path_Name_Type
) return String;
141 -- Returns a file name if -df is used, otherwise return a path name
143 ----------------------
144 -- Marking Routines --
145 ----------------------
147 procedure Mark
(Source_File
: File_Name_Type
; Index
: Int
:= 0);
148 -- Mark a unit, identified by its source file and, when Index is not 0,
149 -- the index of the unit in the source file. Marking is used to signal
150 -- that the unit has already been inserted in the Q.
153 (Source_File
: File_Name_Type
;
154 Index
: Int
:= 0) return Boolean;
155 -- Returns True if the unit was previously marked
157 procedure Delete_All_Marks
;
158 -- Remove all file/index couples marked