OSDN Git Service

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