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
39 Do_Fail
: Fail_Proc
:= Osint
.Fail
'Access;
40 -- Failing procedure called from procedure Test_If_Relative_Path below.
43 Project_Tree
: constant Project_Tree_Ref
:= new Project_Tree_Data
;
47 (Option
: String_Access
;
48 To
: in out String_List_Access
;
49 Last
: in out Natural);
52 To
: in out String_List_Access
;
53 Last
: in out Natural);
54 -- Add a string to a list of strings
56 function Create_Name
(Name
: String) return File_Name_Type
;
57 function Create_Name
(Name
: String) return Name_Id
;
58 function Create_Name
(Name
: String) return Path_Name_Type
;
59 -- Get the Name_Id of a name
61 function Executable_Prefix_Path
return String;
62 -- Return the absolute path parent directory of the directory where the
63 -- current executable resides, if its directory is named "bin", otherwise
64 -- return an empty string.
66 procedure Inform
(N
: Name_Id
:= No_Name
; Msg
: String);
67 procedure Inform
(N
: File_Name_Type
; Msg
: String);
68 -- Prints out the program name followed by a colon, N and S
70 function Is_External_Assignment
(Argv
: String) return Boolean;
71 -- Verify that an external assignment switch is syntactically correct
76 -- -X"name=other value"
78 -- Assumptions: 'First = 1, Argv (1 .. 2) = "-X"
79 -- When this function returns True, the external assignment has
80 -- been entered by a call to Prj.Ext.Add, so that in a project
81 -- file, External ("name") will return "value".
83 function Linker_Options_Switches
84 (Project
: Project_Id
;
85 In_Tree
: Project_Tree_Ref
) return String_List
;
86 -- Collect the options specified in the Linker'Linker_Options attributes
87 -- of project Project, in project tree In_Tree, and in the projects that
88 -- it imports directly or indirectly, and returns the result.
90 -- Package Mains is used to store the mains specified on the command line
91 -- and to retrieve them when a project file is used, to verify that the
92 -- files exist and that they belong to a project file.
94 function Unit_Index_Of
(ALI_File
: File_Name_Type
) return Int
;
95 -- Find the index of a unit in a source file. Return zero if the file
96 -- is not a multi-unit source file.
100 -- Mains are stored in a table. An index is used to retrieve the mains
103 procedure Add_Main
(Name
: String);
104 -- Add one main to the table
106 procedure Set_Location
(Location
: Source_Ptr
);
107 -- Set the location of the last main added. By default, the location is
114 -- Reset the index to the beginning of the table
116 function Next_Main
return String;
117 -- Increase the index and return the next main.
118 -- If table is exhausted, return an empty string.
120 function Get_Location
return Source_Ptr
;
121 -- Get the location of the current main
123 procedure Update_Main
(Name
: String);
124 -- Update the file name of the current main
126 function Number_Of_Mains
return Natural;
127 -- Returns the number of mains added with Add_Main since the last call
132 procedure Test_If_Relative_Path
133 (Switch
: in out String_Access
;
134 Parent
: String_Access
;
135 Including_L_Switch
: Boolean := True;
136 Including_Non_Switch
: Boolean := True);
137 -- Test if Switch is a relative search path switch.
138 -- If it is, fail if Parent is null, otherwise prepend the path with
139 -- Parent. This subprogram is only called when using project files.
140 -- For gnatbind switches, Including_L_Switch is False, because the
141 -- argument of the -L switch is not a path.
143 function Path_Or_File_Name
(Path
: Path_Name_Type
) return String;
144 -- Returns a file name if -df is used, otherwise return a path name
146 ----------------------
147 -- Marking Routines --
148 ----------------------
150 procedure Mark
(Source_File
: File_Name_Type
; Index
: Int
:= 0);
151 -- Mark a unit, identified by its source file and, when Index is not 0,
152 -- the index of the unit in the source file. Marking is used to signal
153 -- that the unit has already been inserted in the Q.
156 (Source_File
: File_Name_Type
;
157 Index
: Int
:= 0) return Boolean;
158 -- Returns True if the unit was previously marked
160 procedure Delete_All_Marks
;
161 -- Remove all file/index couples marked