OSDN Git Service

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