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