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