1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- P R J --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 2001-2012, 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 |
|
|
-- The following package declares the data types for GNAT project.
|
27 |
|
|
-- These data types may be used by GNAT Project-aware tools.
|
28 |
|
|
|
29 |
|
|
-- Children of these package implements various services on these data types.
|
30 |
|
|
-- See in particular Prj.Pars and Prj.Env.
|
31 |
|
|
|
32 |
|
|
with Casing; use Casing;
|
33 |
|
|
with Namet; use Namet;
|
34 |
|
|
with Osint;
|
35 |
|
|
with Scans; use Scans;
|
36 |
|
|
with Types; use Types;
|
37 |
|
|
|
38 |
|
|
with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
|
39 |
|
|
with GNAT.Dynamic_Tables;
|
40 |
|
|
with GNAT.OS_Lib; use GNAT.OS_Lib;
|
41 |
|
|
|
42 |
|
|
package Prj is
|
43 |
|
|
|
44 |
|
|
procedure Add_Restricted_Language (Name : String);
|
45 |
|
|
-- Call by gprbuild for each language specify by switch
|
46 |
|
|
-- --restricted-to-languages=.
|
47 |
|
|
|
48 |
|
|
function Is_Allowed_Language (Name : Name_Id) return Boolean;
|
49 |
|
|
-- Returns True if --restricted-to-languages= is not used or if Name
|
50 |
|
|
-- is one of the restricted languages.
|
51 |
|
|
|
52 |
|
|
All_Other_Names : constant Name_Id := Names_High_Bound;
|
53 |
|
|
-- Name used to replace others as an index of an associative array
|
54 |
|
|
-- attribute in situations where this is allowed.
|
55 |
|
|
|
56 |
|
|
Subdirs : String_Ptr := null;
|
57 |
|
|
-- The value after the equal sign in switch --subdirs=...
|
58 |
|
|
-- Contains the relative subdirectory.
|
59 |
|
|
|
60 |
|
|
type Library_Support is (None, Static_Only, Full);
|
61 |
|
|
-- Support for Library Project File.
|
62 |
|
|
-- - None: Library Project Files are not supported at all
|
63 |
|
|
-- - Static_Only: Library Project Files are only supported for static
|
64 |
|
|
-- libraries.
|
65 |
|
|
-- - Full: Library Project Files are supported for static and dynamic
|
66 |
|
|
-- (shared) libraries.
|
67 |
|
|
|
68 |
|
|
type Yes_No_Unknown is (Yes, No, Unknown);
|
69 |
|
|
-- Tri-state to decide if -lgnarl is needed when linking
|
70 |
|
|
|
71 |
|
|
type Project_Qualifier is
|
72 |
|
|
(Unspecified,
|
73 |
|
|
Standard,
|
74 |
|
|
Library,
|
75 |
|
|
Configuration,
|
76 |
|
|
Dry,
|
77 |
|
|
Aggregate,
|
78 |
|
|
Aggregate_Library);
|
79 |
|
|
-- Qualifiers that can prefix the reserved word "project" in a project
|
80 |
|
|
-- file:
|
81 |
|
|
-- Standard: standard project ...
|
82 |
|
|
-- Library: library project is ...
|
83 |
|
|
-- Dry: abstract project is
|
84 |
|
|
-- Aggregate: aggregate project is
|
85 |
|
|
-- Aggregate_Library: aggregate library project is ...
|
86 |
|
|
-- Configuration: configuration project is ...
|
87 |
|
|
|
88 |
|
|
subtype Aggregate_Project is
|
89 |
|
|
Project_Qualifier range Aggregate .. Aggregate_Library;
|
90 |
|
|
|
91 |
|
|
All_Packages : constant String_List_Access;
|
92 |
|
|
-- Default value of parameter Packages of procedures Parse, in Prj.Pars and
|
93 |
|
|
-- Prj.Part, indicating that all packages should be checked.
|
94 |
|
|
|
95 |
|
|
type Project_Tree_Data;
|
96 |
|
|
type Project_Tree_Ref is access all Project_Tree_Data;
|
97 |
|
|
-- Reference to a project tree. Several project trees may exist in memory
|
98 |
|
|
-- at the same time.
|
99 |
|
|
|
100 |
|
|
No_Project_Tree : constant Project_Tree_Ref;
|
101 |
|
|
|
102 |
|
|
procedure Free (Tree : in out Project_Tree_Ref);
|
103 |
|
|
-- Free memory associated with the tree
|
104 |
|
|
|
105 |
|
|
Config_Project_File_Extension : String := ".cgpr";
|
106 |
|
|
Project_File_Extension : String := ".gpr";
|
107 |
|
|
-- The standard config and user project file name extensions. They are not
|
108 |
|
|
-- constants, because Canonical_Case_File_Name is called on these variables
|
109 |
|
|
-- in the body of Prj.
|
110 |
|
|
|
111 |
|
|
function Empty_File return File_Name_Type;
|
112 |
|
|
function Empty_String return Name_Id;
|
113 |
|
|
-- Return the id for an empty string ""
|
114 |
|
|
|
115 |
|
|
type Path_Information is record
|
116 |
|
|
Name : Path_Name_Type := No_Path;
|
117 |
|
|
Display_Name : Path_Name_Type := No_Path;
|
118 |
|
|
end record;
|
119 |
|
|
-- Directory names always end with a directory separator
|
120 |
|
|
|
121 |
|
|
No_Path_Information : constant Path_Information := (No_Path, No_Path);
|
122 |
|
|
|
123 |
|
|
type Project_Data;
|
124 |
|
|
type Project_Id is access all Project_Data;
|
125 |
|
|
No_Project : constant Project_Id := null;
|
126 |
|
|
-- Id of a Project File
|
127 |
|
|
|
128 |
|
|
type String_List_Id is new Nat;
|
129 |
|
|
Nil_String : constant String_List_Id := 0;
|
130 |
|
|
type String_Element is record
|
131 |
|
|
Value : Name_Id := No_Name;
|
132 |
|
|
Index : Int := 0;
|
133 |
|
|
Display_Value : Name_Id := No_Name;
|
134 |
|
|
Location : Source_Ptr := No_Location;
|
135 |
|
|
Flag : Boolean := False;
|
136 |
|
|
Next : String_List_Id := Nil_String;
|
137 |
|
|
end record;
|
138 |
|
|
-- To hold values for string list variables and array elements.
|
139 |
|
|
-- Component Flag may be used for various purposes. For source
|
140 |
|
|
-- directories, it indicates if the directory contains Ada source(s).
|
141 |
|
|
|
142 |
|
|
package String_Element_Table is new GNAT.Dynamic_Tables
|
143 |
|
|
(Table_Component_Type => String_Element,
|
144 |
|
|
Table_Index_Type => String_List_Id,
|
145 |
|
|
Table_Low_Bound => 1,
|
146 |
|
|
Table_Initial => 200,
|
147 |
|
|
Table_Increment => 100);
|
148 |
|
|
-- The table for string elements in string lists
|
149 |
|
|
|
150 |
|
|
type Variable_Kind is (Undefined, List, Single);
|
151 |
|
|
-- Different kinds of variables
|
152 |
|
|
|
153 |
|
|
subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
|
154 |
|
|
-- The defined kinds of variables
|
155 |
|
|
|
156 |
|
|
Ignored : constant Variable_Kind;
|
157 |
|
|
-- Used to indicate that a package declaration must be ignored
|
158 |
|
|
-- while processing the project tree (unknown package name).
|
159 |
|
|
|
160 |
|
|
type Variable_Value (Kind : Variable_Kind := Undefined) is record
|
161 |
|
|
Project : Project_Id := No_Project;
|
162 |
|
|
Location : Source_Ptr := No_Location;
|
163 |
|
|
Default : Boolean := False;
|
164 |
|
|
case Kind is
|
165 |
|
|
when Undefined =>
|
166 |
|
|
null;
|
167 |
|
|
when List =>
|
168 |
|
|
Values : String_List_Id := Nil_String;
|
169 |
|
|
when Single =>
|
170 |
|
|
Value : Name_Id := No_Name;
|
171 |
|
|
Index : Int := 0;
|
172 |
|
|
end case;
|
173 |
|
|
end record;
|
174 |
|
|
-- Values for variables and array elements. Default is True if the
|
175 |
|
|
-- current value is the default one for the variable.
|
176 |
|
|
|
177 |
|
|
Nil_Variable_Value : constant Variable_Value;
|
178 |
|
|
-- Value of a non existing variable or array element
|
179 |
|
|
|
180 |
|
|
type Variable_Id is new Nat;
|
181 |
|
|
No_Variable : constant Variable_Id := 0;
|
182 |
|
|
type Variable is record
|
183 |
|
|
Next : Variable_Id := No_Variable;
|
184 |
|
|
Name : Name_Id;
|
185 |
|
|
Value : Variable_Value;
|
186 |
|
|
end record;
|
187 |
|
|
-- To hold the list of variables in a project file and in packages
|
188 |
|
|
|
189 |
|
|
package Variable_Element_Table is new GNAT.Dynamic_Tables
|
190 |
|
|
(Table_Component_Type => Variable,
|
191 |
|
|
Table_Index_Type => Variable_Id,
|
192 |
|
|
Table_Low_Bound => 1,
|
193 |
|
|
Table_Initial => 200,
|
194 |
|
|
Table_Increment => 100);
|
195 |
|
|
-- The table of variable in list of variables
|
196 |
|
|
|
197 |
|
|
type Array_Element_Id is new Nat;
|
198 |
|
|
No_Array_Element : constant Array_Element_Id := 0;
|
199 |
|
|
type Array_Element is record
|
200 |
|
|
Index : Name_Id;
|
201 |
|
|
Restricted : Boolean := False;
|
202 |
|
|
Src_Index : Int := 0;
|
203 |
|
|
Index_Case_Sensitive : Boolean := True;
|
204 |
|
|
Value : Variable_Value;
|
205 |
|
|
Next : Array_Element_Id := No_Array_Element;
|
206 |
|
|
end record;
|
207 |
|
|
-- Each Array_Element represents an array element and is linked (Next)
|
208 |
|
|
-- to the next array element, if any, in the array.
|
209 |
|
|
|
210 |
|
|
package Array_Element_Table is new GNAT.Dynamic_Tables
|
211 |
|
|
(Table_Component_Type => Array_Element,
|
212 |
|
|
Table_Index_Type => Array_Element_Id,
|
213 |
|
|
Table_Low_Bound => 1,
|
214 |
|
|
Table_Initial => 200,
|
215 |
|
|
Table_Increment => 100);
|
216 |
|
|
-- The table that contains all array elements
|
217 |
|
|
|
218 |
|
|
type Array_Id is new Nat;
|
219 |
|
|
No_Array : constant Array_Id := 0;
|
220 |
|
|
type Array_Data is record
|
221 |
|
|
Name : Name_Id := No_Name;
|
222 |
|
|
Location : Source_Ptr := No_Location;
|
223 |
|
|
Value : Array_Element_Id := No_Array_Element;
|
224 |
|
|
Next : Array_Id := No_Array;
|
225 |
|
|
end record;
|
226 |
|
|
-- Each Array_Data value represents an array.
|
227 |
|
|
-- Value is the id of the first element.
|
228 |
|
|
-- Next is the id of the next array in the project file or package.
|
229 |
|
|
|
230 |
|
|
package Array_Table is new GNAT.Dynamic_Tables
|
231 |
|
|
(Table_Component_Type => Array_Data,
|
232 |
|
|
Table_Index_Type => Array_Id,
|
233 |
|
|
Table_Low_Bound => 1,
|
234 |
|
|
Table_Initial => 200,
|
235 |
|
|
Table_Increment => 100);
|
236 |
|
|
-- The table that contains all arrays
|
237 |
|
|
|
238 |
|
|
type Package_Id is new Nat;
|
239 |
|
|
No_Package : constant Package_Id := 0;
|
240 |
|
|
type Declarations is record
|
241 |
|
|
Variables : Variable_Id := No_Variable;
|
242 |
|
|
Attributes : Variable_Id := No_Variable;
|
243 |
|
|
Arrays : Array_Id := No_Array;
|
244 |
|
|
Packages : Package_Id := No_Package;
|
245 |
|
|
end record;
|
246 |
|
|
-- Contains the declarations (variables, single and array attributes,
|
247 |
|
|
-- packages) for a project or a package in a project.
|
248 |
|
|
|
249 |
|
|
No_Declarations : constant Declarations :=
|
250 |
|
|
(Variables => No_Variable,
|
251 |
|
|
Attributes => No_Variable,
|
252 |
|
|
Arrays => No_Array,
|
253 |
|
|
Packages => No_Package);
|
254 |
|
|
-- Default value of Declarations: indicates that there is no declarations
|
255 |
|
|
|
256 |
|
|
type Package_Element is record
|
257 |
|
|
Name : Name_Id := No_Name;
|
258 |
|
|
Decl : Declarations := No_Declarations;
|
259 |
|
|
Parent : Package_Id := No_Package;
|
260 |
|
|
Next : Package_Id := No_Package;
|
261 |
|
|
end record;
|
262 |
|
|
-- A package (includes declarations that may include other packages)
|
263 |
|
|
|
264 |
|
|
package Package_Table is new GNAT.Dynamic_Tables
|
265 |
|
|
(Table_Component_Type => Package_Element,
|
266 |
|
|
Table_Index_Type => Package_Id,
|
267 |
|
|
Table_Low_Bound => 1,
|
268 |
|
|
Table_Initial => 100,
|
269 |
|
|
Table_Increment => 100);
|
270 |
|
|
-- The table that contains all packages
|
271 |
|
|
|
272 |
|
|
type Language_Data;
|
273 |
|
|
type Language_Ptr is access all Language_Data;
|
274 |
|
|
-- Index of language data
|
275 |
|
|
|
276 |
|
|
No_Language_Index : constant Language_Ptr := null;
|
277 |
|
|
-- Constant indicating that there is no language data
|
278 |
|
|
|
279 |
|
|
function Get_Language_From_Name
|
280 |
|
|
(Project : Project_Id;
|
281 |
|
|
Name : String) return Language_Ptr;
|
282 |
|
|
-- Get a language from a project. This might return null if no such
|
283 |
|
|
-- language exists in the project
|
284 |
|
|
|
285 |
|
|
Max_Header_Num : constant := 6150;
|
286 |
|
|
type Header_Num is range 0 .. Max_Header_Num;
|
287 |
|
|
-- Size for hash table below. The upper bound is an arbitrary value, the
|
288 |
|
|
-- value here was chosen after testing to determine a good compromise
|
289 |
|
|
-- between speed of access and memory usage.
|
290 |
|
|
|
291 |
|
|
function Hash (Name : Name_Id) return Header_Num;
|
292 |
|
|
function Hash (Name : File_Name_Type) return Header_Num;
|
293 |
|
|
function Hash (Name : Path_Name_Type) return Header_Num;
|
294 |
|
|
function Hash (Project : Project_Id) return Header_Num;
|
295 |
|
|
-- Used for computing hash values for names put into hash tables
|
296 |
|
|
|
297 |
|
|
type Language_Kind is (File_Based, Unit_Based);
|
298 |
|
|
-- Type for the kind of language. All languages are file based, except Ada
|
299 |
|
|
-- which is unit based.
|
300 |
|
|
|
301 |
|
|
type Dependency_File_Kind is (None, Makefile, ALI_File);
|
302 |
|
|
-- Type of dependency to be checked: no dependency file, Makefile fragment
|
303 |
|
|
-- or ALI file (for Ada).
|
304 |
|
|
|
305 |
|
|
Makefile_Dependency_Suffix : constant String := ".d";
|
306 |
|
|
ALI_Dependency_Suffix : constant String := ".ali";
|
307 |
|
|
Switches_Dependency_Suffix : constant String := ".cswi";
|
308 |
|
|
|
309 |
|
|
Binder_Exchange_Suffix : constant String := ".bexch";
|
310 |
|
|
-- Suffix for binder exchange files
|
311 |
|
|
|
312 |
|
|
Library_Exchange_Suffix : constant String := ".lexch";
|
313 |
|
|
-- Suffix for library exchange files
|
314 |
|
|
|
315 |
|
|
type Name_List_Index is new Nat;
|
316 |
|
|
No_Name_List : constant Name_List_Index := 0;
|
317 |
|
|
|
318 |
|
|
type Name_Node is record
|
319 |
|
|
Name : Name_Id := No_Name;
|
320 |
|
|
Next : Name_List_Index := No_Name_List;
|
321 |
|
|
end record;
|
322 |
|
|
|
323 |
|
|
package Name_List_Table is new GNAT.Dynamic_Tables
|
324 |
|
|
(Table_Component_Type => Name_Node,
|
325 |
|
|
Table_Index_Type => Name_List_Index,
|
326 |
|
|
Table_Low_Bound => 1,
|
327 |
|
|
Table_Initial => 10,
|
328 |
|
|
Table_Increment => 100);
|
329 |
|
|
-- The table for lists of names
|
330 |
|
|
|
331 |
|
|
function Length
|
332 |
|
|
(Table : Name_List_Table.Instance;
|
333 |
|
|
List : Name_List_Index) return Natural;
|
334 |
|
|
-- Return the number of elements in specified list
|
335 |
|
|
|
336 |
|
|
type Number_List_Index is new Nat;
|
337 |
|
|
No_Number_List : constant Number_List_Index := 0;
|
338 |
|
|
|
339 |
|
|
type Number_Node is record
|
340 |
|
|
Number : Natural := 0;
|
341 |
|
|
Next : Number_List_Index := No_Number_List;
|
342 |
|
|
end record;
|
343 |
|
|
|
344 |
|
|
package Number_List_Table is new GNAT.Dynamic_Tables
|
345 |
|
|
(Table_Component_Type => Number_Node,
|
346 |
|
|
Table_Index_Type => Number_List_Index,
|
347 |
|
|
Table_Low_Bound => 1,
|
348 |
|
|
Table_Initial => 10,
|
349 |
|
|
Table_Increment => 100);
|
350 |
|
|
-- The table for lists of numbers
|
351 |
|
|
|
352 |
|
|
package Mapping_Files_Htable is new Simple_HTable
|
353 |
|
|
(Header_Num => Header_Num,
|
354 |
|
|
Element => Path_Name_Type,
|
355 |
|
|
No_Element => No_Path,
|
356 |
|
|
Key => Path_Name_Type,
|
357 |
|
|
Hash => Hash,
|
358 |
|
|
Equal => "=");
|
359 |
|
|
-- A hash table to store the mapping files that are not used
|
360 |
|
|
|
361 |
|
|
-- The following record ???
|
362 |
|
|
|
363 |
|
|
type Lang_Naming_Data is record
|
364 |
|
|
Dot_Replacement : File_Name_Type := No_File;
|
365 |
|
|
-- The string to replace '.' in the source file name (for Ada)
|
366 |
|
|
|
367 |
|
|
Casing : Casing_Type := All_Lower_Case;
|
368 |
|
|
-- The casing of the source file name (for Ada)
|
369 |
|
|
|
370 |
|
|
Separate_Suffix : File_Name_Type := No_File;
|
371 |
|
|
-- String to append to unit name for source file name of an Ada subunit
|
372 |
|
|
|
373 |
|
|
Spec_Suffix : File_Name_Type := No_File;
|
374 |
|
|
-- The string to append to the unit name for the
|
375 |
|
|
-- source file name of a spec.
|
376 |
|
|
|
377 |
|
|
Body_Suffix : File_Name_Type := No_File;
|
378 |
|
|
-- The string to append to the unit name for the
|
379 |
|
|
-- source file name of a body.
|
380 |
|
|
end record;
|
381 |
|
|
|
382 |
|
|
No_Lang_Naming_Data : constant Lang_Naming_Data :=
|
383 |
|
|
(Dot_Replacement => No_File,
|
384 |
|
|
Casing => All_Lower_Case,
|
385 |
|
|
Separate_Suffix => No_File,
|
386 |
|
|
Spec_Suffix => No_File,
|
387 |
|
|
Body_Suffix => No_File);
|
388 |
|
|
|
389 |
|
|
function Is_Standard_GNAT_Naming (Naming : Lang_Naming_Data) return Boolean;
|
390 |
|
|
-- True if the naming scheme is GNAT's default naming scheme. This
|
391 |
|
|
-- is to take into account shortened names like "Ada." (a-), "System." (s-)
|
392 |
|
|
-- and so on.
|
393 |
|
|
|
394 |
|
|
type Source_Data;
|
395 |
|
|
type Source_Id is access all Source_Data;
|
396 |
|
|
|
397 |
|
|
function Is_Compilable (Source : Source_Id) return Boolean;
|
398 |
|
|
pragma Inline (Is_Compilable);
|
399 |
|
|
-- Return True if we know how to compile Source (i.e. if a compiler is
|
400 |
|
|
-- defined). This doesn't indicate whether the source should be compiled.
|
401 |
|
|
|
402 |
|
|
function Object_To_Global_Archive (Source : Source_Id) return Boolean;
|
403 |
|
|
pragma Inline (Object_To_Global_Archive);
|
404 |
|
|
-- Return True if the object file should be put in the global archive.
|
405 |
|
|
-- This is for Ada, when only the closure of a main needs to be
|
406 |
|
|
-- (re)compiled.
|
407 |
|
|
|
408 |
|
|
function Other_Part (Source : Source_Id) return Source_Id;
|
409 |
|
|
pragma Inline (Other_Part);
|
410 |
|
|
-- Source ID for the other part, if any: for a spec, indicates its body;
|
411 |
|
|
-- for a body, indicates its spec.
|
412 |
|
|
|
413 |
|
|
No_Source : constant Source_Id := null;
|
414 |
|
|
|
415 |
|
|
type Path_Syntax_Kind is
|
416 |
|
|
(Canonical,
|
417 |
|
|
-- Unix style
|
418 |
|
|
Host);
|
419 |
|
|
-- Host specific syntax, for example on VMS (the default)
|
420 |
|
|
|
421 |
|
|
-- The following record describes the configuration of a language
|
422 |
|
|
|
423 |
|
|
type Language_Config is record
|
424 |
|
|
Kind : Language_Kind := File_Based;
|
425 |
|
|
-- Kind of language. Most languages are file based. A few, such as Ada,
|
426 |
|
|
-- are unit based.
|
427 |
|
|
|
428 |
|
|
Naming_Data : Lang_Naming_Data;
|
429 |
|
|
-- The naming data for the languages (prefixes, etc.)
|
430 |
|
|
|
431 |
|
|
Include_Compatible_Languages : Name_List_Index := No_Name_List;
|
432 |
|
|
-- List of languages that are "include compatible" with this language. A
|
433 |
|
|
-- language B (for example "C") is "include compatible" with a language
|
434 |
|
|
-- A (for example "C++") if it is expected that sources of language A
|
435 |
|
|
-- may "include" header files from language B.
|
436 |
|
|
|
437 |
|
|
Compiler_Driver : File_Name_Type := No_File;
|
438 |
|
|
-- The name of the executable for the compiler of the language
|
439 |
|
|
|
440 |
|
|
Compiler_Driver_Path : String_Access := null;
|
441 |
|
|
-- The path name of the executable for the compiler of the language
|
442 |
|
|
|
443 |
|
|
Compiler_Leading_Required_Switches : Name_List_Index := No_Name_List;
|
444 |
|
|
-- The list of initial switches that are required as a minimum to invoke
|
445 |
|
|
-- the compiler driver.
|
446 |
|
|
|
447 |
|
|
Compiler_Trailing_Required_Switches : Name_List_Index := No_Name_List;
|
448 |
|
|
-- The list of final switches that are required as a minimum to invoke
|
449 |
|
|
-- the compiler driver.
|
450 |
|
|
|
451 |
|
|
Multi_Unit_Switches : Name_List_Index := No_Name_List;
|
452 |
|
|
-- The switch(es) to indicate the index of a unit in a multi-source file
|
453 |
|
|
|
454 |
|
|
Multi_Unit_Object_Separator : Character := ' ';
|
455 |
|
|
-- The string separating the base name of a source from the index of the
|
456 |
|
|
-- unit in a multi-source file, in the object file name.
|
457 |
|
|
|
458 |
|
|
Path_Syntax : Path_Syntax_Kind := Host;
|
459 |
|
|
-- Value may be Canonical (Unix style) or Host (host syntax, for example
|
460 |
|
|
-- on VMS for DEC C).
|
461 |
|
|
|
462 |
|
|
Source_File_Switches : Name_List_Index := No_Name_List;
|
463 |
|
|
-- Optional switches to be put before the source file. The source file
|
464 |
|
|
-- path name is appended to the last switch in the list.
|
465 |
|
|
-- Example: ("-i", "");
|
466 |
|
|
|
467 |
|
|
Object_File_Suffix : Name_Id := No_Name;
|
468 |
|
|
-- Optional alternate object file suffix
|
469 |
|
|
|
470 |
|
|
Object_File_Switches : Name_List_Index := No_Name_List;
|
471 |
|
|
-- Optional object file switches. When this is defined, the switches
|
472 |
|
|
-- are used to specify the object file. The object file name is appended
|
473 |
|
|
-- to the last switch in the list. Example: ("-o", "").
|
474 |
|
|
|
475 |
|
|
Compilation_PIC_Option : Name_List_Index := No_Name_List;
|
476 |
|
|
-- The option(s) to compile a source in Position Independent Code for
|
477 |
|
|
-- shared libraries. Specified in the configuration. When not specified,
|
478 |
|
|
-- there is no need for such switch.
|
479 |
|
|
|
480 |
|
|
Object_Generated : Boolean := True;
|
481 |
|
|
-- False in no object file is generated
|
482 |
|
|
|
483 |
|
|
Objects_Linked : Boolean := True;
|
484 |
|
|
-- False if object files are not use to link executables and build
|
485 |
|
|
-- libraries.
|
486 |
|
|
|
487 |
|
|
Runtime_Library_Dir : Name_Id := No_Name;
|
488 |
|
|
-- Path name of the runtime library directory, if any
|
489 |
|
|
|
490 |
|
|
Runtime_Source_Dir : Name_Id := No_Name;
|
491 |
|
|
-- Path name of the runtime source directory, if any
|
492 |
|
|
|
493 |
|
|
Mapping_File_Switches : Name_List_Index := No_Name_List;
|
494 |
|
|
-- The option(s) to provide a mapping file to the compiler. Specified in
|
495 |
|
|
-- the configuration. When value is No_Name_List, there is no mapping
|
496 |
|
|
-- file.
|
497 |
|
|
|
498 |
|
|
Mapping_Spec_Suffix : File_Name_Type := No_File;
|
499 |
|
|
-- Placeholder representing the spec suffix in a mapping file
|
500 |
|
|
|
501 |
|
|
Mapping_Body_Suffix : File_Name_Type := No_File;
|
502 |
|
|
-- Placeholder representing the body suffix in a mapping file
|
503 |
|
|
|
504 |
|
|
Config_File_Switches : Name_List_Index := No_Name_List;
|
505 |
|
|
-- The option(s) to provide a config file to the compiler. Specified in
|
506 |
|
|
-- the configuration. If value is No_Name_List there is no config file.
|
507 |
|
|
|
508 |
|
|
Dependency_Kind : Dependency_File_Kind := None;
|
509 |
|
|
-- The kind of dependency to be checked: none, Makefile fragment or
|
510 |
|
|
-- ALI file (for Ada).
|
511 |
|
|
|
512 |
|
|
Dependency_Option : Name_List_Index := No_Name_List;
|
513 |
|
|
-- The option(s) to be used to create the dependency file. When value is
|
514 |
|
|
-- No_Name_List, there is not such option(s).
|
515 |
|
|
|
516 |
|
|
Compute_Dependency : Name_List_Index := No_Name_List;
|
517 |
|
|
-- Hold the value of attribute Dependency_Driver, if declared for the
|
518 |
|
|
-- language.
|
519 |
|
|
|
520 |
|
|
Include_Option : Name_List_Index := No_Name_List;
|
521 |
|
|
-- Hold the value of attribute Include_Switches, if declared for the
|
522 |
|
|
-- language.
|
523 |
|
|
|
524 |
|
|
Include_Path : Name_Id := No_Name;
|
525 |
|
|
-- Name of environment variable declared by attribute Include_Path for
|
526 |
|
|
-- the language.
|
527 |
|
|
|
528 |
|
|
Include_Path_File : Name_Id := No_Name;
|
529 |
|
|
-- Name of environment variable declared by attribute Include_Path_File
|
530 |
|
|
-- for the language.
|
531 |
|
|
|
532 |
|
|
Objects_Path : Name_Id := No_Name;
|
533 |
|
|
-- Name of environment variable declared by attribute Objects_Path for
|
534 |
|
|
-- the language.
|
535 |
|
|
|
536 |
|
|
Objects_Path_File : Name_Id := No_Name;
|
537 |
|
|
-- Name of environment variable declared by attribute Objects_Path_File
|
538 |
|
|
-- for the language.
|
539 |
|
|
|
540 |
|
|
Config_Body : Name_Id := No_Name;
|
541 |
|
|
-- The template for a pragma Source_File_Name(_Project) for a specific
|
542 |
|
|
-- file name of a body.
|
543 |
|
|
|
544 |
|
|
Config_Body_Index : Name_Id := No_Name;
|
545 |
|
|
-- The template for a pragma Source_File_Name(_Project) for a specific
|
546 |
|
|
-- file name of a body in a multi-source file.
|
547 |
|
|
|
548 |
|
|
Config_Body_Pattern : Name_Id := No_Name;
|
549 |
|
|
-- The template for a pragma Source_File_Name(_Project) for a naming
|
550 |
|
|
-- body pattern.
|
551 |
|
|
|
552 |
|
|
Config_Spec : Name_Id := No_Name;
|
553 |
|
|
-- The template for a pragma Source_File_Name(_Project) for a specific
|
554 |
|
|
-- file name of a spec.
|
555 |
|
|
|
556 |
|
|
Config_Spec_Index : Name_Id := No_Name;
|
557 |
|
|
-- The template for a pragma Source_File_Name(_Project) for a specific
|
558 |
|
|
-- file name of a spec in a multi-source file.
|
559 |
|
|
|
560 |
|
|
Config_Spec_Pattern : Name_Id := No_Name;
|
561 |
|
|
-- The template for a pragma Source_File_Name(_Project) for a naming
|
562 |
|
|
-- spec pattern.
|
563 |
|
|
|
564 |
|
|
Config_File_Unique : Boolean := False;
|
565 |
|
|
-- Indicate if the config file specified to the compiler needs to be
|
566 |
|
|
-- unique. If it is unique, then all config files are concatenated into
|
567 |
|
|
-- a temp config file.
|
568 |
|
|
|
569 |
|
|
Binder_Driver : File_Name_Type := No_File;
|
570 |
|
|
-- The name of the binder driver for the language, if any
|
571 |
|
|
|
572 |
|
|
Binder_Driver_Path : Path_Name_Type := No_Path;
|
573 |
|
|
-- The path name of the binder driver
|
574 |
|
|
|
575 |
|
|
Binder_Required_Switches : Name_List_Index := No_Name_List;
|
576 |
|
|
-- Hold the value of attribute Binder'Required_Switches for the language
|
577 |
|
|
|
578 |
|
|
Binder_Prefix : Name_Id := No_Name;
|
579 |
|
|
-- Hold the value of attribute Binder'Prefix for the language
|
580 |
|
|
|
581 |
|
|
Toolchain_Version : Name_Id := No_Name;
|
582 |
|
|
-- Hold the value of attribute Toolchain_Version for the language
|
583 |
|
|
|
584 |
|
|
Toolchain_Description : Name_Id := No_Name;
|
585 |
|
|
-- Hold the value of attribute Toolchain_Description for the language
|
586 |
|
|
|
587 |
|
|
end record;
|
588 |
|
|
|
589 |
|
|
No_Language_Config : constant Language_Config :=
|
590 |
|
|
(Kind => File_Based,
|
591 |
|
|
Naming_Data => No_Lang_Naming_Data,
|
592 |
|
|
Include_Compatible_Languages => No_Name_List,
|
593 |
|
|
Compiler_Driver => No_File,
|
594 |
|
|
Compiler_Driver_Path => null,
|
595 |
|
|
Compiler_Leading_Required_Switches
|
596 |
|
|
=> No_Name_List,
|
597 |
|
|
Compiler_Trailing_Required_Switches
|
598 |
|
|
=> No_Name_List,
|
599 |
|
|
Multi_Unit_Switches => No_Name_List,
|
600 |
|
|
Multi_Unit_Object_Separator => ' ',
|
601 |
|
|
Path_Syntax => Canonical,
|
602 |
|
|
Source_File_Switches => No_Name_List,
|
603 |
|
|
Object_File_Suffix => No_Name,
|
604 |
|
|
Object_File_Switches => No_Name_List,
|
605 |
|
|
Compilation_PIC_Option => No_Name_List,
|
606 |
|
|
Object_Generated => True,
|
607 |
|
|
Objects_Linked => True,
|
608 |
|
|
Runtime_Library_Dir => No_Name,
|
609 |
|
|
Runtime_Source_Dir => No_Name,
|
610 |
|
|
Mapping_File_Switches => No_Name_List,
|
611 |
|
|
Mapping_Spec_Suffix => No_File,
|
612 |
|
|
Mapping_Body_Suffix => No_File,
|
613 |
|
|
Config_File_Switches => No_Name_List,
|
614 |
|
|
Dependency_Kind => None,
|
615 |
|
|
Dependency_Option => No_Name_List,
|
616 |
|
|
Compute_Dependency => No_Name_List,
|
617 |
|
|
Include_Option => No_Name_List,
|
618 |
|
|
Include_Path => No_Name,
|
619 |
|
|
Include_Path_File => No_Name,
|
620 |
|
|
Objects_Path => No_Name,
|
621 |
|
|
Objects_Path_File => No_Name,
|
622 |
|
|
Config_Body => No_Name,
|
623 |
|
|
Config_Body_Index => No_Name,
|
624 |
|
|
Config_Body_Pattern => No_Name,
|
625 |
|
|
Config_Spec => No_Name,
|
626 |
|
|
Config_Spec_Index => No_Name,
|
627 |
|
|
Config_Spec_Pattern => No_Name,
|
628 |
|
|
Config_File_Unique => False,
|
629 |
|
|
Binder_Driver => No_File,
|
630 |
|
|
Binder_Driver_Path => No_Path,
|
631 |
|
|
Binder_Required_Switches => No_Name_List,
|
632 |
|
|
Binder_Prefix => No_Name,
|
633 |
|
|
Toolchain_Version => No_Name,
|
634 |
|
|
Toolchain_Description => No_Name);
|
635 |
|
|
|
636 |
|
|
-- The following record ???
|
637 |
|
|
|
638 |
|
|
type Language_Data is record
|
639 |
|
|
Name : Name_Id := No_Name;
|
640 |
|
|
Display_Name : Name_Id := No_Name;
|
641 |
|
|
Config : Language_Config := No_Language_Config;
|
642 |
|
|
First_Source : Source_Id := No_Source;
|
643 |
|
|
Mapping_Files : Mapping_Files_Htable.Instance :=
|
644 |
|
|
Mapping_Files_Htable.Nil;
|
645 |
|
|
Next : Language_Ptr := No_Language_Index;
|
646 |
|
|
end record;
|
647 |
|
|
|
648 |
|
|
No_Language_Data : constant Language_Data :=
|
649 |
|
|
(Name => No_Name,
|
650 |
|
|
Display_Name => No_Name,
|
651 |
|
|
Config => No_Language_Config,
|
652 |
|
|
First_Source => No_Source,
|
653 |
|
|
Mapping_Files => Mapping_Files_Htable.Nil,
|
654 |
|
|
Next => No_Language_Index);
|
655 |
|
|
|
656 |
|
|
type Language_List_Element;
|
657 |
|
|
type Language_List is access all Language_List_Element;
|
658 |
|
|
type Language_List_Element is record
|
659 |
|
|
Language : Language_Ptr := No_Language_Index;
|
660 |
|
|
Next : Language_List;
|
661 |
|
|
end record;
|
662 |
|
|
|
663 |
|
|
type Source_Kind is (Spec, Impl, Sep);
|
664 |
|
|
subtype Spec_Or_Body is Source_Kind range Spec .. Impl;
|
665 |
|
|
|
666 |
|
|
-- The following declarations declare a structure used to store the Name
|
667 |
|
|
-- and File and Path names of a unit, with a reference to its GNAT Project
|
668 |
|
|
-- File(s). Some units might have neither Spec nor Impl when they were
|
669 |
|
|
-- created for a "separate".
|
670 |
|
|
|
671 |
|
|
type File_Names_Data is array (Spec_Or_Body) of Source_Id;
|
672 |
|
|
|
673 |
|
|
type Unit_Data is record
|
674 |
|
|
Name : Name_Id := No_Name;
|
675 |
|
|
File_Names : File_Names_Data;
|
676 |
|
|
end record;
|
677 |
|
|
|
678 |
|
|
type Unit_Index is access all Unit_Data;
|
679 |
|
|
|
680 |
|
|
No_Unit_Index : constant Unit_Index := null;
|
681 |
|
|
-- Used to indicate a null entry for no unit
|
682 |
|
|
|
683 |
|
|
type Source_Roots;
|
684 |
|
|
type Roots_Access is access Source_Roots;
|
685 |
|
|
type Source_Roots is record
|
686 |
|
|
Root : Source_Id;
|
687 |
|
|
Next : Roots_Access;
|
688 |
|
|
end record;
|
689 |
|
|
-- A list to store the roots associated with a main unit. These are the
|
690 |
|
|
-- files that need to linked along with the main (for instance a C file
|
691 |
|
|
-- corresponding to an Ada file). In general, these are dependencies that
|
692 |
|
|
-- cannot be computed automatically by the builder.
|
693 |
|
|
|
694 |
|
|
type Naming_Exception_Type is (No, Yes, Inherited);
|
695 |
|
|
|
696 |
|
|
-- Structure to define source data
|
697 |
|
|
|
698 |
|
|
type Source_Data is record
|
699 |
|
|
Initialized : Boolean := False;
|
700 |
|
|
-- Set to True when Source_Data is completely initialized
|
701 |
|
|
|
702 |
|
|
Project : Project_Id := No_Project;
|
703 |
|
|
-- Project of the source
|
704 |
|
|
|
705 |
|
|
Location : Source_Ptr := No_Location;
|
706 |
|
|
-- Location in the project file of the declaration of the source in
|
707 |
|
|
-- package Naming.
|
708 |
|
|
|
709 |
|
|
Source_Dir_Rank : Natural := 0;
|
710 |
|
|
-- The rank of the source directory in list declared with attribute
|
711 |
|
|
-- Source_Dirs. Two source files with the same name cannot appears in
|
712 |
|
|
-- different directory with the same rank. That can happen when the
|
713 |
|
|
-- recursive notation <dir>/** is used in attribute Source_Dirs.
|
714 |
|
|
|
715 |
|
|
Language : Language_Ptr := No_Language_Index;
|
716 |
|
|
-- Index of the language. This is an index into
|
717 |
|
|
-- Project_Tree.Languages_Data.
|
718 |
|
|
|
719 |
|
|
In_Interfaces : Boolean := True;
|
720 |
|
|
-- False when the source is not included in interfaces, when attribute
|
721 |
|
|
-- Interfaces is declared.
|
722 |
|
|
|
723 |
|
|
Declared_In_Interfaces : Boolean := False;
|
724 |
|
|
-- True when source is declared in attribute Interfaces
|
725 |
|
|
|
726 |
|
|
Alternate_Languages : Language_List := null;
|
727 |
|
|
-- List of languages a header file may also be, in addition of language
|
728 |
|
|
-- Language_Name.
|
729 |
|
|
|
730 |
|
|
Kind : Source_Kind := Spec;
|
731 |
|
|
-- Kind of the source: spec, body or subunit
|
732 |
|
|
|
733 |
|
|
Unit : Unit_Index := No_Unit_Index;
|
734 |
|
|
-- Name of the unit, if language is unit based. This is only set for
|
735 |
|
|
-- those files that are part of the compilation set (for instance a
|
736 |
|
|
-- file in an extended project that is overridden will not have this
|
737 |
|
|
-- field set).
|
738 |
|
|
|
739 |
|
|
Index : Int := 0;
|
740 |
|
|
-- Index of the source in a multi unit source file (the same Source_Data
|
741 |
|
|
-- is duplicated several times when there are several units in the same
|
742 |
|
|
-- file). Index is 0 if there is either no unit or a single one, and
|
743 |
|
|
-- starts at 1 when there are multiple units
|
744 |
|
|
|
745 |
|
|
Compilable : Yes_No_Unknown := Unknown;
|
746 |
|
|
-- Updated at the first call to Is_Compilable. Yes if source file is
|
747 |
|
|
-- compilable.
|
748 |
|
|
|
749 |
|
|
In_The_Queue : Boolean := False;
|
750 |
|
|
-- True if the source has been put in the queue
|
751 |
|
|
|
752 |
|
|
Locally_Removed : Boolean := False;
|
753 |
|
|
-- True if the source has been "excluded"
|
754 |
|
|
|
755 |
|
|
Replaced_By : Source_Id := No_Source;
|
756 |
|
|
-- Missing comment ???
|
757 |
|
|
|
758 |
|
|
File : File_Name_Type := No_File;
|
759 |
|
|
-- Canonical file name of the source
|
760 |
|
|
|
761 |
|
|
Display_File : File_Name_Type := No_File;
|
762 |
|
|
-- File name of the source, for display purposes
|
763 |
|
|
|
764 |
|
|
Path : Path_Information := No_Path_Information;
|
765 |
|
|
-- Path name of the source
|
766 |
|
|
|
767 |
|
|
Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
|
768 |
|
|
-- Time stamp of the source file
|
769 |
|
|
|
770 |
|
|
Object_Project : Project_Id := No_Project;
|
771 |
|
|
-- Project where the object file is. This might be different from
|
772 |
|
|
-- Project when using extending project files.
|
773 |
|
|
|
774 |
|
|
Object : File_Name_Type := No_File;
|
775 |
|
|
-- File name of the object file
|
776 |
|
|
|
777 |
|
|
Current_Object_Path : Path_Name_Type := No_Path;
|
778 |
|
|
-- Object path of an existing object file
|
779 |
|
|
|
780 |
|
|
Object_Path : Path_Name_Type := No_Path;
|
781 |
|
|
-- Object path of the real object file
|
782 |
|
|
|
783 |
|
|
Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
|
784 |
|
|
-- Object file time stamp
|
785 |
|
|
|
786 |
|
|
Dep_Name : File_Name_Type := No_File;
|
787 |
|
|
-- Dependency file simple name
|
788 |
|
|
|
789 |
|
|
Current_Dep_Path : Path_Name_Type := No_Path;
|
790 |
|
|
-- Path name of an existing dependency file
|
791 |
|
|
|
792 |
|
|
Dep_Path : Path_Name_Type := No_Path;
|
793 |
|
|
-- Path name of the real dependency file
|
794 |
|
|
|
795 |
|
|
Dep_TS : aliased Osint.File_Attributes := Osint.Unknown_Attributes;
|
796 |
|
|
-- Dependency file time stamp
|
797 |
|
|
|
798 |
|
|
Switches : File_Name_Type := No_File;
|
799 |
|
|
-- File name of the switches file. For all languages, this is a file
|
800 |
|
|
-- that ends with the .cswi extension.
|
801 |
|
|
|
802 |
|
|
Switches_Path : Path_Name_Type := No_Path;
|
803 |
|
|
-- Path name of the switches file
|
804 |
|
|
|
805 |
|
|
Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
|
806 |
|
|
-- Switches file time stamp
|
807 |
|
|
|
808 |
|
|
Naming_Exception : Naming_Exception_Type := No;
|
809 |
|
|
-- True if the source has an exceptional name
|
810 |
|
|
|
811 |
|
|
Duplicate_Unit : Boolean := False;
|
812 |
|
|
-- True when a duplicate unit has been reported for this source
|
813 |
|
|
|
814 |
|
|
Next_In_Lang : Source_Id := No_Source;
|
815 |
|
|
-- Link to another source of the same language in the same project
|
816 |
|
|
|
817 |
|
|
Next_With_File_Name : Source_Id := No_Source;
|
818 |
|
|
-- Link to another source with the same base file name
|
819 |
|
|
|
820 |
|
|
Roots : Roots_Access := null;
|
821 |
|
|
-- The roots for a main unit
|
822 |
|
|
|
823 |
|
|
end record;
|
824 |
|
|
|
825 |
|
|
No_Source_Data : constant Source_Data :=
|
826 |
|
|
(Initialized => False,
|
827 |
|
|
Project => No_Project,
|
828 |
|
|
Location => No_Location,
|
829 |
|
|
Source_Dir_Rank => 0,
|
830 |
|
|
Language => No_Language_Index,
|
831 |
|
|
In_Interfaces => True,
|
832 |
|
|
Declared_In_Interfaces => False,
|
833 |
|
|
Alternate_Languages => null,
|
834 |
|
|
Kind => Spec,
|
835 |
|
|
Unit => No_Unit_Index,
|
836 |
|
|
Index => 0,
|
837 |
|
|
Locally_Removed => False,
|
838 |
|
|
Compilable => Unknown,
|
839 |
|
|
In_The_Queue => False,
|
840 |
|
|
Replaced_By => No_Source,
|
841 |
|
|
File => No_File,
|
842 |
|
|
Display_File => No_File,
|
843 |
|
|
Path => No_Path_Information,
|
844 |
|
|
Source_TS => Empty_Time_Stamp,
|
845 |
|
|
Object_Project => No_Project,
|
846 |
|
|
Object => No_File,
|
847 |
|
|
Current_Object_Path => No_Path,
|
848 |
|
|
Object_Path => No_Path,
|
849 |
|
|
Object_TS => Empty_Time_Stamp,
|
850 |
|
|
Dep_Name => No_File,
|
851 |
|
|
Current_Dep_Path => No_Path,
|
852 |
|
|
Dep_Path => No_Path,
|
853 |
|
|
Dep_TS => Osint.Unknown_Attributes,
|
854 |
|
|
Switches => No_File,
|
855 |
|
|
Switches_Path => No_Path,
|
856 |
|
|
Switches_TS => Empty_Time_Stamp,
|
857 |
|
|
Naming_Exception => No,
|
858 |
|
|
Duplicate_Unit => False,
|
859 |
|
|
Next_In_Lang => No_Source,
|
860 |
|
|
Next_With_File_Name => No_Source,
|
861 |
|
|
Roots => null);
|
862 |
|
|
|
863 |
|
|
package Source_Files_Htable is new Simple_HTable
|
864 |
|
|
(Header_Num => Header_Num,
|
865 |
|
|
Element => Source_Id,
|
866 |
|
|
No_Element => No_Source,
|
867 |
|
|
Key => File_Name_Type,
|
868 |
|
|
Hash => Hash,
|
869 |
|
|
Equal => "=");
|
870 |
|
|
-- Mapping of source file names to source ids
|
871 |
|
|
|
872 |
|
|
package Source_Paths_Htable is new Simple_HTable
|
873 |
|
|
(Header_Num => Header_Num,
|
874 |
|
|
Element => Source_Id,
|
875 |
|
|
No_Element => No_Source,
|
876 |
|
|
Key => Path_Name_Type,
|
877 |
|
|
Hash => Hash,
|
878 |
|
|
Equal => "=");
|
879 |
|
|
-- Mapping of source paths to source ids
|
880 |
|
|
|
881 |
|
|
type Lib_Kind is (Static, Dynamic, Relocatable);
|
882 |
|
|
|
883 |
|
|
type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
|
884 |
|
|
-- Type to specify the symbol policy, when symbol control is supported.
|
885 |
|
|
-- See full explanation about this type in package Symbols.
|
886 |
|
|
-- Autonomous: Create a symbol file without considering any reference
|
887 |
|
|
-- Compliant: Try to be as compatible as possible with an existing ref
|
888 |
|
|
-- Controlled: Fail if symbols are not the same as those in the reference
|
889 |
|
|
-- Restricted: Restrict the symbols to those in the symbol file
|
890 |
|
|
-- Direct: The symbol file is used as is
|
891 |
|
|
|
892 |
|
|
type Symbol_Record is record
|
893 |
|
|
Symbol_File : Path_Name_Type := No_Path;
|
894 |
|
|
Reference : Path_Name_Type := No_Path;
|
895 |
|
|
Symbol_Policy : Policy := Autonomous;
|
896 |
|
|
end record;
|
897 |
|
|
-- Type to keep the symbol data to be used when building a shared library
|
898 |
|
|
|
899 |
|
|
No_Symbols : constant Symbol_Record :=
|
900 |
|
|
(Symbol_File => No_Path,
|
901 |
|
|
Reference => No_Path,
|
902 |
|
|
Symbol_Policy => Autonomous);
|
903 |
|
|
-- The default value of the symbol data
|
904 |
|
|
|
905 |
|
|
function Image (The_Casing : Casing_Type) return String;
|
906 |
|
|
-- Similar to 'Image (but avoid use of this attribute in compiler)
|
907 |
|
|
|
908 |
|
|
function Value (Image : String) return Casing_Type;
|
909 |
|
|
-- Similar to 'Value (but avoid use of this attribute in compiler)
|
910 |
|
|
-- Raises Constraint_Error if not a Casing_Type image.
|
911 |
|
|
|
912 |
|
|
-- The following record contains data for a naming scheme
|
913 |
|
|
|
914 |
|
|
function Get_Object_Directory
|
915 |
|
|
(Project : Project_Id;
|
916 |
|
|
Including_Libraries : Boolean;
|
917 |
|
|
Only_If_Ada : Boolean := False) return Path_Name_Type;
|
918 |
|
|
-- Return the object directory to use for the project. This depends on
|
919 |
|
|
-- whether we have a library project or a standard project. This function
|
920 |
|
|
-- might return No_Name when no directory applies.
|
921 |
|
|
-- If we have a library project file and Including_Libraries is True then
|
922 |
|
|
-- the library dir is returned instead of the object dir.
|
923 |
|
|
-- If Only_If_Ada is True, then No_Name will be returned when the project
|
924 |
|
|
-- doesn't Ada sources.
|
925 |
|
|
|
926 |
|
|
procedure Compute_All_Imported_Projects
|
927 |
|
|
(Root_Project : Project_Id;
|
928 |
|
|
Tree : Project_Tree_Ref);
|
929 |
|
|
-- For all projects in the tree, compute the list of the projects imported
|
930 |
|
|
-- directly or indirectly by project Root_Project. The result is stored in
|
931 |
|
|
-- Project.All_Imported_Projects for each project
|
932 |
|
|
|
933 |
|
|
function Ultimate_Extending_Project_Of
|
934 |
|
|
(Proj : Project_Id) return Project_Id;
|
935 |
|
|
-- Returns the ultimate extending project of project Proj. If project Proj
|
936 |
|
|
-- is not extended, returns Proj.
|
937 |
|
|
|
938 |
|
|
type Project_List_Element;
|
939 |
|
|
type Project_List is access all Project_List_Element;
|
940 |
|
|
type Project_List_Element is record
|
941 |
|
|
Project : Project_Id := No_Project;
|
942 |
|
|
From_Encapsulated_Lib : Boolean := False;
|
943 |
|
|
Next : Project_List := null;
|
944 |
|
|
end record;
|
945 |
|
|
-- A list of projects
|
946 |
|
|
|
947 |
|
|
procedure Free_List
|
948 |
|
|
(List : in out Project_List;
|
949 |
|
|
Free_Project : Boolean);
|
950 |
|
|
-- Free the list of projects, if Free_Project, each project is also freed
|
951 |
|
|
|
952 |
|
|
type Response_File_Format is
|
953 |
|
|
(None,
|
954 |
|
|
GNU,
|
955 |
|
|
Object_List,
|
956 |
|
|
Option_List,
|
957 |
|
|
GCC,
|
958 |
|
|
GCC_GNU,
|
959 |
|
|
GCC_Object_List,
|
960 |
|
|
GCC_Option_List);
|
961 |
|
|
-- The format of the different response files
|
962 |
|
|
|
963 |
|
|
type Project_Configuration is record
|
964 |
|
|
Target : Name_Id := No_Name;
|
965 |
|
|
-- The target of the configuration, when specified
|
966 |
|
|
|
967 |
|
|
Run_Path_Option : Name_List_Index := No_Name_List;
|
968 |
|
|
-- The option to use when linking to specify the path where to look for
|
969 |
|
|
-- libraries.
|
970 |
|
|
|
971 |
|
|
Run_Path_Origin : Name_Id := No_Name;
|
972 |
|
|
-- Specify the string (such as "$ORIGIN") to indicate paths relative to
|
973 |
|
|
-- the directory of the executable in the run path option.
|
974 |
|
|
|
975 |
|
|
Library_Install_Name_Option : Name_Id := No_Name;
|
976 |
|
|
-- When this is not an empty list, this option, followed by the single
|
977 |
|
|
-- name of the shared library file is used when linking a shared
|
978 |
|
|
-- library.
|
979 |
|
|
|
980 |
|
|
Separate_Run_Path_Options : Boolean := False;
|
981 |
|
|
-- True if each directory needs to be specified in a separate run path
|
982 |
|
|
-- option.
|
983 |
|
|
|
984 |
|
|
Executable_Suffix : Name_Id := No_Name;
|
985 |
|
|
-- The suffix of executables, when specified in the configuration or in
|
986 |
|
|
-- package Builder of the main project. When this is not specified, the
|
987 |
|
|
-- executable suffix is the default for the platform.
|
988 |
|
|
|
989 |
|
|
-- Linking
|
990 |
|
|
|
991 |
|
|
Linker : Path_Name_Type := No_Path;
|
992 |
|
|
-- Path name of the linker driver. Specified in the configuration or in
|
993 |
|
|
-- the package Builder of the main project.
|
994 |
|
|
|
995 |
|
|
Map_File_Option : Name_Id := No_Name;
|
996 |
|
|
-- Option to use when invoking the linker to build a map file
|
997 |
|
|
|
998 |
|
|
Trailing_Linker_Required_Switches : Name_List_Index := No_Name_List;
|
999 |
|
|
-- The minimum options for the linker driver. Specified in the
|
1000 |
|
|
-- configuration.
|
1001 |
|
|
|
1002 |
|
|
Linker_Executable_Option : Name_List_Index := No_Name_List;
|
1003 |
|
|
-- The option(s) to indicate the name of the executable in the linker
|
1004 |
|
|
-- command. Specified in the configuration. When not specified, default
|
1005 |
|
|
-- to -o <executable name>.
|
1006 |
|
|
|
1007 |
|
|
Linker_Lib_Dir_Option : Name_Id := No_Name;
|
1008 |
|
|
-- The option to specify where to find a library for linking. Specified
|
1009 |
|
|
-- in the configuration. When not specified, defaults to "-L".
|
1010 |
|
|
|
1011 |
|
|
Linker_Lib_Name_Option : Name_Id := No_Name;
|
1012 |
|
|
-- The option to specify the name of a library for linking. Specified in
|
1013 |
|
|
-- the configuration. When not specified, defaults to "-l".
|
1014 |
|
|
|
1015 |
|
|
Max_Command_Line_Length : Natural := 0;
|
1016 |
|
|
-- When positive and when Resp_File_Format (see below) is not None,
|
1017 |
|
|
-- if the command line for the invocation of the linker would be greater
|
1018 |
|
|
-- than this value, a response file is used to invoke the linker.
|
1019 |
|
|
|
1020 |
|
|
Resp_File_Format : Response_File_Format := None;
|
1021 |
|
|
-- The format of a response file, when linking with a response file is
|
1022 |
|
|
-- supported.
|
1023 |
|
|
|
1024 |
|
|
Resp_File_Options : Name_List_Index := No_Name_List;
|
1025 |
|
|
-- The switches, if any, that precede the path name of the response
|
1026 |
|
|
-- file in the invocation of the linker.
|
1027 |
|
|
|
1028 |
|
|
-- Libraries
|
1029 |
|
|
|
1030 |
|
|
Library_Builder : Path_Name_Type := No_Path;
|
1031 |
|
|
-- The executable to build library (specified in the configuration)
|
1032 |
|
|
|
1033 |
|
|
Lib_Support : Library_Support := None;
|
1034 |
|
|
-- The level of library support. Specified in the configuration. Support
|
1035 |
|
|
-- is none, static libraries only or both static and shared libraries.
|
1036 |
|
|
|
1037 |
|
|
Lib_Encapsulated_Supported : Boolean := False;
|
1038 |
|
|
-- True when building fully standalone libraries supported on the target
|
1039 |
|
|
|
1040 |
|
|
Archive_Builder : Name_List_Index := No_Name_List;
|
1041 |
|
|
-- The name of the executable to build archives, with the minimum
|
1042 |
|
|
-- switches. Specified in the configuration.
|
1043 |
|
|
|
1044 |
|
|
Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
|
1045 |
|
|
-- The options to append object files to an archive
|
1046 |
|
|
|
1047 |
|
|
Archive_Indexer : Name_List_Index := No_Name_List;
|
1048 |
|
|
-- The name of the executable to index archives, with the minimum
|
1049 |
|
|
-- switches. Specified in the configuration.
|
1050 |
|
|
|
1051 |
|
|
Archive_Suffix : File_Name_Type := No_File;
|
1052 |
|
|
-- The suffix of archives. Specified in the configuration. When not
|
1053 |
|
|
-- specified, defaults to ".a".
|
1054 |
|
|
|
1055 |
|
|
Lib_Partial_Linker : Name_List_Index := No_Name_List;
|
1056 |
|
|
|
1057 |
|
|
-- Shared libraries
|
1058 |
|
|
|
1059 |
|
|
Shared_Lib_Driver : File_Name_Type := No_File;
|
1060 |
|
|
-- The driver to link shared libraries. Set with attribute Library_GCC.
|
1061 |
|
|
-- Default to gcc.
|
1062 |
|
|
|
1063 |
|
|
Shared_Lib_Prefix : File_Name_Type := No_File;
|
1064 |
|
|
-- Part of a shared library file name that precedes the name of the
|
1065 |
|
|
-- library. Specified in the configuration. When not specified, defaults
|
1066 |
|
|
-- to "lib".
|
1067 |
|
|
|
1068 |
|
|
Shared_Lib_Suffix : File_Name_Type := No_File;
|
1069 |
|
|
-- Suffix of shared libraries, after the library name in the shared
|
1070 |
|
|
-- library name. Specified in the configuration. When not specified,
|
1071 |
|
|
-- default to ".so".
|
1072 |
|
|
|
1073 |
|
|
Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
|
1074 |
|
|
-- The minimum options to use when building a shared library
|
1075 |
|
|
|
1076 |
|
|
Lib_Version_Options : Name_List_Index := No_Name_List;
|
1077 |
|
|
-- The options to use to specify a library version
|
1078 |
|
|
|
1079 |
|
|
Symbolic_Link_Supported : Boolean := False;
|
1080 |
|
|
-- True if the platform supports symbolic link files
|
1081 |
|
|
|
1082 |
|
|
Lib_Maj_Min_Id_Supported : Boolean := False;
|
1083 |
|
|
-- True if platform supports library major and minor options, such as
|
1084 |
|
|
-- libname.so -> libname.so.2 -> libname.so.2.4
|
1085 |
|
|
|
1086 |
|
|
Auto_Init_Supported : Boolean := False;
|
1087 |
|
|
-- True if automatic initialisation is supported for shared stand-alone
|
1088 |
|
|
-- libraries.
|
1089 |
|
|
end record;
|
1090 |
|
|
|
1091 |
|
|
Default_Project_Config : constant Project_Configuration :=
|
1092 |
|
|
(Target => No_Name,
|
1093 |
|
|
Run_Path_Option => No_Name_List,
|
1094 |
|
|
Run_Path_Origin => No_Name,
|
1095 |
|
|
Library_Install_Name_Option => No_Name,
|
1096 |
|
|
Separate_Run_Path_Options => False,
|
1097 |
|
|
Executable_Suffix => No_Name,
|
1098 |
|
|
Linker => No_Path,
|
1099 |
|
|
Map_File_Option => No_Name,
|
1100 |
|
|
Trailing_Linker_Required_Switches =>
|
1101 |
|
|
No_Name_List,
|
1102 |
|
|
Linker_Executable_Option => No_Name_List,
|
1103 |
|
|
Linker_Lib_Dir_Option => No_Name,
|
1104 |
|
|
Linker_Lib_Name_Option => No_Name,
|
1105 |
|
|
Library_Builder => No_Path,
|
1106 |
|
|
Max_Command_Line_Length => 0,
|
1107 |
|
|
Resp_File_Format => None,
|
1108 |
|
|
Resp_File_Options => No_Name_List,
|
1109 |
|
|
Lib_Support => None,
|
1110 |
|
|
Lib_Encapsulated_Supported => False,
|
1111 |
|
|
Archive_Builder => No_Name_List,
|
1112 |
|
|
Archive_Builder_Append_Option => No_Name_List,
|
1113 |
|
|
Archive_Indexer => No_Name_List,
|
1114 |
|
|
Archive_Suffix => No_File,
|
1115 |
|
|
Lib_Partial_Linker => No_Name_List,
|
1116 |
|
|
Shared_Lib_Driver => No_File,
|
1117 |
|
|
Shared_Lib_Prefix => No_File,
|
1118 |
|
|
Shared_Lib_Suffix => No_File,
|
1119 |
|
|
Shared_Lib_Min_Options => No_Name_List,
|
1120 |
|
|
Lib_Version_Options => No_Name_List,
|
1121 |
|
|
Symbolic_Link_Supported => False,
|
1122 |
|
|
Lib_Maj_Min_Id_Supported => False,
|
1123 |
|
|
Auto_Init_Supported => False);
|
1124 |
|
|
|
1125 |
|
|
-------------------------
|
1126 |
|
|
-- Aggregated projects --
|
1127 |
|
|
-------------------------
|
1128 |
|
|
|
1129 |
|
|
type Aggregated_Project;
|
1130 |
|
|
type Aggregated_Project_List is access all Aggregated_Project;
|
1131 |
|
|
type Aggregated_Project is record
|
1132 |
|
|
Path : Path_Name_Type;
|
1133 |
|
|
Tree : Project_Tree_Ref;
|
1134 |
|
|
Project : Project_Id;
|
1135 |
|
|
Next : Aggregated_Project_List;
|
1136 |
|
|
end record;
|
1137 |
|
|
|
1138 |
|
|
procedure Free (List : in out Aggregated_Project_List);
|
1139 |
|
|
-- Free the memory used for List
|
1140 |
|
|
|
1141 |
|
|
procedure Add_Aggregated_Project
|
1142 |
|
|
(Project : Project_Id;
|
1143 |
|
|
Path : Path_Name_Type);
|
1144 |
|
|
-- Add a new aggregated project in Project.
|
1145 |
|
|
-- The aggregated project has not been processed yet. This procedure should
|
1146 |
|
|
-- the called while processing the aggregate project, and as a result
|
1147 |
|
|
-- Prj.Proc.Process will then automatically process the aggregated projects
|
1148 |
|
|
|
1149 |
|
|
------------------
|
1150 |
|
|
-- Project_Data --
|
1151 |
|
|
------------------
|
1152 |
|
|
|
1153 |
|
|
-- The following record describes a project file representation
|
1154 |
|
|
|
1155 |
|
|
type Standalone is (No, Standard, Encapsulated);
|
1156 |
|
|
|
1157 |
|
|
type Project_Data (Qualifier : Project_Qualifier := Unspecified) is record
|
1158 |
|
|
|
1159 |
|
|
-------------
|
1160 |
|
|
-- General --
|
1161 |
|
|
-------------
|
1162 |
|
|
|
1163 |
|
|
Name : Name_Id := No_Name;
|
1164 |
|
|
-- The name of the project
|
1165 |
|
|
|
1166 |
|
|
Display_Name : Name_Id := No_Name;
|
1167 |
|
|
-- The name of the project with the spelling of its declaration
|
1168 |
|
|
|
1169 |
|
|
Externally_Built : Boolean := False;
|
1170 |
|
|
-- True if the project is externally built. In such case, the Project
|
1171 |
|
|
-- Manager will not modify anything in this project.
|
1172 |
|
|
|
1173 |
|
|
Config : Project_Configuration;
|
1174 |
|
|
|
1175 |
|
|
Path : Path_Information := No_Path_Information;
|
1176 |
|
|
-- The path name of the project file. This include base name of the
|
1177 |
|
|
-- project file.
|
1178 |
|
|
|
1179 |
|
|
Virtual : Boolean := False;
|
1180 |
|
|
-- True for virtual extending projects
|
1181 |
|
|
|
1182 |
|
|
Location : Source_Ptr := No_Location;
|
1183 |
|
|
-- The location in the project file source of the project name that
|
1184 |
|
|
-- immediately follows the reserved word "project".
|
1185 |
|
|
|
1186 |
|
|
---------------
|
1187 |
|
|
-- Languages --
|
1188 |
|
|
---------------
|
1189 |
|
|
|
1190 |
|
|
Languages : Language_Ptr := No_Language_Index;
|
1191 |
|
|
-- First index of the language data in the project.
|
1192 |
|
|
-- This is an index into the project_tree_data.languages_data.
|
1193 |
|
|
-- Traversing the list gives access to all the languages supported by
|
1194 |
|
|
-- the project.
|
1195 |
|
|
|
1196 |
|
|
--------------
|
1197 |
|
|
-- Projects --
|
1198 |
|
|
--------------
|
1199 |
|
|
|
1200 |
|
|
Mains : String_List_Id := Nil_String;
|
1201 |
|
|
-- List of mains specified by attribute Main
|
1202 |
|
|
|
1203 |
|
|
Extends : Project_Id := No_Project;
|
1204 |
|
|
-- The reference of the project file, if any, that this project file
|
1205 |
|
|
-- extends.
|
1206 |
|
|
|
1207 |
|
|
Extended_By : Project_Id := No_Project;
|
1208 |
|
|
-- The reference of the project file, if any, that extends this project
|
1209 |
|
|
-- file.
|
1210 |
|
|
|
1211 |
|
|
Decl : Declarations := No_Declarations;
|
1212 |
|
|
-- The declarations (variables, attributes and packages) of this project
|
1213 |
|
|
-- file.
|
1214 |
|
|
|
1215 |
|
|
Imported_Projects : Project_List := null;
|
1216 |
|
|
-- The list of all directly imported projects, if any
|
1217 |
|
|
|
1218 |
|
|
All_Imported_Projects : Project_List := null;
|
1219 |
|
|
-- The list of all projects imported directly or indirectly, if any.
|
1220 |
|
|
-- This does not include the project itself.
|
1221 |
|
|
|
1222 |
|
|
-----------------
|
1223 |
|
|
-- Directories --
|
1224 |
|
|
-----------------
|
1225 |
|
|
|
1226 |
|
|
Directory : Path_Information := No_Path_Information;
|
1227 |
|
|
-- Path name of the directory where the project file resides
|
1228 |
|
|
|
1229 |
|
|
Object_Directory : Path_Information := No_Path_Information;
|
1230 |
|
|
-- The path name of the object directory of this project file
|
1231 |
|
|
|
1232 |
|
|
Exec_Directory : Path_Information := No_Path_Information;
|
1233 |
|
|
-- The path name of the exec directory of this project file. Default is
|
1234 |
|
|
-- equal to Object_Directory.
|
1235 |
|
|
|
1236 |
|
|
-------------
|
1237 |
|
|
-- Library --
|
1238 |
|
|
-------------
|
1239 |
|
|
|
1240 |
|
|
Library : Boolean := False;
|
1241 |
|
|
-- True if this is a library project
|
1242 |
|
|
|
1243 |
|
|
Library_Name : Name_Id := No_Name;
|
1244 |
|
|
-- If a library project, name of the library
|
1245 |
|
|
|
1246 |
|
|
Library_Kind : Lib_Kind := Static;
|
1247 |
|
|
-- If a library project, kind of library
|
1248 |
|
|
|
1249 |
|
|
Library_Dir : Path_Information := No_Path_Information;
|
1250 |
|
|
-- If a library project, path name of the directory where the library
|
1251 |
|
|
-- resides.
|
1252 |
|
|
|
1253 |
|
|
Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
|
1254 |
|
|
-- The timestamp of a library file in a library project
|
1255 |
|
|
|
1256 |
|
|
Library_Src_Dir : Path_Information := No_Path_Information;
|
1257 |
|
|
-- If a Stand-Alone Library project, path name of the directory where
|
1258 |
|
|
-- the sources of the interfaces of the library are copied. By default,
|
1259 |
|
|
-- if attribute Library_Src_Dir is not specified, sources of the
|
1260 |
|
|
-- interfaces are not copied anywhere.
|
1261 |
|
|
|
1262 |
|
|
Library_ALI_Dir : Path_Information := No_Path_Information;
|
1263 |
|
|
-- In a library project, path name of the directory where the ALI files
|
1264 |
|
|
-- are copied. If attribute Library_ALI_Dir is not specified, ALI files
|
1265 |
|
|
-- are copied in the Library_Dir.
|
1266 |
|
|
|
1267 |
|
|
Lib_Internal_Name : Name_Id := No_Name;
|
1268 |
|
|
-- If a library project, internal name store inside the library
|
1269 |
|
|
|
1270 |
|
|
Standalone_Library : Standalone := No;
|
1271 |
|
|
-- Indicate that this is a Standalone Library Project File
|
1272 |
|
|
|
1273 |
|
|
Lib_Interface_ALIs : String_List_Id := Nil_String;
|
1274 |
|
|
-- For Standalone Library Project Files, indicate the list of Interface
|
1275 |
|
|
-- ALI files.
|
1276 |
|
|
|
1277 |
|
|
Lib_Auto_Init : Boolean := False;
|
1278 |
|
|
-- For non static Stand-Alone Library Project Files, indicate if
|
1279 |
|
|
-- the library initialisation should be automatic.
|
1280 |
|
|
|
1281 |
|
|
Symbol_Data : Symbol_Record := No_Symbols;
|
1282 |
|
|
-- Symbol file name, reference symbol file name, symbol policy
|
1283 |
|
|
|
1284 |
|
|
Need_To_Build_Lib : Boolean := False;
|
1285 |
|
|
-- Indicates that the library of a Library Project needs to be built or
|
1286 |
|
|
-- rebuilt.
|
1287 |
|
|
|
1288 |
|
|
-------------
|
1289 |
|
|
-- Sources --
|
1290 |
|
|
-------------
|
1291 |
|
|
-- The sources for all languages including Ada are accessible through
|
1292 |
|
|
-- the Source_Iterator type
|
1293 |
|
|
|
1294 |
|
|
Interfaces_Defined : Boolean := False;
|
1295 |
|
|
-- True if attribute Interfaces is declared for the project or any
|
1296 |
|
|
-- project it extends.
|
1297 |
|
|
|
1298 |
|
|
Include_Path_File : Path_Name_Type := No_Path;
|
1299 |
|
|
-- The path name of the of the source search directory file.
|
1300 |
|
|
-- This is only used by gnatmake
|
1301 |
|
|
|
1302 |
|
|
Source_Dirs : String_List_Id := Nil_String;
|
1303 |
|
|
-- The list of all the source directories
|
1304 |
|
|
|
1305 |
|
|
Source_Dir_Ranks : Number_List_Index := No_Number_List;
|
1306 |
|
|
|
1307 |
|
|
Ada_Include_Path : String_Access := null;
|
1308 |
|
|
-- The cached value of source search path for this project file. Set by
|
1309 |
|
|
-- the first call to Prj.Env.Ada_Include_Path for the project. Do not
|
1310 |
|
|
-- use this field directly outside of the project manager, use
|
1311 |
|
|
-- Prj.Env.Ada_Include_Path instead.
|
1312 |
|
|
|
1313 |
|
|
Has_Multi_Unit_Sources : Boolean := False;
|
1314 |
|
|
-- Whether there is at least one source file containing multiple units
|
1315 |
|
|
|
1316 |
|
|
-------------------
|
1317 |
|
|
-- Miscellaneous --
|
1318 |
|
|
-------------------
|
1319 |
|
|
|
1320 |
|
|
Ada_Objects_Path : String_Access := null;
|
1321 |
|
|
-- The cached value of ADA_OBJECTS_PATH for this project file. Do not
|
1322 |
|
|
-- use this field directly outside of the compiler, use
|
1323 |
|
|
-- Prj.Env.Ada_Objects_Path instead.
|
1324 |
|
|
|
1325 |
|
|
Libgnarl_Needed : Yes_No_Unknown := Unknown;
|
1326 |
|
|
-- Set to True when libgnarl is needed to link
|
1327 |
|
|
|
1328 |
|
|
Objects_Path : String_Access := null;
|
1329 |
|
|
-- The cached value of the object dir path, used during the binding
|
1330 |
|
|
-- phase of gprbuild.
|
1331 |
|
|
|
1332 |
|
|
Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
|
1333 |
|
|
-- The cached value of the object path temp file (including library
|
1334 |
|
|
-- dirs) for this project file.
|
1335 |
|
|
|
1336 |
|
|
Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
|
1337 |
|
|
-- The cached value of the object path temp file (excluding library
|
1338 |
|
|
-- dirs) for this project file.
|
1339 |
|
|
|
1340 |
|
|
Config_File_Name : Path_Name_Type := No_Path;
|
1341 |
|
|
-- The path name of the configuration pragmas file, if any
|
1342 |
|
|
|
1343 |
|
|
Config_File_Temp : Boolean := False;
|
1344 |
|
|
-- An indication that the configuration pragmas file is a temporary file
|
1345 |
|
|
-- that must be deleted at the end.
|
1346 |
|
|
|
1347 |
|
|
Config_Checked : Boolean := False;
|
1348 |
|
|
-- A flag to avoid checking repetitively the configuration pragmas file
|
1349 |
|
|
|
1350 |
|
|
Depth : Natural := 0;
|
1351 |
|
|
-- The maximum depth of a project in the project graph. Depth of main
|
1352 |
|
|
-- project is 0.
|
1353 |
|
|
|
1354 |
|
|
Unkept_Comments : Boolean := False;
|
1355 |
|
|
-- True if there are comments in the project sources that cannot be kept
|
1356 |
|
|
-- in the project tree.
|
1357 |
|
|
|
1358 |
|
|
-----------------------------
|
1359 |
|
|
-- Qualifier-Specific data --
|
1360 |
|
|
-----------------------------
|
1361 |
|
|
|
1362 |
|
|
-- The following fields are only valid for specific types of projects
|
1363 |
|
|
|
1364 |
|
|
case Qualifier is
|
1365 |
|
|
when Aggregate | Aggregate_Library =>
|
1366 |
|
|
Aggregated_Projects : Aggregated_Project_List := null;
|
1367 |
|
|
-- List of aggregated projects (which could themselves be
|
1368 |
|
|
-- aggregate projects).
|
1369 |
|
|
|
1370 |
|
|
when others =>
|
1371 |
|
|
null;
|
1372 |
|
|
end case;
|
1373 |
|
|
end record;
|
1374 |
|
|
|
1375 |
|
|
function Empty_Project (Qualifier : Project_Qualifier) return Project_Data;
|
1376 |
|
|
-- Return the representation of an empty project
|
1377 |
|
|
|
1378 |
|
|
function Is_Extending
|
1379 |
|
|
(Extending : Project_Id;
|
1380 |
|
|
Extended : Project_Id) return Boolean;
|
1381 |
|
|
-- Return True if Extending is extending the Extended project
|
1382 |
|
|
|
1383 |
|
|
function Is_Ext
|
1384 |
|
|
(Extending : Project_Id;
|
1385 |
|
|
Extended : Project_Id) return Boolean renames Is_Extending;
|
1386 |
|
|
|
1387 |
|
|
function Has_Ada_Sources (Data : Project_Id) return Boolean;
|
1388 |
|
|
-- Return True if the project has Ada sources
|
1389 |
|
|
|
1390 |
|
|
Project_Error : exception;
|
1391 |
|
|
-- Raised by some subprograms in Prj.Attr
|
1392 |
|
|
|
1393 |
|
|
package Units_Htable is new Simple_HTable
|
1394 |
|
|
(Header_Num => Header_Num,
|
1395 |
|
|
Element => Unit_Index,
|
1396 |
|
|
No_Element => No_Unit_Index,
|
1397 |
|
|
Key => Name_Id,
|
1398 |
|
|
Hash => Hash,
|
1399 |
|
|
Equal => "=");
|
1400 |
|
|
-- Mapping of unit names to indexes in the Units table
|
1401 |
|
|
|
1402 |
|
|
---------------------
|
1403 |
|
|
-- Source_Iterator --
|
1404 |
|
|
---------------------
|
1405 |
|
|
|
1406 |
|
|
type Source_Iterator is private;
|
1407 |
|
|
|
1408 |
|
|
function For_Each_Source
|
1409 |
|
|
(In_Tree : Project_Tree_Ref;
|
1410 |
|
|
Project : Project_Id := No_Project;
|
1411 |
|
|
Language : Name_Id := No_Name;
|
1412 |
|
|
Encapsulated_Libs : Boolean := True) return Source_Iterator;
|
1413 |
|
|
-- Returns an iterator for all the sources of a project tree, or a specific
|
1414 |
|
|
-- project, or a specific language. Include sources from aggregated libs if
|
1415 |
|
|
-- Aggregated_Libs is True.
|
1416 |
|
|
|
1417 |
|
|
function Element (Iter : Source_Iterator) return Source_Id;
|
1418 |
|
|
-- Return the current source (or No_Source if there are no more sources)
|
1419 |
|
|
|
1420 |
|
|
procedure Next (Iter : in out Source_Iterator);
|
1421 |
|
|
-- Move on to the next source
|
1422 |
|
|
|
1423 |
|
|
function Find_Source
|
1424 |
|
|
(In_Tree : Project_Tree_Ref;
|
1425 |
|
|
Project : Project_Id;
|
1426 |
|
|
In_Imported_Only : Boolean := False;
|
1427 |
|
|
In_Extended_Only : Boolean := False;
|
1428 |
|
|
Base_Name : File_Name_Type;
|
1429 |
|
|
Index : Int := 0) return Source_Id;
|
1430 |
|
|
-- Find the first source file with the given name.
|
1431 |
|
|
-- If In_Extended_Only is True, it will search in project and the project
|
1432 |
|
|
-- it extends, but not in the imported projects.
|
1433 |
|
|
-- Elsif In_Imported_Only is True, it will search in project and the
|
1434 |
|
|
-- projects it imports, but not in the others or in aggregated projects.
|
1435 |
|
|
-- Else it searches in the whole tree.
|
1436 |
|
|
-- If Index is specified, this only search for a source with that index.
|
1437 |
|
|
|
1438 |
|
|
-----------------------
|
1439 |
|
|
-- Project_Tree_Data --
|
1440 |
|
|
-----------------------
|
1441 |
|
|
|
1442 |
|
|
package Replaced_Source_HTable is new Simple_HTable
|
1443 |
|
|
(Header_Num => Header_Num,
|
1444 |
|
|
Element => File_Name_Type,
|
1445 |
|
|
No_Element => No_File,
|
1446 |
|
|
Key => File_Name_Type,
|
1447 |
|
|
Hash => Hash,
|
1448 |
|
|
Equal => "=");
|
1449 |
|
|
|
1450 |
|
|
type Private_Project_Tree_Data is private;
|
1451 |
|
|
-- Data for a project tree that is used only by the Project Manager
|
1452 |
|
|
|
1453 |
|
|
type Shared_Project_Tree_Data is record
|
1454 |
|
|
Name_Lists : Name_List_Table.Instance;
|
1455 |
|
|
Number_Lists : Number_List_Table.Instance;
|
1456 |
|
|
String_Elements : String_Element_Table.Instance;
|
1457 |
|
|
Variable_Elements : Variable_Element_Table.Instance;
|
1458 |
|
|
Array_Elements : Array_Element_Table.Instance;
|
1459 |
|
|
Arrays : Array_Table.Instance;
|
1460 |
|
|
Packages : Package_Table.Instance;
|
1461 |
|
|
Private_Part : Private_Project_Tree_Data;
|
1462 |
|
|
end record;
|
1463 |
|
|
type Shared_Project_Tree_Data_Access is access all Shared_Project_Tree_Data;
|
1464 |
|
|
-- The data that is shared among multiple trees, when these trees are
|
1465 |
|
|
-- loaded through the same aggregate project.
|
1466 |
|
|
-- To avoid ambiguities, limit the number of parameters to the
|
1467 |
|
|
-- subprograms (we would have to parse the "root project tree" since this
|
1468 |
|
|
-- is where the configuration file was loaded, in addition to the project's
|
1469 |
|
|
-- own tree) and make the comparison of projects easier, all trees store
|
1470 |
|
|
-- the lists in the same tables.
|
1471 |
|
|
|
1472 |
|
|
type Project_Tree_Appdata is tagged null record;
|
1473 |
|
|
type Project_Tree_Appdata_Access is access all Project_Tree_Appdata'Class;
|
1474 |
|
|
-- Application-specific data that can be associated with a project tree.
|
1475 |
|
|
-- We do not make the Project_Tree_Data itself tagged for several reasons:
|
1476 |
|
|
-- - it couldn't have a default value for its discriminant
|
1477 |
|
|
-- - it would require a "factory" to allocate such data, because trees
|
1478 |
|
|
-- are created automatically when parsing aggregate projects.
|
1479 |
|
|
|
1480 |
|
|
procedure Free (Tree : in out Project_Tree_Appdata);
|
1481 |
|
|
-- Should be overridden if your derive your own data
|
1482 |
|
|
|
1483 |
|
|
type Project_Tree_Data (Is_Root_Tree : Boolean := True) is record
|
1484 |
|
|
-- The root tree is the one loaded by the user from the command line.
|
1485 |
|
|
-- Is_Root_Tree is only false for projects aggregated within a root
|
1486 |
|
|
-- aggregate project.
|
1487 |
|
|
|
1488 |
|
|
Projects : Project_List;
|
1489 |
|
|
-- List of projects in this tree
|
1490 |
|
|
|
1491 |
|
|
Replaced_Sources : Replaced_Source_HTable.Instance;
|
1492 |
|
|
-- The list of sources that have been replaced by sources with
|
1493 |
|
|
-- different file names.
|
1494 |
|
|
|
1495 |
|
|
Replaced_Source_Number : Natural := 0;
|
1496 |
|
|
-- The number of entries in Replaced_Sources
|
1497 |
|
|
|
1498 |
|
|
Units_HT : Units_Htable.Instance;
|
1499 |
|
|
-- Unit name to Unit_Index (and from there to Source_Id)
|
1500 |
|
|
|
1501 |
|
|
Source_Files_HT : Source_Files_Htable.Instance;
|
1502 |
|
|
-- Base source file names to Source_Id list
|
1503 |
|
|
|
1504 |
|
|
Source_Paths_HT : Source_Paths_Htable.Instance;
|
1505 |
|
|
-- Full path to Source_Id
|
1506 |
|
|
-- ??? What is behavior for multi-unit source files, where there are
|
1507 |
|
|
-- several source_id per file ?
|
1508 |
|
|
|
1509 |
|
|
Source_Info_File_Name : String_Access := null;
|
1510 |
|
|
-- The name of the source info file, if specified by the builder
|
1511 |
|
|
|
1512 |
|
|
Source_Info_File_Exists : Boolean := False;
|
1513 |
|
|
-- True when a source info file has been successfully read
|
1514 |
|
|
|
1515 |
|
|
Shared : Shared_Project_Tree_Data_Access;
|
1516 |
|
|
-- The shared data for this tree and all aggregated trees
|
1517 |
|
|
|
1518 |
|
|
Appdata : Project_Tree_Appdata_Access;
|
1519 |
|
|
-- Application-specific data for this tree
|
1520 |
|
|
|
1521 |
|
|
case Is_Root_Tree is
|
1522 |
|
|
when True =>
|
1523 |
|
|
Shared_Data : aliased Shared_Project_Tree_Data;
|
1524 |
|
|
-- Do not access directly, only through Shared
|
1525 |
|
|
|
1526 |
|
|
when False =>
|
1527 |
|
|
null;
|
1528 |
|
|
end case;
|
1529 |
|
|
end record;
|
1530 |
|
|
-- Data for a project tree
|
1531 |
|
|
|
1532 |
|
|
function Debug_Name (Tree : Project_Tree_Ref) return Name_Id;
|
1533 |
|
|
-- If debug traces are activated, return an identitier for the project
|
1534 |
|
|
-- tree. This modifies Name_Buffer.
|
1535 |
|
|
|
1536 |
|
|
procedure Expect (The_Token : Token_Type; Token_Image : String);
|
1537 |
|
|
-- Check that the current token is The_Token. If it is not, then output
|
1538 |
|
|
-- an error message.
|
1539 |
|
|
|
1540 |
|
|
procedure Initialize (Tree : Project_Tree_Ref);
|
1541 |
|
|
-- This procedure must be called before using any services from the Prj
|
1542 |
|
|
-- hierarchy. Namet.Initialize must be called before Prj.Initialize.
|
1543 |
|
|
|
1544 |
|
|
procedure Reset (Tree : Project_Tree_Ref);
|
1545 |
|
|
-- This procedure resets all the tables that are used when processing a
|
1546 |
|
|
-- project file tree. Initialize must be called before the call to Reset.
|
1547 |
|
|
|
1548 |
|
|
package Project_Boolean_Htable is new Simple_HTable
|
1549 |
|
|
(Header_Num => Header_Num,
|
1550 |
|
|
Element => Boolean,
|
1551 |
|
|
No_Element => False,
|
1552 |
|
|
Key => Project_Id,
|
1553 |
|
|
Hash => Hash,
|
1554 |
|
|
Equal => "=");
|
1555 |
|
|
-- A table that associates a project to a boolean. This is used to detect
|
1556 |
|
|
-- whether a project was already processed for instance.
|
1557 |
|
|
|
1558 |
|
|
generic
|
1559 |
|
|
with procedure Action (Project : Project_Id; Tree : Project_Tree_Ref);
|
1560 |
|
|
procedure For_Project_And_Aggregated
|
1561 |
|
|
(Root_Project : Project_Id;
|
1562 |
|
|
Root_Tree : Project_Tree_Ref);
|
1563 |
|
|
-- Execute Action for Root_Project and all its aggregated projects
|
1564 |
|
|
-- recursively.
|
1565 |
|
|
|
1566 |
|
|
generic
|
1567 |
|
|
type State is limited private;
|
1568 |
|
|
with procedure Action
|
1569 |
|
|
(Project : Project_Id;
|
1570 |
|
|
Tree : Project_Tree_Ref;
|
1571 |
|
|
With_State : in out State);
|
1572 |
|
|
procedure For_Every_Project_Imported
|
1573 |
|
|
(By : Project_Id;
|
1574 |
|
|
Tree : Project_Tree_Ref;
|
1575 |
|
|
With_State : in out State;
|
1576 |
|
|
Include_Aggregated : Boolean := True;
|
1577 |
|
|
Imported_First : Boolean := False);
|
1578 |
|
|
-- Call Action for each project imported directly or indirectly by project
|
1579 |
|
|
-- By, as well as extended projects.
|
1580 |
|
|
--
|
1581 |
|
|
-- The order of processing depends on Imported_First:
|
1582 |
|
|
--
|
1583 |
|
|
-- If False, Action is called according to the order of importation: if A
|
1584 |
|
|
-- imports B, directly or indirectly, Action will be called for A before
|
1585 |
|
|
-- it is called for B. If two projects import each other directly or
|
1586 |
|
|
-- indirectly (using at least one "limited with"), it is not specified
|
1587 |
|
|
-- for which of these two projects Action will be called first.
|
1588 |
|
|
--
|
1589 |
|
|
-- The order is reversed if Imported_First is True
|
1590 |
|
|
--
|
1591 |
|
|
-- With_State may be used by Action to choose a behavior or to report some
|
1592 |
|
|
-- global result.
|
1593 |
|
|
--
|
1594 |
|
|
-- If Include_Aggregated is True, then an aggregate project will recurse
|
1595 |
|
|
-- into the projects it aggregates. Otherwise, the latter are never
|
1596 |
|
|
-- returned.
|
1597 |
|
|
--
|
1598 |
|
|
-- In_Aggregate_Lib is True if the project is in an aggregate library
|
1599 |
|
|
--
|
1600 |
|
|
-- The Tree argument passed to the callback is required in the case of
|
1601 |
|
|
-- aggregated projects, since they might not be using the same tree as 'By'
|
1602 |
|
|
|
1603 |
|
|
type Project_Context is record
|
1604 |
|
|
In_Aggregate_Lib : Boolean;
|
1605 |
|
|
-- True if the project is part of an aggregate library
|
1606 |
|
|
|
1607 |
|
|
From_Encapsulated_Lib : Boolean;
|
1608 |
|
|
-- True if the project is imported from an encapsulated library
|
1609 |
|
|
end record;
|
1610 |
|
|
|
1611 |
|
|
generic
|
1612 |
|
|
type State is limited private;
|
1613 |
|
|
with procedure Action
|
1614 |
|
|
(Project : Project_Id;
|
1615 |
|
|
Tree : Project_Tree_Ref;
|
1616 |
|
|
Context : Project_Context;
|
1617 |
|
|
With_State : in out State);
|
1618 |
|
|
procedure For_Every_Project_Imported_Context
|
1619 |
|
|
(By : Project_Id;
|
1620 |
|
|
Tree : Project_Tree_Ref;
|
1621 |
|
|
With_State : in out State;
|
1622 |
|
|
Include_Aggregated : Boolean := True;
|
1623 |
|
|
Imported_First : Boolean := False);
|
1624 |
|
|
-- As for For_Every_Project_Imported but with an associated context
|
1625 |
|
|
|
1626 |
|
|
generic
|
1627 |
|
|
with procedure Action
|
1628 |
|
|
(Project : Project_Id;
|
1629 |
|
|
Tree : Project_Tree_Ref;
|
1630 |
|
|
Context : Project_Context);
|
1631 |
|
|
procedure For_Project_And_Aggregated_Context
|
1632 |
|
|
(Root_Project : Project_Id;
|
1633 |
|
|
Root_Tree : Project_Tree_Ref);
|
1634 |
|
|
-- As for For_Project_And_Aggregated but with an associated context
|
1635 |
|
|
|
1636 |
|
|
function Extend_Name
|
1637 |
|
|
(File : File_Name_Type;
|
1638 |
|
|
With_Suffix : String) return File_Name_Type;
|
1639 |
|
|
-- Replace the extension of File with With_Suffix
|
1640 |
|
|
|
1641 |
|
|
function Object_Name
|
1642 |
|
|
(Source_File_Name : File_Name_Type;
|
1643 |
|
|
Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
|
1644 |
|
|
-- Returns the object file name corresponding to a source file name
|
1645 |
|
|
|
1646 |
|
|
function Object_Name
|
1647 |
|
|
(Source_File_Name : File_Name_Type;
|
1648 |
|
|
Source_Index : Int;
|
1649 |
|
|
Index_Separator : Character;
|
1650 |
|
|
Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
|
1651 |
|
|
-- Returns the object file name corresponding to a unit in a multi-source
|
1652 |
|
|
-- file.
|
1653 |
|
|
|
1654 |
|
|
function Dependency_Name
|
1655 |
|
|
(Source_File_Name : File_Name_Type;
|
1656 |
|
|
Dependency : Dependency_File_Kind) return File_Name_Type;
|
1657 |
|
|
-- Returns the dependency file name corresponding to a source file name
|
1658 |
|
|
|
1659 |
|
|
function Switches_Name
|
1660 |
|
|
(Source_File_Name : File_Name_Type) return File_Name_Type;
|
1661 |
|
|
-- Returns the switches file name corresponding to a source file name
|
1662 |
|
|
|
1663 |
|
|
procedure Set_Path_File_Var (Name : String; Value : String);
|
1664 |
|
|
-- Call Setenv, after calling To_Host_File_Spec
|
1665 |
|
|
|
1666 |
|
|
function Current_Source_Path_File_Of
|
1667 |
|
|
(Shared : Shared_Project_Tree_Data_Access) return Path_Name_Type;
|
1668 |
|
|
-- Get the current include path file name
|
1669 |
|
|
|
1670 |
|
|
procedure Set_Current_Source_Path_File_Of
|
1671 |
|
|
(Shared : Shared_Project_Tree_Data_Access;
|
1672 |
|
|
To : Path_Name_Type);
|
1673 |
|
|
-- Record the current include path file name
|
1674 |
|
|
|
1675 |
|
|
function Current_Object_Path_File_Of
|
1676 |
|
|
(Shared : Shared_Project_Tree_Data_Access) return Path_Name_Type;
|
1677 |
|
|
-- Get the current object path file name
|
1678 |
|
|
|
1679 |
|
|
procedure Set_Current_Object_Path_File_Of
|
1680 |
|
|
(Shared : Shared_Project_Tree_Data_Access;
|
1681 |
|
|
To : Path_Name_Type);
|
1682 |
|
|
-- Record the current object path file name
|
1683 |
|
|
|
1684 |
|
|
-----------
|
1685 |
|
|
-- Flags --
|
1686 |
|
|
-----------
|
1687 |
|
|
|
1688 |
|
|
type Processing_Flags is private;
|
1689 |
|
|
-- Flags used while parsing and processing a project tree to configure the
|
1690 |
|
|
-- behavior of the parser, and indicate how to report error messages. This
|
1691 |
|
|
-- structure does not allocate memory and never needs to be freed
|
1692 |
|
|
|
1693 |
|
|
type Error_Warning is (Silent, Warning, Error);
|
1694 |
|
|
-- Severity of some situations, such as: no Ada sources in a project where
|
1695 |
|
|
-- Ada is one of the language.
|
1696 |
|
|
--
|
1697 |
|
|
-- When the situation occurs, the behaviour depends on the setting:
|
1698 |
|
|
--
|
1699 |
|
|
-- - Silent: no action
|
1700 |
|
|
-- - Warning: issue a warning, does not cause the tool to fail
|
1701 |
|
|
-- - Error: issue an error, causes the tool to fail
|
1702 |
|
|
|
1703 |
|
|
type Error_Handler is access procedure
|
1704 |
|
|
(Project : Project_Id;
|
1705 |
|
|
Is_Warning : Boolean);
|
1706 |
|
|
-- This warns when an error was found when parsing a project. The error
|
1707 |
|
|
-- itself is handled through Prj.Err (and Prj.Err.Finalize should be called
|
1708 |
|
|
-- to actually print the error). This ensures that duplicate error messages
|
1709 |
|
|
-- are always correctly removed, that errors msgs are sorted, and that all
|
1710 |
|
|
-- tools will report the same error to the user.
|
1711 |
|
|
|
1712 |
|
|
function Create_Flags
|
1713 |
|
|
(Report_Error : Error_Handler;
|
1714 |
|
|
When_No_Sources : Error_Warning;
|
1715 |
|
|
Require_Sources_Other_Lang : Boolean := True;
|
1716 |
|
|
Allow_Duplicate_Basenames : Boolean := True;
|
1717 |
|
|
Compiler_Driver_Mandatory : Boolean := False;
|
1718 |
|
|
Error_On_Unknown_Language : Boolean := True;
|
1719 |
|
|
Require_Obj_Dirs : Error_Warning := Error;
|
1720 |
|
|
Allow_Invalid_External : Error_Warning := Error;
|
1721 |
|
|
Missing_Source_Files : Error_Warning := Error;
|
1722 |
|
|
Ignore_Missing_With : Boolean := False)
|
1723 |
|
|
return Processing_Flags;
|
1724 |
|
|
-- Function used to create Processing_Flags structure
|
1725 |
|
|
--
|
1726 |
|
|
-- If Allow_Duplicate_Basenames, then files with the same base names are
|
1727 |
|
|
-- authorized within a project for source-based languages (never for unit
|
1728 |
|
|
-- based languages).
|
1729 |
|
|
--
|
1730 |
|
|
-- If Compiler_Driver_Mandatory is true, then a Compiler.Driver attribute
|
1731 |
|
|
-- for each language must be defined, or we will not look for its source
|
1732 |
|
|
-- files.
|
1733 |
|
|
--
|
1734 |
|
|
-- When_No_Sources indicates what should be done when no sources of a
|
1735 |
|
|
-- language are found in a project where this language is declared.
|
1736 |
|
|
-- If Require_Sources_Other_Lang is true, then all languages must have at
|
1737 |
|
|
-- least one source file, or an error is reported via When_No_Sources. If
|
1738 |
|
|
-- it is false, this is only required for Ada (and only if it is a language
|
1739 |
|
|
-- of the project). When this parameter is set to False, we do not check
|
1740 |
|
|
-- that a proper naming scheme is defined for languages other than Ada.
|
1741 |
|
|
--
|
1742 |
|
|
-- If Report_Error is null, use the standard error reporting mechanism
|
1743 |
|
|
-- (Errout). Otherwise, report errors using Report_Error.
|
1744 |
|
|
--
|
1745 |
|
|
-- If Error_On_Unknown_Language is true, an error is displayed if some of
|
1746 |
|
|
-- the source files listed in the project do not match any naming scheme
|
1747 |
|
|
--
|
1748 |
|
|
-- If Require_Obj_Dirs is true, then all object directories must exist
|
1749 |
|
|
-- (possibly after they have been created automatically if the appropriate
|
1750 |
|
|
-- switches were specified), or an error is raised.
|
1751 |
|
|
--
|
1752 |
|
|
-- If Allow_Invalid_External is Silent, then no error is reported when an
|
1753 |
|
|
-- invalid value is used for an external variable (and it doesn't match its
|
1754 |
|
|
-- type). Instead, the first possible value is used.
|
1755 |
|
|
--
|
1756 |
|
|
-- Missing_Source_Files indicates whether it is an error or a warning that
|
1757 |
|
|
-- a source file mentioned in the Source_Files attributes is not actually
|
1758 |
|
|
-- found in the source directories. This also impacts errors for missing
|
1759 |
|
|
-- source directories.
|
1760 |
|
|
--
|
1761 |
|
|
-- If Ignore_Missing_With is True, then a "with" statement that cannot be
|
1762 |
|
|
-- resolved will simply be ignored. However, in such a case, the flag
|
1763 |
|
|
-- Incomplete_With in the project tree will be set to True.
|
1764 |
|
|
-- This is meant for use by tools so that they can properly set the
|
1765 |
|
|
-- project path in such a case:
|
1766 |
|
|
-- * no "gnatls" found (so no default project path)
|
1767 |
|
|
-- * user project sets Project.IDE'gnatls attribute to a cross gnatls
|
1768 |
|
|
-- * user project also includes a "with" that can only be resolved
|
1769 |
|
|
-- once we have found the gnatls
|
1770 |
|
|
|
1771 |
|
|
Gprbuild_Flags : constant Processing_Flags;
|
1772 |
|
|
Gprclean_Flags : constant Processing_Flags;
|
1773 |
|
|
Gnatmake_Flags : constant Processing_Flags;
|
1774 |
|
|
-- Flags used by the various tools. They all display the error messages
|
1775 |
|
|
-- through Prj.Err.
|
1776 |
|
|
|
1777 |
|
|
----------------
|
1778 |
|
|
-- Temp Files --
|
1779 |
|
|
----------------
|
1780 |
|
|
|
1781 |
|
|
procedure Record_Temp_File
|
1782 |
|
|
(Shared : Shared_Project_Tree_Data_Access;
|
1783 |
|
|
Path : Path_Name_Type);
|
1784 |
|
|
-- Record the path of a newly created temporary file, so that it can be
|
1785 |
|
|
-- deleted later.
|
1786 |
|
|
|
1787 |
|
|
procedure Delete_All_Temp_Files
|
1788 |
|
|
(Shared : Shared_Project_Tree_Data_Access);
|
1789 |
|
|
-- Delete all recorded temporary files.
|
1790 |
|
|
-- Does nothing if Debug.Debug_Flag_N is set
|
1791 |
|
|
|
1792 |
|
|
procedure Delete_Temp_Config_Files (Project_Tree : Project_Tree_Ref);
|
1793 |
|
|
-- Delete all temporary config files. Does nothing if Debug.Debug_Flag_N is
|
1794 |
|
|
-- set or if Project_Tree is null. This initially came from gnatmake
|
1795 |
|
|
-- ??? Should this be combined with Delete_All_Temp_Files above
|
1796 |
|
|
|
1797 |
|
|
procedure Delete_Temporary_File
|
1798 |
|
|
(Shared : Shared_Project_Tree_Data_Access := null;
|
1799 |
|
|
Path : Path_Name_Type);
|
1800 |
|
|
-- Delete a temporary file from the disk. The file is also removed from the
|
1801 |
|
|
-- list of temporary files to delete at the end of the program, in case
|
1802 |
|
|
-- another program running on the same machine has recreated it. Does
|
1803 |
|
|
-- nothing if Debug.Debug_Flag_N is set
|
1804 |
|
|
|
1805 |
|
|
Virtual_Prefix : constant String := "v$";
|
1806 |
|
|
-- The prefix for virtual extending projects. Because of the '$', which is
|
1807 |
|
|
-- normally forbidden for project names, there cannot be any name clash.
|
1808 |
|
|
|
1809 |
|
|
-----------
|
1810 |
|
|
-- Debug --
|
1811 |
|
|
-----------
|
1812 |
|
|
|
1813 |
|
|
type Verbosity is (Default, Medium, High);
|
1814 |
|
|
pragma Ordered (Verbosity);
|
1815 |
|
|
-- Verbosity when parsing GNAT Project Files
|
1816 |
|
|
-- Default is default (very quiet, if no errors).
|
1817 |
|
|
-- Medium is more verbose.
|
1818 |
|
|
-- High is extremely verbose.
|
1819 |
|
|
|
1820 |
|
|
Current_Verbosity : Verbosity := Default;
|
1821 |
|
|
-- The current value of the verbosity the project files are parsed with
|
1822 |
|
|
|
1823 |
|
|
procedure Debug_Indent;
|
1824 |
|
|
-- Inserts a series of blanks depending on the current indentation level
|
1825 |
|
|
|
1826 |
|
|
procedure Debug_Output (Str : String);
|
1827 |
|
|
procedure Debug_Output (Str : String; Str2 : Name_Id);
|
1828 |
|
|
-- If Current_Verbosity is not Default, outputs Str.
|
1829 |
|
|
-- This indents Str based on the current indentation level for traces
|
1830 |
|
|
-- Debug_Error is intended to be used to report an error in the traces.
|
1831 |
|
|
|
1832 |
|
|
procedure Debug_Increase_Indent
|
1833 |
|
|
(Str : String := ""; Str2 : Name_Id := No_Name);
|
1834 |
|
|
procedure Debug_Decrease_Indent (Str : String := "");
|
1835 |
|
|
-- Increase or decrease the indentation level for debug traces. This
|
1836 |
|
|
-- indentation level only affects output done through Debug_Output.
|
1837 |
|
|
|
1838 |
|
|
private
|
1839 |
|
|
|
1840 |
|
|
All_Packages : constant String_List_Access := null;
|
1841 |
|
|
|
1842 |
|
|
No_Project_Tree : constant Project_Tree_Ref := null;
|
1843 |
|
|
|
1844 |
|
|
Ignored : constant Variable_Kind := Single;
|
1845 |
|
|
|
1846 |
|
|
Nil_Variable_Value : constant Variable_Value :=
|
1847 |
|
|
(Project => No_Project,
|
1848 |
|
|
Kind => Undefined,
|
1849 |
|
|
Location => No_Location,
|
1850 |
|
|
Default => False);
|
1851 |
|
|
|
1852 |
|
|
type Source_Iterator is record
|
1853 |
|
|
In_Tree : Project_Tree_Ref;
|
1854 |
|
|
|
1855 |
|
|
Project : Project_List;
|
1856 |
|
|
All_Projects : Boolean;
|
1857 |
|
|
-- Current project and whether we should move on to the next
|
1858 |
|
|
|
1859 |
|
|
Language : Language_Ptr;
|
1860 |
|
|
-- Current language processed
|
1861 |
|
|
|
1862 |
|
|
Language_Name : Name_Id;
|
1863 |
|
|
-- Only sources of this language will be returned (or all if No_Name)
|
1864 |
|
|
|
1865 |
|
|
Current : Source_Id;
|
1866 |
|
|
|
1867 |
|
|
Encapsulated_Libs : Boolean;
|
1868 |
|
|
-- True if we want to include the sources from encapsulated libs
|
1869 |
|
|
end record;
|
1870 |
|
|
|
1871 |
|
|
procedure Add_To_Buffer
|
1872 |
|
|
(S : String;
|
1873 |
|
|
To : in out String_Access;
|
1874 |
|
|
Last : in out Natural);
|
1875 |
|
|
-- Append a String to the Buffer
|
1876 |
|
|
|
1877 |
|
|
package Temp_Files_Table is new GNAT.Dynamic_Tables
|
1878 |
|
|
(Table_Component_Type => Path_Name_Type,
|
1879 |
|
|
Table_Index_Type => Integer,
|
1880 |
|
|
Table_Low_Bound => 1,
|
1881 |
|
|
Table_Initial => 10,
|
1882 |
|
|
Table_Increment => 10);
|
1883 |
|
|
-- Table to store the path name of all the created temporary files, so that
|
1884 |
|
|
-- they can be deleted at the end, or when the program is interrupted.
|
1885 |
|
|
|
1886 |
|
|
type Private_Project_Tree_Data is record
|
1887 |
|
|
Temp_Files : Temp_Files_Table.Instance;
|
1888 |
|
|
-- Temporary files created as part of running tools (pragma files,
|
1889 |
|
|
-- mapping files,...)
|
1890 |
|
|
|
1891 |
|
|
Current_Source_Path_File : Path_Name_Type := No_Path;
|
1892 |
|
|
-- Current value of project source path file env var. Used to avoid
|
1893 |
|
|
-- setting the env var to the same value. When different from No_Path,
|
1894 |
|
|
-- this indicates that logical names (VMS) or environment variables were
|
1895 |
|
|
-- created and should be deassigned to avoid polluting the environment
|
1896 |
|
|
-- on VMS.
|
1897 |
|
|
-- gnatmake only
|
1898 |
|
|
|
1899 |
|
|
Current_Object_Path_File : Path_Name_Type := No_Path;
|
1900 |
|
|
-- Current value of project object path file env var. Used to avoid
|
1901 |
|
|
-- setting the env var to the same value.
|
1902 |
|
|
-- gnatmake only
|
1903 |
|
|
|
1904 |
|
|
end record;
|
1905 |
|
|
-- Type to represent the part of a project tree which is private to the
|
1906 |
|
|
-- Project Manager.
|
1907 |
|
|
|
1908 |
|
|
type Processing_Flags is record
|
1909 |
|
|
Require_Sources_Other_Lang : Boolean;
|
1910 |
|
|
Report_Error : Error_Handler;
|
1911 |
|
|
When_No_Sources : Error_Warning;
|
1912 |
|
|
Allow_Duplicate_Basenames : Boolean;
|
1913 |
|
|
Compiler_Driver_Mandatory : Boolean;
|
1914 |
|
|
Error_On_Unknown_Language : Boolean;
|
1915 |
|
|
Require_Obj_Dirs : Error_Warning;
|
1916 |
|
|
Allow_Invalid_External : Error_Warning;
|
1917 |
|
|
Missing_Source_Files : Error_Warning;
|
1918 |
|
|
Ignore_Missing_With : Boolean;
|
1919 |
|
|
end record;
|
1920 |
|
|
|
1921 |
|
|
Gprbuild_Flags : constant Processing_Flags :=
|
1922 |
|
|
(Report_Error => null,
|
1923 |
|
|
When_No_Sources => Warning,
|
1924 |
|
|
Require_Sources_Other_Lang => True,
|
1925 |
|
|
Allow_Duplicate_Basenames => False,
|
1926 |
|
|
Compiler_Driver_Mandatory => True,
|
1927 |
|
|
Error_On_Unknown_Language => True,
|
1928 |
|
|
Require_Obj_Dirs => Error,
|
1929 |
|
|
Allow_Invalid_External => Error,
|
1930 |
|
|
Missing_Source_Files => Error,
|
1931 |
|
|
Ignore_Missing_With => False);
|
1932 |
|
|
|
1933 |
|
|
Gprclean_Flags : constant Processing_Flags :=
|
1934 |
|
|
(Report_Error => null,
|
1935 |
|
|
When_No_Sources => Warning,
|
1936 |
|
|
Require_Sources_Other_Lang => True,
|
1937 |
|
|
Allow_Duplicate_Basenames => False,
|
1938 |
|
|
Compiler_Driver_Mandatory => True,
|
1939 |
|
|
Error_On_Unknown_Language => True,
|
1940 |
|
|
Require_Obj_Dirs => Warning,
|
1941 |
|
|
Allow_Invalid_External => Error,
|
1942 |
|
|
Missing_Source_Files => Error,
|
1943 |
|
|
Ignore_Missing_With => False);
|
1944 |
|
|
|
1945 |
|
|
Gnatmake_Flags : constant Processing_Flags :=
|
1946 |
|
|
(Report_Error => null,
|
1947 |
|
|
When_No_Sources => Error,
|
1948 |
|
|
Require_Sources_Other_Lang => False,
|
1949 |
|
|
Allow_Duplicate_Basenames => False,
|
1950 |
|
|
Compiler_Driver_Mandatory => False,
|
1951 |
|
|
Error_On_Unknown_Language => False,
|
1952 |
|
|
Require_Obj_Dirs => Error,
|
1953 |
|
|
Allow_Invalid_External => Error,
|
1954 |
|
|
Missing_Source_Files => Error,
|
1955 |
|
|
Ignore_Missing_With => False);
|
1956 |
|
|
|
1957 |
|
|
end Prj;
|