OSDN Git Service

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