OSDN Git Service

2007-08-14 Robert Dewar <dewar@adacore.com>
[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-2007, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  The following package declares the data types for GNAT project.
28 --  These data types may be used by GNAT Project-aware tools.
29
30 --  Children of these package implements various services on these data types.
31 --  See in particular Prj.Pars and Prj.Env.
32
33 with Casing; use Casing;
34 with Namet;  use Namet;
35 with Scans;  use Scans;
36 with Table;
37 with Types;  use Types;
38
39 with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
40 with GNAT.Dynamic_Tables;
41 with GNAT.OS_Lib;          use GNAT.OS_Lib;
42
43 with System.HTable;
44
45 package Prj is
46
47    type Library_Support is (None, Static_Only, Full);
48    --  Support for Library Project File.
49    --  - None: Library Project Files are not supported at all
50    --  - Static_Only: Library Project Files are only supported for static
51    --    libraries.
52    --  - Full: Library Project Files are supported for static and dynamic
53    --    (shared) libraries.
54
55    type Yes_No_Unknown is (Yes, No, Unknown);
56    --  Tri-state to decide if -lgnarl is needed when linking
57
58    type Mode is (Multi_Language, Ada_Only);
59
60    function Get_Mode return Mode;
61    pragma Inline (Get_Mode);
62
63    procedure Set_Mode (New_Mode : Mode);
64    pragma Inline (Set_Mode);
65
66    function In_Configuration return Boolean;
67    pragma Inline (In_Configuration);
68
69    procedure Set_In_Configuration (Value : Boolean);
70    pragma Inline (Set_In_Configuration);
71
72    All_Packages : constant String_List_Access;
73    --  Default value of parameter Packages of procedures Parse, in Prj.Pars and
74    --  Prj.Part, indicating that all packages should be checked.
75
76    type Project_Tree_Data;
77    type Project_Tree_Ref is access all Project_Tree_Data;
78    --  Reference to a project tree.
79    --  Several project trees may exist in memory at the same time.
80
81    No_Project_Tree : constant Project_Tree_Ref;
82
83    function Default_Ada_Spec_Suffix return File_Name_Type;
84    pragma Inline (Default_Ada_Spec_Suffix);
85    --  The name for the standard GNAT suffix for Ada spec source file name
86    --  ".ads". Initialized by Prj.Initialize.
87
88    function Default_Ada_Body_Suffix return File_Name_Type;
89    pragma Inline (Default_Ada_Body_Suffix);
90    --  The name for the standard GNAT suffix for Ada body source file name
91    --  ".adb". Initialized by Prj.Initialize.
92
93    function Slash return Path_Name_Type;
94    pragma Inline (Slash);
95    --  "/", used as the path of locally removed files
96
97    Config_Project_File_Extension : String := ".cgpr";
98    Project_File_Extension : String := ".gpr";
99    --  The standard config and user project file name extensions. They are not
100    --  constants, because Canonical_Case_File_Name is called on these variables
101    --  in the body of Prj.
102
103    type Error_Warning is (Silent, Warning, Error);
104    --  Severity of some situations, such as: no Ada sources in a project where
105    --  Ada is one of the language.
106    --
107    --  When the situation occurs, the behaviour depends on the setting:
108    --
109    --    - Silent:  no action
110    --    - Warning: issue a warning, does not cause the tool to fail
111    --    - Error:   issue an error, causes the tool to fail
112
113    function Empty_File   return File_Name_Type;
114    function Empty_String return Name_Id;
115    --  Return the id for an empty string ""
116
117    type Project_Id is new Nat;
118    No_Project : constant Project_Id := 0;
119    --  Id of a Project File
120
121    type String_List_Id is new Nat;
122    Nil_String : constant String_List_Id := 0;
123    type String_Element is record
124       Value         : Name_Id        := No_Name;
125       Index         : Int            := 0;
126       Display_Value : Name_Id        := No_Name;
127       Location      : Source_Ptr     := No_Location;
128       Flag          : Boolean        := False;
129       Next          : String_List_Id := Nil_String;
130    end record;
131    --  To hold values for string list variables and array elements.
132    --  Component Flag may be used for various purposes. For source
133    --  directories, it indicates if the directory contains Ada source(s).
134
135    package String_Element_Table is new GNAT.Dynamic_Tables
136      (Table_Component_Type => String_Element,
137       Table_Index_Type     => String_List_Id,
138       Table_Low_Bound      => 1,
139       Table_Initial        => 200,
140       Table_Increment      => 100);
141    --  The table for string elements in string lists
142
143    type Variable_Kind is (Undefined, List, Single);
144    --  Different kinds of variables
145
146    subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
147    --  The defined kinds of variables
148
149    Ignored : constant Variable_Kind;
150    --  Used to indicate that a package declaration must be ignored
151    --  while processing the project tree (unknown package name).
152
153    type Variable_Value (Kind : Variable_Kind := Undefined) is record
154       Project  : Project_Id := No_Project;
155       Location : Source_Ptr := No_Location;
156       Default  : Boolean    := False;
157       case Kind is
158          when Undefined =>
159             null;
160          when List =>
161             Values : String_List_Id := Nil_String;
162          when Single =>
163             Value : Name_Id := No_Name;
164             Index : Int     := 0;
165       end case;
166    end record;
167    --  Values for variables and array elements. Default is True if the
168    --  current value is the default one for the variable
169
170    Nil_Variable_Value : constant Variable_Value;
171    --  Value of a non existing variable or array element
172
173    type Variable_Id is new Nat;
174    No_Variable : constant Variable_Id := 0;
175    type Variable is record
176       Next  : Variable_Id := No_Variable;
177       Name  : Name_Id;
178       Value : Variable_Value;
179    end record;
180    --  To hold the list of variables in a project file and in packages
181
182    package Variable_Element_Table is new GNAT.Dynamic_Tables
183      (Table_Component_Type => Variable,
184       Table_Index_Type     => Variable_Id,
185       Table_Low_Bound      => 1,
186       Table_Initial        => 200,
187       Table_Increment      => 100);
188    --  The table of variable in list of variables
189
190    type Array_Element_Id is new Nat;
191    No_Array_Element : constant Array_Element_Id := 0;
192    type Array_Element is record
193       Index                : Name_Id;
194       Src_Index            : Int := 0;
195       Index_Case_Sensitive : Boolean := True;
196       Value                : Variable_Value;
197       Next                 : Array_Element_Id := No_Array_Element;
198    end record;
199    --  Each Array_Element represents an array element and is linked (Next)
200    --  to the next array element, if any, in the array.
201
202    package Array_Element_Table is new GNAT.Dynamic_Tables
203      (Table_Component_Type => Array_Element,
204       Table_Index_Type     => Array_Element_Id,
205       Table_Low_Bound      => 1,
206       Table_Initial        => 200,
207       Table_Increment      => 100);
208    --  The table that contains all array elements
209
210    type Array_Id is new Nat;
211    No_Array : constant Array_Id := 0;
212    type Array_Data is record
213       Name  : Name_Id          := No_Name;
214       Value : Array_Element_Id := No_Array_Element;
215       Next  : Array_Id         := No_Array;
216    end record;
217    --  Each Array_Data value represents an array.
218    --  Value is the id of the first element.
219    --  Next is the id of the next array in the project file or package.
220
221    package Array_Table is new GNAT.Dynamic_Tables
222      (Table_Component_Type => Array_Data,
223       Table_Index_Type     => Array_Id,
224       Table_Low_Bound      => 1,
225       Table_Initial        => 200,
226       Table_Increment      => 100);
227    --  The table that contains all arrays
228
229    type Package_Id is new Nat;
230    No_Package : constant Package_Id := 0;
231    type Declarations is record
232       Variables  : Variable_Id := No_Variable;
233       Attributes : Variable_Id := No_Variable;
234       Arrays     : Array_Id    := No_Array;
235       Packages   : Package_Id  := No_Package;
236    end record;
237    --  Contains the declarations (variables, single and array attributes,
238    --  packages) for a project or a package in a project.
239
240    No_Declarations : constant Declarations :=
241      (Variables  => No_Variable,
242       Attributes => No_Variable,
243       Arrays     => No_Array,
244       Packages   => No_Package);
245    --  Default value of Declarations: indicates that there is no declarations
246
247    type Package_Element is record
248       Name   : Name_Id      := No_Name;
249       Decl   : Declarations := No_Declarations;
250       Parent : Package_Id   := No_Package;
251       Next   : Package_Id   := No_Package;
252    end record;
253    --  A package (includes declarations that may include other packages)
254
255    package Package_Table is new GNAT.Dynamic_Tables
256      (Table_Component_Type => Package_Element,
257       Table_Index_Type     => Package_Id,
258       Table_Low_Bound      => 1,
259       Table_Initial        => 100,
260       Table_Increment      => 100);
261    --  The table that contains all packages
262
263    type Language_Index is new Nat;
264
265    No_Language_Index : constant Language_Index := 0;
266
267    procedure Display_Language_Name
268      (In_Tree  : Project_Tree_Ref;
269       Language : Language_Index);
270
271    type Header_Num is range 0 .. 2047;
272
273    function Hash is new System.HTable.Hash (Header_Num => Header_Num);
274
275    function Hash (Name : Name_Id)        return Header_Num;
276    function Hash (Name : File_Name_Type) return Header_Num;
277    function Hash (Name : Path_Name_Type) return Header_Num;
278
279    type Language_Kind is (File_Based, Unit_Based);
280
281    type Dependency_File_Kind is (None, Makefile, ALI_File);
282
283    Makefile_Dependency_Suffix : constant String := ".d";
284    ALI_Dependency_Suffix      : constant String := ".ali";
285
286    Switches_Dependency_Suffix : constant String := ".cswi";
287
288    Binder_Exchange_Suffix     : constant String := ".bexch";
289    --  Suffix for binder exchange files
290
291    Library_Exchange_Suffix     : constant String := ".lexch";
292    --  Suffix for library exchange files
293
294    type Name_List_Index is new Nat;
295    No_Name_List            : constant Name_List_Index := 0;
296
297    type Name_Node is record
298       Name : Name_Id         := No_Name;
299       Next : Name_List_Index := No_Name_List;
300    end record;
301
302    function Default_Language (In_Tree : Project_Tree_Ref) return Name_Id;
303
304    package Name_List_Table is new GNAT.Dynamic_Tables
305      (Table_Component_Type => Name_Node,
306       Table_Index_Type     => Name_List_Index,
307       Table_Low_Bound      => 1,
308       Table_Initial        => 10,
309       Table_Increment      => 100);
310    --  The table for lists of names used in package Language_Processing
311
312    package Mapping_Files_Htable is new Simple_HTable
313      (Header_Num => Header_Num,
314       Element    => Path_Name_Type,
315       No_Element => No_Path,
316       Key        => Path_Name_Type,
317       Hash       => Hash,
318       Equal      => "=");
319    --  A hash table to store the mapping files that are not used
320
321    type Lang_Naming_Data is record
322       Dot_Replacement : File_Name_Type := No_File;
323       --  The string to replace '.' in the source file name (for Ada)
324
325       Casing : Casing_Type := All_Lower_Case;
326       --  The casing of the source file name (for Ada)
327
328       Separate_Suffix : File_Name_Type := No_File;
329       --  String to append to unit name for source file name of an Ada subunit
330
331       Spec_Suffix : File_Name_Type := No_File;
332       --  The string to append to the unit name for the
333       --  source file name of a spec.
334
335       Body_Suffix : File_Name_Type := No_File;
336       --  The string to append to the unit name for the
337       --  source file name of a body.
338    end record;
339
340    No_Lang_Naming_Data : constant Lang_Naming_Data :=
341                            (Dot_Replacement => No_File,
342                             Casing          => All_Lower_Case,
343                             Separate_Suffix => No_File,
344                             Spec_Suffix     => No_File,
345                             Body_Suffix     => No_File);
346
347    type Source_Id is new Nat;
348
349    No_Source : constant Source_Id := 0;
350
351    --  All the fields in the below record should be commented ???
352
353    type Language_Config is record
354       Kind : Language_Kind := File_Based;
355       --  Kind of language. All languages are file based, except Ada which is
356       --  unit based.
357
358       Naming_Data : Lang_Naming_Data;
359       --  The naming data for the languages (prefixs, etc)
360
361       Compiler_Driver : File_Name_Type := No_File;
362       --  The name of the executable for the compiler of the language
363
364       Compiler_Driver_Path : String_Access := null;
365       --  The path name of the executable for the compiler of the language
366
367       Compiler_Min_Options : Name_List_Index := No_Name_List;
368       --  The minimum options for the compiler of the language. Specified
369       --  in the configuration as Compiler'Switches (<language>).
370
371       Min_Compiler_Options : String_List_Access := null;
372       --  The minimum options as an argument list
373
374       Compilation_PIC_Option : Name_List_Index := No_Name_List;
375       --  The option(s) to compile a source in Position Independent Code for
376       --  shared libraries. Specified in the configuration. When not specified,
377       --  there is no need for such switch.
378
379       Mapping_File_Switches  : Name_List_Index := No_Name_List;
380       --  The option(s) to provide a mapping file to the compiler. Specified in
381       --  the configuration. When not ???
382
383       Mapping_Spec_Suffix  : File_Name_Type       := No_File;
384       Mapping_Body_Suffix  : File_Name_Type       := No_File;
385       Config_File_Switches : Name_List_Index      := No_Name_List;
386       Dependency_Kind      : Dependency_File_Kind := None;
387       Dependency_Option    : Name_List_Index      := No_Name_List;
388       Compute_Dependency   : Name_List_Index      := No_Name_List;
389       Include_Option       : Name_List_Index      := No_Name_List;
390
391       Include_Path : Name_Id := No_Name;
392       --  Name of an environment variable
393
394       Include_Path_File : Name_Id := No_Name;
395       --  Name of an environment variable
396
397       Objects_Path : Name_Id := No_Name;
398       --  Name of an environment variable
399
400       Objects_Path_File : Name_Id := No_Name;
401       --  Name of an environment variable
402
403       Config_Body           : Name_Id         := No_Name;
404       Config_Spec           : Name_Id         := No_Name;
405       Config_Body_Pattern   : Name_Id         := No_Name;
406       Config_Spec_Pattern   : Name_Id         := No_Name;
407       Config_File_Unique    : Boolean         := False;
408       Runtime_Project       : Path_Name_Type  := No_Path;
409       Binder_Driver         : File_Name_Type  := No_File;
410       Binder_Driver_Path    : Path_Name_Type  := No_Path;
411       Binder_Min_Options    : Name_List_Index := No_Name_List;
412       Binder_Prefix         : Name_Id         := No_Name;
413       Toolchain_Version     : Name_Id         := No_Name;
414       Toolchain_Description : Name_Id         := No_Name;
415       PIC_Option            : Name_Id         := No_Name;
416       Objects_Generated     : Boolean         := True;
417    end record;
418
419    No_Language_Config : constant Language_Config :=
420                           (Kind                    => File_Based,
421                            Naming_Data             => No_Lang_Naming_Data,
422                            Compiler_Driver         => No_File,
423                            Compiler_Driver_Path    => null,
424                            Compiler_Min_Options    => No_Name_List,
425                            Min_Compiler_Options    => null,
426                            Compilation_PIC_Option  => No_Name_List,
427                            Mapping_File_Switches   => No_Name_List,
428                            Mapping_Spec_Suffix     => No_File,
429                            Mapping_Body_Suffix     => No_File,
430                            Config_File_Switches    => No_Name_List,
431                            Dependency_Kind         => Makefile,
432                            Dependency_Option       => No_Name_List,
433                            Compute_Dependency      => No_Name_List,
434                            Include_Option          => No_Name_List,
435                            Include_Path            => No_Name,
436                            Include_Path_File       => No_Name,
437                            Objects_Path            => No_Name,
438                            Objects_Path_File       => No_Name,
439                            Config_Body             => No_Name,
440                            Config_Spec             => No_Name,
441                            Config_Body_Pattern     => No_Name,
442                            Config_Spec_Pattern     => No_Name,
443                            Config_File_Unique      => False,
444                            Runtime_Project         => No_Path,
445                            Binder_Driver           => No_File,
446                            Binder_Driver_Path      => No_Path,
447                            Binder_Min_Options      => No_Name_List,
448                            Binder_Prefix           => No_Name,
449                            Toolchain_Version       => No_Name,
450                            Toolchain_Description   => No_Name,
451                            PIC_Option              => No_Name,
452                            Objects_Generated       => True);
453
454    type Language_Data is record
455       Name          : Name_Id         := No_Name;
456       Display_Name  : Name_Id         := No_Name;
457       Config        : Language_Config := No_Language_Config;
458       First_Source  : Source_Id       := No_Source;
459       Mapping_Files : Mapping_Files_Htable.Instance :=
460                         Mapping_Files_Htable.Nil;
461       Next          : Language_Index  := No_Language_Index;
462    end record;
463
464    No_Language_Data : constant Language_Data :=
465                         (Name          => No_Name,
466                          Display_Name  => No_Name,
467                          Config        => No_Language_Config,
468                          First_Source  => No_Source,
469                          Mapping_Files => Mapping_Files_Htable.Nil,
470                          Next          => No_Language_Index);
471
472    package Language_Data_Table is new GNAT.Dynamic_Tables
473      (Table_Component_Type => Language_Data,
474       Table_Index_Type     => Language_Index,
475       Table_Low_Bound      => 1,
476       Table_Initial        => 10,
477       Table_Increment      => 100);
478    --  The table for lists of names used in package Language_Processing
479
480    type Alternate_Language_Id is new Nat;
481
482    No_Alternate_Language : constant Alternate_Language_Id := 0;
483
484    type Alternate_Language_Data is record
485       Language : Language_Index := No_Language_Index;
486       Next     : Alternate_Language_Id := No_Alternate_Language;
487    end record;
488
489    package Alternate_Language_Table is new GNAT.Dynamic_Tables
490      (Table_Component_Type => Alternate_Language_Data,
491       Table_Index_Type     => Alternate_Language_Id,
492       Table_Low_Bound      => 1,
493       Table_Initial        => 10,
494       Table_Increment      => 100);
495    --  The table for storing the alternate languages of a header file that
496    --  is used for several languages.
497
498    type Source_Kind is (Spec, Impl, Sep);
499
500    --  Following record needs full comments on every field ???
501
502    type Source_Data is record
503       Project             : Project_Id            := No_Project;
504       Language_Name       : Name_Id               := No_Name;
505       Language            : Language_Index        := No_Language_Index;
506       Alternate_Languages : Alternate_Language_Id := No_Alternate_Language;
507       Kind                : Source_Kind           := Spec;
508       Dependency          : Dependency_File_Kind  := Makefile;
509       Other_Part          : Source_Id             := No_Source;
510       Unit                : Name_Id               := No_Name;
511       Index               : Int                   := 0;
512       Locally_Removed     : Boolean               := False;
513       Replaced_By         : Source_Id             := No_Source;
514       File                : File_Name_Type        := No_File;
515       Display_File        : File_Name_Type        := No_File;
516       Path                : Path_Name_Type        := No_Path;
517       Display_Path        : Path_Name_Type        := No_Path;
518       Source_TS           : Time_Stamp_Type       := Empty_Time_Stamp;
519       Object_Project      : Project_Id            := No_Project;
520       Object_Exists       : Boolean               := True;
521       Object              : File_Name_Type        := No_File;
522       Current_Object_Path : Path_Name_Type        := No_Path;
523       Object_Path         : Path_Name_Type        := No_Path;
524
525       Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
526       --  Object file time stamp
527
528       Dep_Name : File_Name_Type := No_File;
529       --  Dependency file simple name
530
531       Current_Dep_Path : Path_Name_Type := No_Path;
532
533       Dep_Path : Path_Name_Type := No_Path;
534       --  Dependency full path name
535
536       Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
537       --  Dependency file time stamp
538
539       Switches         : File_Name_Type  := No_File;
540       Switches_Path    : Path_Name_Type  := No_Path;
541       Switches_TS      : Time_Stamp_Type := Empty_Time_Stamp;
542       Naming_Exception : Boolean         := False;
543       Next_In_Sources  : Source_Id       := No_Source;
544       Next_In_Project  : Source_Id       := No_Source;
545       Next_In_Lang     : Source_Id       := No_Source;
546    end record;
547
548    No_Source_Data : constant Source_Data :=
549                       (Project             => No_Project,
550                        Language_Name       => No_Name,
551                        Language            => No_Language_Index,
552                        Alternate_Languages => No_Alternate_Language,
553                        Kind                => Spec,
554                        Dependency          => Makefile,
555                        Other_Part          => No_Source,
556                        Unit                => No_Name,
557                        Index               => 0,
558                        Locally_Removed     => False,
559                        Replaced_By         => No_Source,
560                        File                => No_File,
561                        Display_File        => No_File,
562                        Path                => No_Path,
563                        Display_Path        => No_Path,
564                        Source_TS           => Empty_Time_Stamp,
565                        Object_Project      => No_Project,
566                        Object_Exists       => True,
567                        Object              => No_File,
568                        Current_Object_Path => No_Path,
569                        Object_Path         => No_Path,
570                        Object_TS           => Empty_Time_Stamp,
571                        Dep_Name            => No_File,
572                        Current_Dep_Path    => No_Path,
573                        Dep_Path            => No_Path,
574                        Dep_TS              => Empty_Time_Stamp,
575                        Switches            => No_File,
576                        Switches_Path       => No_Path,
577                        Switches_TS         => Empty_Time_Stamp,
578                        Naming_Exception    => False,
579                        Next_In_Sources     => No_Source,
580                        Next_In_Project     => No_Source,
581                        Next_In_Lang        => No_Source);
582
583    package Source_Data_Table is new GNAT.Dynamic_Tables
584      (Table_Component_Type => Source_Data,
585       Table_Index_Type     => Source_Id,
586       Table_Low_Bound      => 1,
587       Table_Initial        => 1000,
588       Table_Increment      => 100);
589    --  The table for the sources
590
591    package Source_Paths_Htable is new Simple_HTable
592      (Header_Num => Header_Num,
593       Element    => Source_Id,
594       No_Element => No_Source,
595       Key        => Path_Name_Type,
596       Hash       => Hash,
597       Equal      => "=");
598    --  Mapping of source paths to source ids
599
600    type Verbosity is (Default, Medium, High);
601    --  Verbosity when parsing GNAT Project Files
602    --    Default is default (very quiet, if no errors).
603    --    Medium is more verbose.
604    --    High is extremely verbose.
605
606    Current_Verbosity : Verbosity := Default;
607    --  The current value of the verbosity the project files are parsed with
608
609    type Lib_Kind is (Static, Dynamic, Relocatable);
610
611    type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
612    --  Type to specify the symbol policy, when symbol control is supported.
613    --  See full explanation about this type in package Symbols.
614    --    Autonomous: Create a symbol file without considering any reference
615    --    Compliant:  Try to be as compatible as possible with an existing ref
616    --    Controlled: Fail if symbols are not the same as those in the reference
617    --    Restricted: Restrict the symbols to those in the symbol file
618    --    Direct:     The symbol file is used as is
619
620    type Symbol_Record is record
621       Symbol_File   : Path_Name_Type := No_Path;
622       Reference     : Path_Name_Type := No_Path;
623       Symbol_Policy : Policy  := Autonomous;
624    end record;
625    --  Type to keep the symbol data to be used when building a shared library
626
627    No_Symbols : constant Symbol_Record :=
628      (Symbol_File   => No_Path,
629       Reference     => No_Path,
630       Symbol_Policy => Autonomous);
631    --  The default value of the symbol data
632
633    function Image (Casing : Casing_Type) return String;
634    --  Similar to 'Image (but avoid use of this attribute in compiler)
635
636    function Value (Image : String) return Casing_Type;
637    --  Similar to 'Value (but avoid use of this attribute in compiler)
638    --  Raises Constraint_Error if not a Casing_Type image.
639
640    --  Declarations for gprmake:
641
642    First_Language_Index        : constant Language_Index := 1;
643    First_Language_Indexes_Last : constant Language_Index := 5;
644
645    Ada_Language_Index         : constant Language_Index :=
646                                   First_Language_Index;
647    C_Language_Index           : constant Language_Index :=
648                                   Ada_Language_Index + 1;
649    C_Plus_Plus_Language_Index : constant Language_Index :=
650                                   C_Language_Index + 1;
651
652    Last_Language_Index : Language_Index := No_Language_Index;
653
654    subtype First_Language_Indexes is Language_Index
655       range First_Language_Index .. First_Language_Indexes_Last;
656
657    package Language_Indexes is new System.HTable.Simple_HTable
658      (Header_Num => Header_Num,
659       Element    => Language_Index,
660       No_Element => No_Language_Index,
661       Key        => Name_Id,
662       Hash       => Hash,
663       Equal      => "=");
664    --  Mapping of language names to language indexes
665
666    package Language_Names is new Table.Table
667      (Table_Component_Type => Name_Id,
668       Table_Index_Type     => Language_Index,
669       Table_Low_Bound      => 1,
670       Table_Initial        => 4,
671       Table_Increment      => 100,
672       Table_Name           => "Prj.Language_Names");
673    --  The table for the name of programming languages
674
675    procedure Add_Language_Name (Name : Name_Id);
676
677    procedure Display_Language_Name (Language : Language_Index);
678
679    type Languages_In_Project is array (First_Language_Indexes) of Boolean;
680    --  Set of supported languages used in a project
681
682    No_Languages : constant Languages_In_Project := (others => False);
683    --  No supported languages are used
684
685    type Supp_Language_Index is new Nat;
686    No_Supp_Language_Index  : constant Supp_Language_Index := 0;
687
688    type Supp_Language is record
689       Index   : Language_Index := No_Language_Index;
690       Present : Boolean := False;
691       Next    : Supp_Language_Index := No_Supp_Language_Index;
692    end record;
693
694    package Present_Language_Table is new GNAT.Dynamic_Tables
695      (Table_Component_Type => Supp_Language,
696       Table_Index_Type     => Supp_Language_Index,
697       Table_Low_Bound      => 1,
698       Table_Initial        => 4,
699       Table_Increment      => 100);
700    --  The table for the presence of languages with an index that is outside
701    --  of First_Language_Indexes.
702
703    type Impl_Suffix_Array is array (First_Language_Indexes) of File_Name_Type;
704    --  Suffixes for the non spec sources of the different supported languages
705    --  in a project.
706
707    No_Impl_Suffixes : constant Impl_Suffix_Array := (others => No_File);
708    --  A default value for the non spec source suffixes
709
710    type Supp_Suffix is record
711       Index   : Language_Index      := No_Language_Index;
712       Suffix  : File_Name_Type      := No_File;
713       Next    : Supp_Language_Index := No_Supp_Language_Index;
714    end record;
715
716    package Supp_Suffix_Table is new GNAT.Dynamic_Tables
717      (Table_Component_Type => Supp_Suffix,
718       Table_Index_Type     => Supp_Language_Index,
719       Table_Low_Bound      => 1,
720       Table_Initial        => 4,
721       Table_Increment      => 100);
722    --  The table for the presence of languages with an index that is outside
723    --  of First_Language_Indexes.
724
725    type Lang_Kind is (GNU, Other);
726
727    type Language_Processing_Data is record
728       Compiler_Drivers     : Name_List_Index := No_Name_List;
729       Compiler_Paths       : Name_Id         := No_Name;
730       Compiler_Kinds       : Lang_Kind       := GNU;
731       Dependency_Options   : Name_List_Index := No_Name_List;
732       Compute_Dependencies : Name_List_Index := No_Name_List;
733       Include_Options      : Name_List_Index := No_Name_List;
734       Binder_Drivers       : Name_Id         := No_Name;
735       Binder_Driver_Paths  : Name_Id         := No_Name;
736    end record;
737
738    Default_Language_Processing_Data :
739      constant Language_Processing_Data :=
740        (Compiler_Drivers     => No_Name_List,
741         Compiler_Paths       => No_Name,
742         Compiler_Kinds       => GNU,
743         Dependency_Options   => No_Name_List,
744         Compute_Dependencies => No_Name_List,
745         Include_Options      => No_Name_List,
746         Binder_Drivers       => No_Name,
747         Binder_Driver_Paths  => No_Name);
748
749    type First_Language_Processing_Data is
750      array (First_Language_Indexes) of Language_Processing_Data;
751
752    Default_First_Language_Processing_Data :
753       constant First_Language_Processing_Data :=
754                  (others => Default_Language_Processing_Data);
755
756    type Supp_Language_Data is record
757       Index : Language_Index := No_Language_Index;
758       Data  : Language_Processing_Data := Default_Language_Processing_Data;
759       Next  : Supp_Language_Index := No_Supp_Language_Index;
760    end record;
761
762    package Supp_Language_Table is new GNAT.Dynamic_Tables
763      (Table_Component_Type => Supp_Language_Data,
764       Table_Index_Type     => Supp_Language_Index,
765       Table_Low_Bound      => 1,
766       Table_Initial        => 4,
767       Table_Increment      => 100);
768    --  The table for language data when there are more languages than
769    --  in First_Language_Indexes.
770
771    type Other_Source_Id is new Nat;
772    No_Other_Source : constant Other_Source_Id := 0;
773
774    type Other_Source is record
775       Language         : Language_Index;       --  language of the source
776       File_Name        : File_Name_Type;       --  source file simple name
777       Path_Name        : Path_Name_Type;       --  source full path name
778       Source_TS        : Time_Stamp_Type;      --  source file time stamp
779       Object_Name      : File_Name_Type;       --  object file simple name
780       Object_Path      : Path_Name_Type;       --  object full path name
781       Object_TS        : Time_Stamp_Type;      --  object file time stamp
782       Dep_Name         : File_Name_Type;       --  dependency file simple name
783       Dep_Path         : Path_Name_Type;       --  dependency full path name
784       Dep_TS           : Time_Stamp_Type;      --  dependency file time stamp
785       Naming_Exception : Boolean := False;     --  True if a naming exception
786       Next             : Other_Source_Id := No_Other_Source;
787    end record;
788    --  Data for a source in a language other than Ada
789
790    package Other_Source_Table is new GNAT.Dynamic_Tables
791      (Table_Component_Type => Other_Source,
792       Table_Index_Type     => Other_Source_Id,
793       Table_Low_Bound      => 1,
794       Table_Initial        => 200,
795       Table_Increment      => 100);
796    --  The table for sources of languages other than Ada
797
798    --  The following record contains data for a naming scheme
799
800    type Naming_Data is record
801
802       Dot_Replacement : File_Name_Type := No_File;
803       --  The string to replace '.' in the source file name (for Ada)
804
805       Dot_Repl_Loc : Source_Ptr := No_Location;
806
807       Casing : Casing_Type := All_Lower_Case;
808       --  The casing of the source file name (for Ada)
809
810       Spec_Suffix : Array_Element_Id := No_Array_Element;
811       --  The string to append to the unit name for the
812       --  source file name of a spec.
813       --  Indexed by the programming language.
814
815       Ada_Spec_Suffix_Loc : Source_Ptr := No_Location;
816
817       Body_Suffix : Array_Element_Id := No_Array_Element;
818       --  The string to append to the unit name for the
819       --  source file name of a body.
820       --  Indexed by the programming language.
821
822       Ada_Body_Suffix_Loc : Source_Ptr := No_Location;
823
824       Separate_Suffix : File_Name_Type := No_File;
825       --  String to append to unit name for source file name of an Ada subunit
826
827       Sep_Suffix_Loc : Source_Ptr := No_Location;
828       --  Position in the project file source where Separate_Suffix is defined
829
830       Specs : Array_Element_Id := No_Array_Element;
831       --  An associative array mapping individual specs to source file names
832       --  This is specific to Ada.
833
834       Bodies : Array_Element_Id := No_Array_Element;
835       --  An associative array mapping individual bodies to source file names
836       --  This is specific to Ada.
837
838       Specification_Exceptions : Array_Element_Id := No_Array_Element;
839       --  An associative array listing spec file names that do not have the
840       --  spec suffix. Not used by Ada. Indexed by programming language name.
841
842       Implementation_Exceptions : Array_Element_Id := No_Array_Element;
843       --  An associative array listing body file names that do not have the
844       --  body suffix. Not used by Ada. Indexed by programming language name.
845
846       --  For gprmake:
847
848       Impl_Suffixes : Impl_Suffix_Array   := No_Impl_Suffixes;
849       Supp_Suffixes : Supp_Language_Index := No_Supp_Language_Index;
850    end record;
851
852    function Spec_Suffix_Of
853      (In_Tree  : Project_Tree_Ref;
854       Language : String;
855       Naming   : Naming_Data) return String;
856
857    function Spec_Suffix_Id_Of
858      (In_Tree  : Project_Tree_Ref;
859       Language : String;
860       Naming   : Naming_Data) return File_Name_Type;
861
862    procedure Set_Spec_Suffix
863      (In_Tree  : Project_Tree_Ref;
864       Language : String;
865       Naming   : in out Naming_Data;
866       Suffix   : File_Name_Type);
867
868    function Body_Suffix_Id_Of
869      (In_Tree  : Project_Tree_Ref;
870       Language : String;
871       Naming   : Naming_Data) return File_Name_Type;
872
873    function Body_Suffix_Of
874      (In_Tree  : Project_Tree_Ref;
875       Language : String;
876       Naming   : Naming_Data) return String;
877
878    procedure Set_Body_Suffix
879      (In_Tree  : Project_Tree_Ref;
880       Language : String;
881       Naming   : in out Naming_Data;
882       Suffix   : File_Name_Type);
883
884    function Objects_Exist_For
885      (Language : String;
886       In_Tree  : Project_Tree_Ref) return Boolean;
887
888    function Standard_Naming_Data
889      (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
890    pragma Inline (Standard_Naming_Data);
891    --  The standard GNAT naming scheme when Tree is No_Project_Tree.
892    --  Otherwise, return the default naming scheme for the project tree Tree,
893    --  which must have been Initialized.
894
895    function Same_Naming_Scheme
896      (Left, Right : Naming_Data) return Boolean;
897    --  Returns True if Left and Right are the same naming scheme
898    --  not considering Specs and Bodies.
899
900    type Project_List is new Nat;
901    Empty_Project_List : constant Project_List := 0;
902    --  A list of project files
903
904    type Project_Element is record
905       Project : Project_Id   := No_Project;
906       Next    : Project_List := Empty_Project_List;
907    end record;
908    --  Element in a list of project files. Next is the id of the next
909    --  project file in the list.
910
911    package Project_List_Table is new GNAT.Dynamic_Tables
912      (Table_Component_Type => Project_Element,
913       Table_Index_Type     => Project_List,
914       Table_Low_Bound      => 1,
915       Table_Initial        => 100,
916       Table_Increment      => 100);
917    --  The table that contains the lists of project files
918
919    type Project_Configuration is record
920          Run_Path_Option          : Name_List_Index := No_Name_List;
921          --  The option to use when linking to specify the path where to look
922          --  for libraries.
923
924          Executable_Suffix        : Name_Id         := No_Name;
925          --  The suffix of executables, when specified in the configuration or
926          --  in package Builder of the main project. When this is not
927          --  specified, the executable suffix is the default for the platform.
928
929          --  Linking
930
931          Linker                   : Path_Name_Type  := No_Path;
932          --  Path name of the linker driver; specified in the configuration
933          --  or in the package Builder of the main project.
934
935          Minimum_Linker_Options   : Name_List_Index := No_Name_List;
936          --  The minimum options for the linker driver; specified in the
937          --  configuration.
938
939          Linker_Executable_Option : Name_List_Index := No_Name_List;
940          --  The option(s) to indicate the name of the executable in the
941          --  linker command. Specified in the configuration. When not
942          --  specified, default to -o <executable name>.
943
944          Linker_Lib_Dir_Option    : Name_Id         := No_Name;
945          --  The option to specify where to find a library for linking.
946          --  Specified in the configuration. When not specified, defaults to
947          --  "-L".
948
949          Linker_Lib_Name_Option   : Name_Id         := No_Name;
950          --  The option to specify the name of a library for linking.
951          --  Specified in the configuration. When not specified, defaults to
952          --  "-l".
953
954          --  Libraries
955
956          Library_Builder          : Path_Name_Type  := No_Path;
957          --  The executable to build library. Specified in the configuration.
958
959          Lib_Support              : Library_Support := None;
960          --  The level of library support. Specified in the configuration.
961          --  Support is none, static libraries only or both static and shared
962          --  libraries.
963
964          --  Archives
965
966          Archive_Builder          : Name_List_Index := No_Name_List;
967          --  The name of the executable to build archives, with the minimum
968          --  switches. Specified in the configuration.
969
970          Archive_Indexer          : Name_List_Index := No_Name_List;
971          --  The name of the executable to index archives, with the minimum
972          --  switches. Specified in the configuration.
973
974          Archive_Suffix           : File_Name_Type  := No_File;
975          --  The suffix of archives. Specified in the configuration. When not
976          --  specified, defaults to ".a".
977
978          Lib_Partial_Linker       : Name_List_Index := No_Name_List;
979
980          --  Shared libraries
981
982          Shared_Lib_Prefix        : File_Name_Type  := No_File;
983          --  Part of a shared library file name that precedes the name of the
984          --  library. Specified in the configuration. When not specified,
985          --  defaults to "lib".
986
987          Shared_Lib_Suffix        : File_Name_Type  := No_File;
988          --  Suffix of shared libraries, after the library name in the shared
989          --  library name. Specified in the configuration. When not specified,
990          --  default to ".so".
991
992          Shared_Lib_Min_Options   : Name_List_Index := No_Name_List;
993          --
994
995          Lib_Version_Options      : Name_List_Index := No_Name_List;
996          --
997
998          Symbolic_Link_Supported  : Boolean         := False;
999          --
1000
1001          Lib_Maj_Min_Id_Supported : Boolean         := False;
1002          --
1003
1004          Auto_Init_Supported      : Boolean         := False;
1005          --
1006    end record;
1007
1008    Default_Project_Config : constant Project_Configuration :=
1009        (Run_Path_Option          => No_Name_List,
1010         Executable_Suffix        => No_Name,
1011         Linker                   => No_Path,
1012         Minimum_Linker_Options   => No_Name_List,
1013         Linker_Executable_Option => No_Name_List,
1014         Linker_Lib_Dir_Option    => No_Name,
1015         Linker_Lib_Name_Option   => No_Name,
1016         Library_Builder          => No_Path,
1017         Lib_Support              => None,
1018         Archive_Builder          => No_Name_List,
1019         Archive_Indexer          => No_Name_List,
1020         Archive_Suffix           => No_File,
1021         Lib_Partial_Linker       => No_Name_List,
1022         Shared_Lib_Prefix        => No_File,
1023         Shared_Lib_Suffix        => No_File,
1024         Shared_Lib_Min_Options   => No_Name_List,
1025         Lib_Version_Options      => No_Name_List,
1026         Symbolic_Link_Supported  => False,
1027         Lib_Maj_Min_Id_Supported => False,
1028         Auto_Init_Supported      => False);
1029
1030    --  The following record describes a project file representation
1031
1032    type Project_Data is record
1033       Externally_Built : Boolean := False;
1034       --  True if the project is externally built. In such case, the Project
1035       --  Manager will not modify anything in this project.
1036
1037       Languages        : Name_List_Index := No_Name_List;
1038       --  The list of languages of the sources of this project
1039
1040       Config           : Project_Configuration;
1041
1042       First_Referred_By : Project_Id := No_Project;
1043       --  The project, if any, that was the first to be known as importing or
1044       --  extending this project
1045
1046       Name : Name_Id := No_Name;
1047       --  The name of the project
1048
1049       Display_Name : Name_Id := No_Name;
1050       --  The name of the project with the spelling of its declaration
1051
1052       Path_Name : Path_Name_Type := No_Path;
1053       --  The path name of the project file
1054
1055       Display_Path_Name : Path_Name_Type := No_Path;
1056       --  The path name used for display purposes. May be different from
1057       --  Path_Name for platforms where the file names are case-insensitive.
1058
1059       Virtual : Boolean := False;
1060       --  True for virtual extending projects
1061
1062       Location : Source_Ptr := No_Location;
1063       --  The location in the project file source of the reserved word project
1064
1065       Mains : String_List_Id := Nil_String;
1066       --  List of mains specified by attribute Main
1067
1068       Directory : Path_Name_Type := No_Path;
1069       --  Path name of the directory where the project file resides
1070
1071       Display_Directory : Path_Name_Type := No_Path;
1072       --  The path name of the project directory, for display purposes. May be
1073       --  different from Directory for platforms where the file names are
1074       --  case-insensitive.
1075
1076       Dir_Path : String_Access;
1077       --  Same as Directory, but as an access to String
1078
1079       Library : Boolean := False;
1080       --  True if this is a library project
1081
1082       Library_Dir : Path_Name_Type := No_Path;
1083       --  If a library project, path name of the directory where the library
1084       --  resides.
1085
1086       Display_Library_Dir : Path_Name_Type := No_Path;
1087       --  The path name of the library directory, for display purposes. May be
1088       --  different from Library_Dir for platforms where the file names are
1089       --  case-insensitive.
1090
1091       Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
1092       --  The timestamp of a library file in a library project
1093
1094       Library_Src_Dir : Path_Name_Type := No_Path;
1095       --  If a Stand-Alone Library project, path name of the directory where
1096       --  the sources of the interfaces of the library are copied. By default,
1097       --  if attribute Library_Src_Dir is not specified, sources of the
1098       --  interfaces are not copied anywhere.
1099
1100       Display_Library_Src_Dir : Path_Name_Type := No_Path;
1101       --  The path name of the library source directory, for display purposes.
1102       --  May be different from Library_Src_Dir for platforms where the file
1103       --  names are case-insensitive.
1104
1105       Library_ALI_Dir : Path_Name_Type := No_Path;
1106       --  In a library project, path name of the directory where the ALI files
1107       --  are copied. If attribute Library_ALI_Dir is not specified, ALI files
1108       --  are copied in the Library_Dir.
1109
1110       Display_Library_ALI_Dir : Path_Name_Type := No_Path;
1111       --  The path name of the library ALI directory, for display purposes. May
1112       --  be different from Library_ALI_Dir for platforms where the file names
1113       --  are case-insensitive.
1114
1115       Library_Name : Name_Id := No_Name;
1116       --  If a library project, name of the library
1117
1118       Library_Kind : Lib_Kind := Static;
1119       --  If a library project, kind of library
1120
1121       Lib_Internal_Name : Name_Id := No_Name;
1122       --  If a library project, internal name store inside the library
1123
1124       Standalone_Library : Boolean := False;
1125       --  Indicate that this is a Standalone Library Project File
1126
1127       Lib_Interface_ALIs : String_List_Id := Nil_String;
1128       --  For Standalone Library Project Files, indicate the list of Interface
1129       --  ALI files.
1130
1131       Lib_Auto_Init : Boolean := False;
1132       --  For non static Stand-Alone Library Project Files, indicate if
1133       --  the library initialisation should be automatic.
1134
1135       Libgnarl_Needed : Yes_No_Unknown := Unknown;
1136       --  Set to True when libgnarl is needed to link
1137
1138       Symbol_Data : Symbol_Record := No_Symbols;
1139       --  Symbol file name, reference symbol file name, symbol policy
1140
1141       Ada_Sources : String_List_Id := Nil_String;
1142       --  The list of all the Ada source file names (gnatmake only).
1143
1144       Sources                 : String_List_Id := Nil_String;
1145       --  Identical to Ada_Sources. For upward compatibility of GPS.
1146
1147       First_Source : Source_Id := No_Source;
1148       Last_Source  : Source_Id := No_Source;
1149       --  Head and tail of the list of sources
1150
1151       Unit_Based_Language_Name  : Name_Id := No_Name;
1152       Unit_Based_Language_Index : Language_Index := No_Language_Index;
1153       --  The name and index, if any, of the unit-based language of some
1154       --  sources of the project. There may be only one unit-based language
1155       --  in one project.
1156
1157       Imported_Directories_Switches : Argument_List_Access := null;
1158       --  List of the source search switches (-I<source dir>) to be used when
1159       --  compiling.
1160
1161       Include_Path : String_Access := null;
1162       --  Value of the environment variable to indicate the source search path,
1163       --  instead of a list of switches (Imported_Directories_Switches).
1164
1165       Include_Path_File : Path_Name_Type := No_Path;
1166       --  The path name of the of the source search directory file
1167
1168       Include_Data_Set : Boolean := False;
1169       --  Set True when Imported_Directories_Switches or Include_Path are set
1170
1171       Include_Language : Language_Index := No_Language_Index;
1172
1173       Source_Dirs : String_List_Id := Nil_String;
1174       --  The list of all the source directories
1175
1176       Known_Order_Of_Source_Dirs : Boolean := True;
1177       --  False, if there is any /** in the Source_Dirs, because in this case
1178       --  the ordering of the source subdirs depend on the OS. If True,
1179       --  duplicate file names in the same project file are allowed.
1180
1181       Object_Directory : Path_Name_Type := No_Path;
1182       --  The path name of the object directory of this project file
1183
1184       Display_Object_Dir : Path_Name_Type := No_Path;
1185       --  The path name of the object directory, for display purposes. May be
1186       --  different from Object_Directory for platforms where the file names
1187       --  are case-insensitive.
1188
1189       Exec_Directory : Path_Name_Type := No_Path;
1190       --  The path name of the exec directory of this project file. Default is
1191       --  equal to Object_Directory.
1192
1193       Display_Exec_Dir : Path_Name_Type := No_Path;
1194       --  The path name of the exec directory, for display purposes. May be
1195       --  different from Exec_Directory for platforms where the file names are
1196       --  case-insensitive.
1197
1198       Extends : Project_Id := No_Project;
1199       --  The reference of the project file, if any, that this project file
1200       --  extends.
1201
1202       Extended_By : Project_Id := No_Project;
1203       --  The reference of the project file, if any, that extends this project
1204       --  file.
1205
1206       Naming : Naming_Data := Standard_Naming_Data;
1207       --  The naming scheme of this project file
1208
1209       First_Language_Processing : Language_Index := No_Language_Index;
1210       --  Comment needed ???
1211
1212       Decl : Declarations := No_Declarations;
1213       --  The declarations (variables, attributes and packages) of this project
1214       --  file.
1215
1216       Imported_Projects : Project_List := Empty_Project_List;
1217       --  The list of all directly imported projects, if any
1218
1219       All_Imported_Projects : Project_List := Empty_Project_List;
1220       --  The list of all projects imported directly or indirectly, if any
1221
1222       Ada_Include_Path : String_Access := null;
1223       --  The cached value of ADA_INCLUDE_PATH for this project file. Do not
1224       --  use this field directly outside of the compiler, use
1225       --  Prj.Env.Ada_Include_Path instead.
1226
1227       Ada_Objects_Path : String_Access := null;
1228       --  The cached value of ADA_OBJECTS_PATH for this project file. Do not
1229       --  use this field directly outside of the compiler, use
1230       --  Prj.Env.Ada_Objects_Path instead.
1231
1232       Objects_Path                  : String_Access := null;
1233       --  ???
1234
1235       Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
1236       --  The cached value of the object path temp file (including library
1237       --  dirs) for this project file.
1238
1239       Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
1240       --  The cached value of the object path temp file (excluding library
1241       --  dirs) for this project file.
1242
1243       Config_File_Name : Path_Name_Type := No_Path;
1244       --  The path name of the configuration pragmas file, if any
1245
1246       Config_File_Temp : Boolean := False;
1247       --  An indication that the configuration pragmas file is a temporary file
1248       --  that must be deleted at the end.
1249
1250       Linker_Name                    : File_Name_Type  := No_File;
1251       --  Value of attribute Language_Processing'Linker in the project file
1252
1253       Linker_Path                    : Path_Name_Type  := No_Path;
1254       --  Path of linker when attribute Language_Processing'Linker is specified
1255
1256       Minimum_Linker_Options         : Name_List_Index := No_Name_List;
1257       --  List of options specified in attribute
1258       --  Language_Processing'Minimum_Linker_Options.
1259
1260       Config_Checked : Boolean := False;
1261       --  A flag to avoid checking repetitively the configuration pragmas file
1262
1263       Checked : Boolean := False;
1264       --  A flag to avoid checking repetitively the naming scheme of this
1265       --  project file.
1266
1267       Seen : Boolean := False;
1268       --  A flag to mark a project as "visited" to avoid processing the same
1269       --  project several time.
1270
1271       Need_To_Build_Lib : Boolean := False;
1272       --  Indicates that the library of a Library Project needs to be built or
1273       --  rebuilt.
1274
1275       Depth : Natural := 0;
1276       --  The maximum depth of a project in the project graph. Depth of main
1277       --  project is 0.
1278
1279       Unkept_Comments : Boolean := False;
1280       --  True if there are comments in the project sources that cannot be kept
1281       --  in the project tree.
1282
1283       --  For gprmake
1284
1285       Langs          : Languages_In_Project := No_Languages;
1286       Supp_Languages : Supp_Language_Index  := No_Supp_Language_Index;
1287       --  Indicate the different languages of the source of this project
1288
1289       Ada_Sources_Present   : Boolean := True;
1290       Other_Sources_Present : Boolean := True;
1291       First_Other_Source    : Other_Source_Id := No_Other_Source;
1292       Last_Other_Source     : Other_Source_Id := No_Other_Source;
1293       First_Lang_Processing : First_Language_Processing_Data :=
1294                                     Default_First_Language_Processing_Data;
1295       Supp_Language_Processing : Supp_Language_Index := No_Supp_Language_Index;
1296    end record;
1297
1298    function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
1299    --  Return the representation of an empty project in project Tree tree.
1300    --  The project tree Tree must have been Initialized and/or Reset.
1301
1302    function Is_Extending
1303      (Extending : Project_Id;
1304       Extended  : Project_Id;
1305       In_Tree   : Project_Tree_Ref) return Boolean;
1306
1307    function Is_A_Language
1308      (Tree          : Project_Tree_Ref;
1309       Data          : Project_Data;
1310       Language_Name : String) return Boolean;
1311
1312    function There_Are_Ada_Sources
1313      (In_Tree : Project_Tree_Ref;
1314       Project : Project_Id) return Boolean;
1315
1316    Project_Error : exception;
1317    --  Raised by some subprograms in Prj.Attr
1318
1319    package Project_Table is new GNAT.Dynamic_Tables (
1320      Table_Component_Type => Project_Data,
1321      Table_Index_Type     => Project_Id,
1322      Table_Low_Bound      => 1,
1323      Table_Initial        => 100,
1324      Table_Increment      => 100);
1325    --  The set of all project files
1326
1327    type Spec_Or_Body is
1328      (Specification, Body_Part);
1329
1330    type File_Name_Data is record
1331       Name         : File_Name_Type := No_File;
1332       Index        : Int        := 0;
1333       Display_Name : File_Name_Type := No_File;
1334       Path         : Path_Name_Type := No_Path;
1335       Display_Path : Path_Name_Type := No_Path;
1336       Project      : Project_Id := No_Project;
1337       Needs_Pragma : Boolean    := False;
1338    end record;
1339    --  File and Path name of a spec or body
1340
1341    type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
1342
1343    type Unit_Index is new Nat;
1344    No_Unit_Index : constant Unit_Index := 0;
1345    type Unit_Data is record
1346       Name       : Name_Id    := No_Name;
1347       File_Names : File_Names_Data;
1348    end record;
1349    --  Name and File and Path names of a unit, with a reference to its
1350    --  GNAT Project File(s).
1351
1352    package Unit_Table is new GNAT.Dynamic_Tables
1353      (Table_Component_Type => Unit_Data,
1354       Table_Index_Type     => Unit_Index,
1355       Table_Low_Bound      => 1,
1356       Table_Initial        => 100,
1357       Table_Increment      => 100);
1358    --  Table of all units in a project tree
1359
1360    package Units_Htable is new Simple_HTable
1361      (Header_Num => Header_Num,
1362       Element    => Unit_Index,
1363       No_Element => No_Unit_Index,
1364       Key        => Name_Id,
1365       Hash       => Hash,
1366       Equal      => "=");
1367    --  Mapping of unit names to indexes in the Units table
1368
1369    type Unit_Project is record
1370       Unit    : Unit_Index := No_Unit_Index;
1371       Project : Project_Id := No_Project;
1372    end record;
1373
1374    No_Unit_Project : constant Unit_Project := (No_Unit_Index, No_Project);
1375
1376    package Files_Htable is new Simple_HTable
1377      (Header_Num => Header_Num,
1378       Element    => Unit_Project,
1379       No_Element => No_Unit_Project,
1380       Key        => File_Name_Type,
1381       Hash       => Hash,
1382       Equal      => "=");
1383    --  Mapping of file names to indexes in the Units table
1384
1385    type Private_Project_Tree_Data is private;
1386    --  Data for a project tree that is used only by the Project Manager
1387
1388    type Project_Tree_Data is
1389       record
1390          --  General
1391
1392          Default_Language         : Name_Id         := No_Name;
1393          --  The name of the language of the sources of a project, when
1394          --  attribute Languages is not specified.
1395
1396          Config                   : Project_Configuration;
1397
1398          --  Languages and sources of the project
1399
1400          First_Language           : Language_Index  := No_Language_Index;
1401          --
1402
1403          First_Source             : Source_Id := No_Source;
1404          --
1405
1406          --  Tables
1407
1408          Languages_Data           : Language_Data_Table.Instance;
1409          Name_Lists               : Name_List_Table.Instance;
1410          String_Elements          : String_Element_Table.Instance;
1411          Variable_Elements        : Variable_Element_Table.Instance;
1412          Array_Elements           : Array_Element_Table.Instance;
1413          Arrays                   : Array_Table.Instance;
1414          Packages                 : Package_Table.Instance;
1415          Project_Lists            : Project_List_Table.Instance;
1416          Projects                 : Project_Table.Instance;
1417          Sources                  : Source_Data_Table.Instance;
1418          Alt_Langs                : Alternate_Language_Table.Instance;
1419          Units                    : Unit_Table.Instance;
1420          Units_HT                 : Units_Htable.Instance;
1421          Files_HT                 : Files_Htable.Instance;
1422          Source_Paths_HT          : Source_Paths_Htable.Instance;
1423
1424          --  For gprmake:
1425
1426          Present_Languages : Present_Language_Table.Instance;
1427          Supp_Suffixes     : Supp_Suffix_Table.Instance;
1428          Supp_Languages    : Supp_Language_Table.Instance;
1429          Other_Sources     : Other_Source_Table.Instance;
1430
1431          --  Private part
1432
1433          Private_Part             : Private_Project_Tree_Data;
1434       end record;
1435    --  Data for a project tree
1436
1437    type Put_Line_Access is access procedure
1438      (Line    : String;
1439       Project : Project_Id;
1440       In_Tree : Project_Tree_Ref);
1441    --  Use to customize error reporting in Prj.Proc and Prj.Nmsc
1442
1443    procedure Expect (The_Token : Token_Type; Token_Image : String);
1444    --  Check that the current token is The_Token. If it is not, then
1445    --  output an error message.
1446
1447    procedure Initialize (Tree : Project_Tree_Ref);
1448    --  This procedure must be called before using any services from the Prj
1449    --  hierarchy. Namet.Initialize must be called before Prj.Initialize.
1450
1451    procedure Reset (Tree : Project_Tree_Ref);
1452    --  This procedure resets all the tables that are used when processing a
1453    --  project file tree. Initialize must be called before the call to Reset.
1454
1455    procedure Register_Default_Naming_Scheme
1456      (Language            : Name_Id;
1457       Default_Spec_Suffix : File_Name_Type;
1458       Default_Body_Suffix : File_Name_Type;
1459       In_Tree             : Project_Tree_Ref);
1460    --  Register the default suffixes for a given language. These extensions
1461    --  will be ignored if the user has specified a new naming scheme in a
1462    --  project file.
1463    --
1464    --  Otherwise, this information will be automatically added to Naming_Data
1465    --  when a project is processed, in the lists Spec_Suffix and Body_Suffix.
1466
1467    generic
1468       type State is limited private;
1469       with procedure Action
1470         (Project    : Project_Id;
1471          With_State : in out State);
1472    procedure For_Every_Project_Imported
1473      (By         : Project_Id;
1474       In_Tree    : Project_Tree_Ref;
1475       With_State : in out State);
1476    --  Call Action for each project imported directly or indirectly by project
1477    --  By. Action is called according to the order of importation: if A
1478    --  imports B, directly or indirectly, Action will be called for A before
1479    --  it is called for B. If two projects import each other directly or
1480    --  indirectly (using at least one "limited with"), it is not specified
1481    --  for which of these two projects Action will be called first. Projects
1482    --  that are extended by other projects are not considered. With_State may
1483    --  be used by Action to choose a behavior or to report some global result.
1484
1485    function Extend_Name
1486      (File        : File_Name_Type;
1487       With_Suffix : String) return File_Name_Type;
1488    --  Replace the extension of File with With_Suffix
1489
1490    function Object_Name
1491      (Source_File_Name : File_Name_Type) return File_Name_Type;
1492    --  Returns the object file name corresponding to a source file name
1493
1494    function Dependency_Name
1495      (Source_File_Name : File_Name_Type;
1496       Dependency       : Dependency_File_Kind) return File_Name_Type;
1497    --  Returns the dependency file name corresponding to a source file name
1498
1499    function Switches_Name
1500      (Source_File_Name : File_Name_Type) return File_Name_Type;
1501    --  Returns the switches file name corresponding to a source file name
1502
1503    --  For gprmake
1504
1505    function Body_Suffix_Of
1506      (Language   : Language_Index;
1507       In_Project : Project_Data;
1508       In_Tree    : Project_Tree_Ref) return String;
1509    --  Returns the suffix of sources of language Language in project In_Project
1510    --  in project tree In_Tree.
1511
1512    function Is_Present
1513      (Language   : Language_Index;
1514       In_Project : Project_Data;
1515       In_Tree    : Project_Tree_Ref) return Boolean;
1516    --  Return True when Language is one of the languages used in
1517    --  project In_Project.
1518
1519    procedure Set
1520      (Language   : Language_Index;
1521       Present    : Boolean;
1522       In_Project : in out Project_Data;
1523       In_Tree    : Project_Tree_Ref);
1524    --  Indicate if Language is or not a language used in project In_Project
1525
1526    function Language_Processing_Data_Of
1527      (Language   : Language_Index;
1528       In_Project : Project_Data;
1529       In_Tree    : Project_Tree_Ref) return Language_Processing_Data;
1530    --  Return the Language_Processing_Data for language Language in project
1531    --  In_Project. Return the default when no Language_Processing_Data are
1532    --  defined for the language.
1533
1534    procedure Set
1535      (Language_Processing : Language_Processing_Data;
1536       For_Language        : Language_Index;
1537       In_Project          : in out Project_Data;
1538       In_Tree             : Project_Tree_Ref);
1539    --  Set the Language_Processing_Data for language Language in project
1540    --  In_Project.
1541
1542    function Suffix_Of
1543      (Language   : Language_Index;
1544       In_Project : Project_Data;
1545       In_Tree    : Project_Tree_Ref) return File_Name_Type;
1546    --  Return the suffix for language Language in project In_Project. Return
1547    --  No_Name when no suffix is defined for the language.
1548
1549    procedure Set
1550      (Suffix       : File_Name_Type;
1551       For_Language : Language_Index;
1552       In_Project   : in out Project_Data;
1553       In_Tree      : Project_Tree_Ref);
1554    --  Set the suffix for language Language in project In_Project
1555
1556    ----------------
1557    -- Temp Files --
1558    ----------------
1559
1560    procedure Record_Temp_File (Path : Path_Name_Type);
1561    --  Record the path of a newly created temporary file, so that it can be
1562    --  deleted later.
1563
1564    procedure Delete_All_Temp_Files;
1565    --  Delete all recorded temporary files
1566
1567 private
1568
1569    All_Packages : constant String_List_Access := null;
1570
1571    No_Project_Tree : constant Project_Tree_Ref := null;
1572
1573    Ignored : constant Variable_Kind := Single;
1574
1575    Nil_Variable_Value : constant Variable_Value :=
1576      (Project  => No_Project,
1577       Kind     => Undefined,
1578       Location => No_Location,
1579       Default  => False);
1580
1581    Virtual_Prefix : constant String := "v$";
1582    --  The prefix for virtual extending projects. Because of the '$', which is
1583    --  normally forbidden for project names, there cannot be any name clash.
1584
1585    Empty_Name : Name_Id;
1586    --  Name_Id for an empty name (no characters). Initialized by the call
1587    --  to procedure Initialize.
1588
1589    procedure Add_To_Buffer
1590      (S    : String;
1591       To   : in out String_Access;
1592       Last : in out Natural);
1593    --  Append a String to the Buffer
1594
1595    type Naming_Id is new Nat;
1596
1597    package Naming_Table is new GNAT.Dynamic_Tables
1598      (Table_Component_Type => Naming_Data,
1599       Table_Index_Type     => Naming_Id,
1600       Table_Low_Bound      => 1,
1601       Table_Initial        => 5,
1602       Table_Increment      => 100);
1603    --  Comment ???
1604
1605    package Path_File_Table is new GNAT.Dynamic_Tables
1606      (Table_Component_Type => Path_Name_Type,
1607       Table_Index_Type     => Natural,
1608       Table_Low_Bound      => 1,
1609       Table_Initial        => 50,
1610       Table_Increment      => 100);
1611    --  Table storing all the temp path file names.
1612    --  Used by Delete_All_Path_Files.
1613
1614    package Source_Path_Table is new GNAT.Dynamic_Tables
1615      (Table_Component_Type => Name_Id,
1616       Table_Index_Type     => Natural,
1617       Table_Low_Bound      => 1,
1618       Table_Initial        => 50,
1619       Table_Increment      => 100);
1620    --  A table to store the source dirs before creating the source path file
1621
1622    package Object_Path_Table is new GNAT.Dynamic_Tables
1623      (Table_Component_Type => Path_Name_Type,
1624       Table_Index_Type     => Natural,
1625       Table_Low_Bound      => 1,
1626       Table_Initial        => 50,
1627       Table_Increment      => 100);
1628    --  A table to store the object dirs, before creating the object path file
1629
1630    type Private_Project_Tree_Data is record
1631       Namings        : Naming_Table.Instance;
1632       Path_Files     : Path_File_Table.Instance;
1633       Source_Paths   : Source_Path_Table.Instance;
1634       Object_Paths   : Object_Path_Table.Instance;
1635       Default_Naming : Naming_Data;
1636    end record;
1637    --  Type to represent the part of a project tree which is private to the
1638    --  Project Manager.
1639
1640 end Prj;