[multiple changes]
[gcc.git] / gcc / ada / makeutl.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M A K E U T L --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2004-2010, 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 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. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
25
26 with ALI;
27 with Namet; use Namet;
28 with Opt;
29 with Osint;
30 with Prj; use Prj;
31 with Prj.Tree;
32 with Types; use Types;
33
34 with GNAT.OS_Lib; use GNAT.OS_Lib;
35
36 package Makeutl is
37
38 type Fail_Proc is access procedure (S : String);
39 Do_Fail : Fail_Proc := Osint.Fail'Access;
40 -- Failing procedure called from procedure Test_If_Relative_Path below. May
41 -- be redirected.
42
43 Project_Tree : constant Project_Tree_Ref := new Project_Tree_Data;
44 -- The project tree
45
46 Source_Info_Option : constant String := "--source-info=";
47 -- Switch to indicate the source info file
48
49 Subdirs_Option : constant String := "--subdirs=";
50 -- Switch used to indicate that the real directories (object, exec,
51 -- library, ...) are subdirectories of those in the project file.
52
53 Unchecked_Shared_Lib_Imports : constant String :=
54 "--unchecked-shared-lib-imports";
55 -- Command line switch to allow shared library projects to import projects
56 -- that are not shared library projects.
57
58 Single_Compile_Per_Obj_Dir_Switch : constant String :=
59 "--single-compile-per-obj-dir";
60 -- Switch to forbid simultaneous compilations for the same object directory
61 -- when project files are used.
62
63 Create_Map_File_Switch : constant String := "--create-map-file";
64 -- Switch to create a map file when an executable is linked
65
66 procedure Add
67 (Option : String_Access;
68 To : in out String_List_Access;
69 Last : in out Natural);
70 procedure Add
71 (Option : String;
72 To : in out String_List_Access;
73 Last : in out Natural);
74 -- Add a string to a list of strings
75
76 function Create_Binder_Mapping_File return Path_Name_Type;
77 -- Create a binder mapping file and returns its path name
78
79 function Create_Name (Name : String) return File_Name_Type;
80 function Create_Name (Name : String) return Name_Id;
81 function Create_Name (Name : String) return Path_Name_Type;
82 -- Get an id for a name
83
84 function Base_Name_Index_For
85 (Main : String;
86 Main_Index : Int;
87 Index_Separator : Character) return File_Name_Type;
88 -- Returns the base name of Main, without the extension, followed by the
89 -- Index_Separator followed by the Main_Index if it is non-zero.
90
91 function Executable_Prefix_Path return String;
92 -- Return the absolute path parent directory of the directory where the
93 -- current executable resides, if its directory is named "bin", otherwise
94 -- return an empty string. When a directory is returned, it is guaranteed
95 -- to end with a directory separator.
96
97 procedure Inform (N : Name_Id := No_Name; Msg : String);
98 procedure Inform (N : File_Name_Type; Msg : String);
99 -- Prints out the program name followed by a colon, N and S
100
101 function File_Not_A_Source_Of
102 (Uname : Name_Id;
103 Sfile : File_Name_Type) return Boolean;
104 -- Check that file name Sfile is one of the source of unit Uname. Returns
105 -- True if the unit is in one of the project file, but the file name is not
106 -- one of its source. Returns False otherwise.
107
108 function Check_Source_Info_In_ALI
109 (The_ALI : ALI.ALI_Id;
110 Tree : Project_Tree_Ref) return Boolean;
111 -- Check whether all file references in ALI are still valid (i.e. the
112 -- source files are still associated with the same units). Return True
113 -- if everything is still valid.
114
115 function Is_External_Assignment
116 (Tree : Prj.Tree.Project_Node_Tree_Ref;
117 Argv : String) return Boolean;
118 -- Verify that an external assignment switch is syntactically correct
119 --
120 -- Correct forms are:
121 --
122 -- -Xname=value
123 -- -X"name=other value"
124 --
125 -- Assumptions: 'First = 1, Argv (1 .. 2) = "-X"
126 --
127 -- When this function returns True, the external assignment has been
128 -- entered by a call to Prj.Ext.Add, so that in a project file, External
129 -- ("name") will return "value".
130
131 procedure Verbose_Msg
132 (N1 : Name_Id;
133 S1 : String;
134 N2 : Name_Id := No_Name;
135 S2 : String := "";
136 Prefix : String := " -> ";
137 Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low);
138 procedure Verbose_Msg
139 (N1 : File_Name_Type;
140 S1 : String;
141 N2 : File_Name_Type := No_File;
142 S2 : String := "";
143 Prefix : String := " -> ";
144 Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low);
145 -- If the verbose flag (Verbose_Mode) is set and the verbosity level is at
146 -- least equal to Minimum_Verbosity, then print Prefix to standard output
147 -- followed by N1 and S1. If N2 /= No_Name then N2 is printed after S1. S2
148 -- is printed last. Both N1 and N2 are printed in quotation marks. The two
149 -- forms differ only in taking Name_Id or File_name_Type arguments.
150
151 function Linker_Options_Switches
152 (Project : Project_Id;
153 In_Tree : Project_Tree_Ref) return String_List;
154 -- Collect the options specified in the Linker'Linker_Options attributes
155 -- of project Project, in project tree In_Tree, and in the projects that
156 -- it imports directly or indirectly, and returns the result.
157
158 -- Package Mains is used to store the mains specified on the command line
159 -- and to retrieve them when a project file is used, to verify that the
160 -- files exist and that they belong to a project file.
161
162 function Unit_Index_Of (ALI_File : File_Name_Type) return Int;
163 -- Find the index of a unit in a source file. Return zero if the file is
164 -- not a multi-unit source file.
165
166 procedure Test_If_Relative_Path
167 (Switch : in out String_Access;
168 Parent : String;
169 Including_L_Switch : Boolean := True;
170 Including_Non_Switch : Boolean := True;
171 Including_RTS : Boolean := False);
172 -- Test if Switch is a relative search path switch. If it is, fail if
173 -- Parent is the empty string, otherwise prepend the path with Parent.
174 -- This subprogram is only called when using project files. For gnatbind
175 -- switches, Including_L_Switch is False, because the argument of the -L
176 -- switch is not a path. If Including_RTS is True, process also switches
177 -- --RTS=.
178
179 function Path_Or_File_Name (Path : Path_Name_Type) return String;
180 -- Returns a file name if -df is used, otherwise return a path name
181
182 -----------
183 -- Mains --
184 -----------
185
186 -- Mains are stored in a table. An index is used to retrieve the mains
187 -- from the table.
188
189 package Mains is
190
191 procedure Add_Main (Name : String);
192 -- Add one main to the table
193
194 procedure Set_Index (Index : Int);
195
196 procedure Set_Location (Location : Source_Ptr);
197 -- Set the location of the last main added. By default, the location is
198 -- No_Location.
199
200 procedure Delete;
201 -- Empty the table
202
203 procedure Reset;
204 -- Reset the index to the beginning of the table
205
206 function Next_Main return String;
207 -- Increase the index and return the next main. If table is exhausted,
208 -- return an empty string.
209
210 function Get_Index return Int;
211
212 function Get_Location return Source_Ptr;
213 -- Get the location of the current main
214
215 procedure Update_Main (Name : String);
216 -- Update the file name of the current main
217
218 function Number_Of_Mains return Natural;
219 -- Returns the number of mains added with Add_Main since the last call
220 -- to Delete.
221
222 end Mains;
223
224 ----------------------
225 -- Marking Routines --
226 ----------------------
227
228 procedure Mark (Source_File : File_Name_Type; Index : Int := 0);
229 -- Mark a unit, identified by its source file and, when Index is not 0, the
230 -- index of the unit in the source file. Marking is used to signal that the
231 -- unit has already been inserted in the Q.
232
233 function Is_Marked
234 (Source_File : File_Name_Type;
235 Index : Int := 0) return Boolean;
236 -- Returns True if the unit was previously marked
237
238 procedure Delete_All_Marks;
239 -- Remove all file/index couples marked
240
241 end Makeutl;