OSDN Git Service

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