OSDN Git Service

2007-04-20 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 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  The following package declares the data types for GNAT project.
28 --  These data types may be used by GNAT Project-aware tools.
29
30 --  Children of these package implements various services on these data types.
31 --  See in particular Prj.Pars and Prj.Env.
32
33 with Casing; use Casing;
34 with Namet;  use Namet;
35 with Scans;  use Scans;
36 with Table;
37 with Types;  use Types;
38
39 with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
40 with GNAT.Dynamic_Tables;
41 with GNAT.OS_Lib;          use GNAT.OS_Lib;
42
43 with System.HTable;
44
45 package Prj is
46
47    All_Packages : constant String_List_Access;
48    --  Default value of parameter Packages of procedures Parse, in Prj.Pars and
49    --  Prj.Part, indicating that all packages should be checked.
50
51    type Project_Tree_Data;
52    type Project_Tree_Ref is access all Project_Tree_Data;
53    --  Reference to a project tree.
54    --  Several project trees may exist in memory at the same time.
55
56    No_Project_Tree : constant Project_Tree_Ref;
57
58    function Default_Ada_Spec_Suffix return File_Name_Type;
59    pragma Inline (Default_Ada_Spec_Suffix);
60    --  The Name_Id for the standard GNAT suffix for Ada spec source file
61    --  name ".ads". Initialized by Prj.Initialize.
62
63    function Default_Ada_Body_Suffix return File_Name_Type;
64    pragma Inline (Default_Ada_Body_Suffix);
65    --  The Name_Id for the standard GNAT suffix for Ada body source file
66    --  name ".adb". Initialized by Prj.Initialize.
67
68    function Slash return File_Name_Type;
69    pragma Inline (Slash);
70    --  "/", used as the path of locally removed files
71
72    Project_File_Extension : String := ".gpr";
73    --  The standard project file name extension. It is not a constant, because
74    --  Canonical_Case_File_Name is called on this variable in the body of Prj.
75
76    type Error_Warning is (Silent, Warning, Error);
77    --  Severity of some situations, such as: no Ada sources in a project where
78    --  Ada is one of the language.
79    --
80    --  When the situation occurs, the behaviour depends on the setting:
81    --
82    --    - Silent:  no action
83    --    - Warning: issue a warning, does not cause the tool to fail
84    --    - Error:   issue an error, causes the tool to fail
85
86    type Yes_No_Unknown is (Yes, No, Unknown);
87    --  Tri-state to decide if -lgnarl is needed when linking
88
89    -----------------------------------------------------
90    -- Multi-language Stuff That Will be Modified Soon --
91    -----------------------------------------------------
92
93    --  Still should be properly commented ???
94
95    type Language_Index is new Nat;
96
97    No_Language_Index           : constant Language_Index := 0;
98    First_Language_Index        : constant Language_Index := 1;
99    First_Language_Indexes_Last : constant Language_Index := 5;
100
101    Ada_Language_Index         : constant Language_Index :=
102                                   First_Language_Index;
103    C_Language_Index           : constant Language_Index :=
104                                   Ada_Language_Index + 1;
105    C_Plus_Plus_Language_Index : constant Language_Index :=
106                                   C_Language_Index + 1;
107
108    Last_Language_Index : Language_Index := No_Language_Index;
109
110    subtype First_Language_Indexes is Language_Index
111       range First_Language_Index .. First_Language_Indexes_Last;
112
113    type Header_Num is range 0 .. 2047;
114
115    function Hash is new System.HTable.Hash (Header_Num => Header_Num);
116
117    function Hash (Name : Name_Id)        return Header_Num;
118    function Hash (Name : File_Name_Type) return Header_Num;
119
120    package Language_Indexes is new System.HTable.Simple_HTable
121      (Header_Num => Header_Num,
122       Element    => Language_Index,
123       No_Element => No_Language_Index,
124       Key        => Name_Id,
125       Hash       => Hash,
126       Equal      => "=");
127    --  Mapping of language names to language indexes
128
129    package Language_Names is new Table.Table
130      (Table_Component_Type => Name_Id,
131       Table_Index_Type     => Language_Index,
132       Table_Low_Bound      => 1,
133       Table_Initial        => 4,
134       Table_Increment      => 100,
135       Table_Name           => "Prj.Language_Names");
136    --  The table for the name of programming languages
137
138    procedure Add_Language_Name (Name : Name_Id);
139
140    procedure Display_Language_Name (Language : Language_Index);
141
142    type Languages_In_Project is array (First_Language_Indexes) of Boolean;
143    --  Set of supported languages used in a project
144
145    No_Languages : constant Languages_In_Project := (others => False);
146    --  No supported languages are used
147
148    type Supp_Language_Index is new Nat;
149    No_Supp_Language_Index  : constant Supp_Language_Index := 0;
150
151    type Supp_Language is record
152       Index   : Language_Index := No_Language_Index;
153       Present : Boolean := False;
154       Next    : Supp_Language_Index := No_Supp_Language_Index;
155    end record;
156
157    package Present_Language_Table is new GNAT.Dynamic_Tables
158      (Table_Component_Type => Supp_Language,
159       Table_Index_Type     => Supp_Language_Index,
160       Table_Low_Bound      => 1,
161       Table_Initial        => 4,
162       Table_Increment      => 100);
163    --  The table for the presence of languages with an index that is outside
164    --  of First_Language_Indexes.
165
166    type Impl_Suffix_Array is array (First_Language_Indexes) of File_Name_Type;
167    --  Suffixes for the non spec sources of the different supported languages
168    --  in a project.
169
170    No_Impl_Suffixes : constant Impl_Suffix_Array := (others => No_File);
171    --  A default value for the non spec source suffixes
172
173    type Supp_Suffix is record
174       Index   : Language_Index      := No_Language_Index;
175       Suffix  : File_Name_Type      := No_File;
176       Next    : Supp_Language_Index := No_Supp_Language_Index;
177    end record;
178
179    package Supp_Suffix_Table is new GNAT.Dynamic_Tables
180      (Table_Component_Type => Supp_Suffix,
181       Table_Index_Type     => Supp_Language_Index,
182       Table_Low_Bound      => 1,
183       Table_Initial        => 4,
184       Table_Increment      => 100);
185    --  The table for the presence of languages with an index that is outside
186    --  of First_Language_Indexes.
187
188    type Language_Kind is (GNU, other);
189
190    type Name_List_Index is new Nat;
191    No_Name_List            : constant Name_List_Index := 0;
192
193    type Name_Node is record
194       Name : Name_Id         := No_Name;
195       Next : Name_List_Index := No_Name_List;
196    end record;
197
198    package Name_List_Table is new GNAT.Dynamic_Tables
199      (Table_Component_Type => Name_Node,
200       Table_Index_Type     => Name_List_Index,
201       Table_Low_Bound      => 1,
202       Table_Initial        => 10,
203       Table_Increment      => 100);
204    --  The table for lists of names used in package Language_Processing
205
206    type Language_Processing_Data is record
207       Compiler_Drivers     : Name_List_Index := No_Name_List;
208       Compiler_Paths       : Name_Id         := No_Name;
209       Compiler_Kinds       : Language_Kind   := GNU;
210       Dependency_Options   : Name_List_Index := No_Name_List;
211       Compute_Dependencies : Name_List_Index := No_Name_List;
212       Include_Options      : Name_List_Index := No_Name_List;
213       Binder_Drivers       : Name_Id         := No_Name;
214       Binder_Driver_Paths  : Name_Id         := No_Name;
215    end record;
216
217    Default_Language_Processing_Data :
218      constant Language_Processing_Data :=
219        (Compiler_Drivers     => No_Name_List,
220         Compiler_Paths       => No_Name,
221         Compiler_Kinds       => GNU,
222         Dependency_Options   => No_Name_List,
223         Compute_Dependencies => No_Name_List,
224         Include_Options      => No_Name_List,
225         Binder_Drivers       => No_Name,
226         Binder_Driver_Paths  => No_Name);
227
228    type First_Language_Processing_Data is
229      array (First_Language_Indexes) of Language_Processing_Data;
230
231    Default_First_Language_Processing_Data :
232       constant First_Language_Processing_Data :=
233                  (others => Default_Language_Processing_Data);
234
235    type Supp_Language_Data is record
236       Index : Language_Index := No_Language_Index;
237       Data  : Language_Processing_Data := Default_Language_Processing_Data;
238       Next  : Supp_Language_Index := No_Supp_Language_Index;
239    end record;
240
241    package Supp_Language_Table is new GNAT.Dynamic_Tables
242      (Table_Component_Type => Supp_Language_Data,
243       Table_Index_Type     => Supp_Language_Index,
244       Table_Low_Bound      => 1,
245       Table_Initial        => 4,
246       Table_Increment      => 100);
247    --  The table for language data when there are more languages than
248    --  in First_Language_Indexes.
249
250    type Other_Source_Id is new Nat;
251    No_Other_Source : constant Other_Source_Id := 0;
252
253    type Other_Source is record
254       Language         : Language_Index;       --  language of the source
255       File_Name        : File_Name_Type;       --  source file simple name
256       Path_Name        : Path_Name_Type;       --  source full path name
257       Source_TS        : Time_Stamp_Type;      --  source file time stamp
258       Object_Name      : File_Name_Type;       --  object file simple name
259       Object_Path      : Path_Name_Type;       --  object full path name
260       Object_TS        : Time_Stamp_Type;      --  object file time stamp
261       Dep_Name         : File_Name_Type;       --  dependency file simple name
262       Dep_Path         : Path_Name_Type;       --  dependency full path name
263       Dep_TS           : Time_Stamp_Type;      --  dependency file time stamp
264       Naming_Exception : Boolean := False;     --  True if a naming exception
265       Next             : Other_Source_Id := No_Other_Source;
266    end record;
267    --  Data for a source in a language other than Ada
268
269    package Other_Source_Table is new GNAT.Dynamic_Tables
270      (Table_Component_Type => Other_Source,
271       Table_Index_Type     => Other_Source_Id,
272       Table_Low_Bound      => 1,
273       Table_Initial        => 200,
274       Table_Increment      => 100);
275    --  The table for sources of languages other than Ada
276
277    ----------------------------------
278    --  End of multi-language stuff --
279    ----------------------------------
280
281    type Verbosity is (Default, Medium, High);
282    --  Verbosity when parsing GNAT Project Files
283    --    Default is default (very quiet, if no errors).
284    --    Medium is more verbose.
285    --    High is extremely verbose.
286
287    Current_Verbosity : Verbosity := Default;
288    --  The current value of the verbosity the project files are parsed with
289
290    type Lib_Kind is (Static, Dynamic, Relocatable);
291    type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
292    --  Type to specify the symbol policy, when symbol control is supported.
293    --  See full explanation about this type in package Symbols.
294    --    Autonomous: Create a symbol file without considering any reference
295    --    Compliant:  Try to be as compatible as possible with an existing ref
296    --    Controlled: Fail if symbols are not the same as those in the reference
297    --    Restricted: Restrict the symbols to those in the symbol file
298    --    Direct:     The symbol file is used as is
299
300    type Symbol_Record is record
301       Symbol_File   : Name_Id := No_Name;
302       Reference     : Name_Id := No_Name;
303       Symbol_Policy : Policy  := Autonomous;
304    end record;
305    --  Type to keep the symbol data to be used when building a shared library
306
307    No_Symbols : constant Symbol_Record :=
308      (Symbol_File   => No_Name,
309       Reference     => No_Name,
310       Symbol_Policy => Autonomous);
311    --  The default value of the symbol data
312
313    function Empty_String return Name_Id;
314    --  Return the Name_Id for an empty string ""
315
316    type Project_Id is new Nat;
317    No_Project : constant Project_Id := 0;
318    --  Id of a Project File
319
320    type String_List_Id is new Nat;
321    Nil_String : constant String_List_Id := 0;
322    type String_Element is record
323       Value         : Name_Id        := No_Name;
324       Index         : Int            := 0;
325       Display_Value : Name_Id        := No_Name;
326       Location      : Source_Ptr     := No_Location;
327       Flag          : Boolean        := False;
328       Next          : String_List_Id := Nil_String;
329    end record;
330    --  To hold values for string list variables and array elements.
331    --  The component Flag may be used for various purposes. For source
332    --  directories, it indicates if the directory contains Ada source(s).
333
334    package String_Element_Table is new GNAT.Dynamic_Tables
335      (Table_Component_Type => String_Element,
336       Table_Index_Type     => String_List_Id,
337       Table_Low_Bound      => 1,
338       Table_Initial        => 200,
339       Table_Increment      => 100);
340    --  The table for string elements in string lists
341
342    type Variable_Kind is (Undefined, List, Single);
343    --  Different kinds of variables
344
345    subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
346    --  The defined kinds of variables
347
348    Ignored : constant Variable_Kind;
349    --  Used to indicate that a package declaration must be ignored
350    --  while processing the project tree (unknown package name).
351
352    type Variable_Value (Kind : Variable_Kind := Undefined) is record
353       Project  : Project_Id := No_Project;
354       Location : Source_Ptr := No_Location;
355       Default  : Boolean    := False;
356       case Kind is
357          when Undefined =>
358             null;
359          when List =>
360             Values : String_List_Id := Nil_String;
361          when Single =>
362             Value : Name_Id := No_Name;
363             Index : Int     := 0;
364       end case;
365    end record;
366    --  Values for variables and array elements. Default is True if the
367    --  current value is the default one for the variable
368
369    Nil_Variable_Value : constant Variable_Value;
370    --  Value of a non existing variable or array element
371
372    type Variable_Id is new Nat;
373    No_Variable : constant Variable_Id := 0;
374    type Variable is record
375       Next  : Variable_Id := No_Variable;
376       Name  : Name_Id;
377       Value : Variable_Value;
378    end record;
379    --  To hold the list of variables in a project file and in packages
380
381    package Variable_Element_Table is new GNAT.Dynamic_Tables
382      (Table_Component_Type => Variable,
383       Table_Index_Type     => Variable_Id,
384       Table_Low_Bound      => 1,
385       Table_Initial        => 200,
386       Table_Increment      => 100);
387    --  The table of variable in list of variables
388
389    type Array_Element_Id is new Nat;
390    No_Array_Element : constant Array_Element_Id := 0;
391    type Array_Element is record
392       Index                : Name_Id;
393       Src_Index            : Int := 0;
394       Index_Case_Sensitive : Boolean := True;
395       Value                : Variable_Value;
396       Next                 : Array_Element_Id := No_Array_Element;
397    end record;
398    --  Each Array_Element represents an array element and is linked (Next)
399    --  to the next array element, if any, in the array.
400
401    package Array_Element_Table is new GNAT.Dynamic_Tables
402      (Table_Component_Type => Array_Element,
403       Table_Index_Type     => Array_Element_Id,
404       Table_Low_Bound      => 1,
405       Table_Initial        => 200,
406       Table_Increment      => 100);
407    --  The table that contains all array elements
408
409    type Array_Id is new Nat;
410    No_Array : constant Array_Id := 0;
411    type Array_Data is record
412       Name  : Name_Id          := No_Name;
413       Value : Array_Element_Id := No_Array_Element;
414       Next  : Array_Id         := No_Array;
415    end record;
416    --  Each Array_Data value represents an array.
417    --  Value is the id of the first element.
418    --  Next is the id of the next array in the project file or package.
419
420    package Array_Table is new GNAT.Dynamic_Tables
421      (Table_Component_Type => Array_Data,
422       Table_Index_Type     => Array_Id,
423       Table_Low_Bound      => 1,
424       Table_Initial        => 200,
425       Table_Increment      => 100);
426    --  The table that contains all arrays
427
428    type Package_Id is new Nat;
429    No_Package : constant Package_Id := 0;
430    type Declarations is record
431       Variables  : Variable_Id := No_Variable;
432       Attributes : Variable_Id := No_Variable;
433       Arrays     : Array_Id    := No_Array;
434       Packages   : Package_Id  := No_Package;
435    end record;
436    --  Contains the declarations (variables, single and array attributes,
437    --  packages) for a project or a package in a project.
438
439    No_Declarations : constant Declarations :=
440      (Variables  => No_Variable,
441       Attributes => No_Variable,
442       Arrays     => No_Array,
443       Packages   => No_Package);
444    --  Default value of Declarations: indicates that there is no declarations
445
446    type Package_Element is record
447       Name   : Name_Id      := No_Name;
448       Decl   : Declarations := No_Declarations;
449       Parent : Package_Id   := No_Package;
450       Next   : Package_Id   := No_Package;
451    end record;
452    --  A package (includes declarations that may include other packages)
453
454    package Package_Table is new GNAT.Dynamic_Tables
455      (Table_Component_Type => Package_Element,
456       Table_Index_Type     => Package_Id,
457       Table_Low_Bound      => 1,
458       Table_Initial        => 100,
459       Table_Increment      => 100);
460    --  The table that contains all packages
461
462    function Image (Casing : Casing_Type) return String;
463    --  Similar to 'Image (but avoid use of this attribute in compiler)
464
465    function Value (Image : String) return Casing_Type;
466    --  Similar to 'Value (but avoid use of this attribute in compiler)
467    --  Raises Constraint_Error if not a Casing_Type image.
468
469    --  The following record contains data for a naming scheme
470
471    type Naming_Data is record
472
473       Dot_Replacement : File_Name_Type := No_File;
474       --  The string to replace '.' in the source file name (for Ada)
475
476       Dot_Repl_Loc : Source_Ptr := No_Location;
477       --  The position in the project file source where Dot_Replacement is
478       --  defined.
479
480       Casing : Casing_Type := All_Lower_Case;
481       --  The casing of the source file name (for Ada)
482
483       Spec_Suffix : Array_Element_Id := No_Array_Element;
484       --  The string to append to the unit name for the
485       --  source file name of a spec.
486       --  Indexed by the programming language.
487
488       Ada_Spec_Suffix : File_Name_Type := No_File;
489       --  The suffix of the Ada spec sources
490
491       Spec_Suffix_Loc : Source_Ptr := No_Location;
492       --  The position in the project file source where
493       --  Ada_Spec_Suffix is defined.
494
495       Impl_Suffixes : Impl_Suffix_Array   := No_Impl_Suffixes;
496       Supp_Suffixes : Supp_Language_Index := No_Supp_Language_Index;
497       --  The source suffixes of the different languages
498
499       Body_Suffix : Array_Element_Id := No_Array_Element;
500       --  The string to append to the unit name for the
501       --  source file name of a body.
502       --  Indexed by the programming language.
503
504       Ada_Body_Suffix : File_Name_Type := No_File;
505       --  The suffix of the Ada body sources
506
507       Body_Suffix_Loc : Source_Ptr := No_Location;
508       --  The position in the project file source where
509       --  Ada_Body_Suffix is defined.
510
511       Separate_Suffix : File_Name_Type := No_File;
512       --  String to append to unit name for source file name of an Ada subunit
513
514       Sep_Suffix_Loc : Source_Ptr := No_Location;
515       --  Position in the project file source where Separate_Suffix is defined
516
517       Specs : Array_Element_Id := No_Array_Element;
518       --  An associative array mapping individual specs to source file names
519       --  This is specific to Ada.
520
521       Bodies : Array_Element_Id := No_Array_Element;
522       --  An associative array mapping individual bodies to source file names
523       --  This is specific to Ada.
524
525       Specification_Exceptions : Array_Element_Id := No_Array_Element;
526       --  An associative array listing spec file names that do not have the
527       --  spec suffix. Not used by Ada. Indexed by programming language name.
528
529       Implementation_Exceptions : Array_Element_Id := No_Array_Element;
530       --  An associative array listing body file names that do not have the
531       --  body suffix. Not used by Ada. Indexed by programming language name.
532
533    end record;
534
535    function Standard_Naming_Data
536      (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
537    pragma Inline (Standard_Naming_Data);
538    --  The standard GNAT naming scheme when Tree is No_Project_Tree.
539    --  Otherwise, return the default naming scheme for the project tree Tree,
540    --  which must have been Initialized.
541
542    function Same_Naming_Scheme
543      (Left, Right : Naming_Data) return Boolean;
544    --  Returns True if Left and Right are the same naming scheme
545    --  not considering Specs and Bodies.
546
547    type Project_List is new Nat;
548    Empty_Project_List : constant Project_List := 0;
549    --  A list of project files
550
551    type Project_Element is record
552       Project : Project_Id   := No_Project;
553       Next    : Project_List := Empty_Project_List;
554    end record;
555    --  Element in a list of project files. Next is the id of the next
556    --  project file in the list.
557
558    package Project_List_Table is new GNAT.Dynamic_Tables
559      (Table_Component_Type => Project_Element,
560       Table_Index_Type     => Project_List,
561       Table_Low_Bound      => 1,
562       Table_Initial        => 100,
563       Table_Increment      => 100);
564    --  The table that contains the lists of project files
565
566    --  The following record describes a project file representation
567
568    type Project_Data is record
569       Externally_Built : Boolean := False;
570
571       Languages      : Languages_In_Project := No_Languages;
572       Supp_Languages : Supp_Language_Index  := No_Supp_Language_Index;
573       --  Indicate the different languages of the source of this project
574
575       First_Referred_By : Project_Id := No_Project;
576       --  The project, if any, that was the first to be known as importing or
577       --  extending this project. Set by Prj.Proc.Process.
578
579       Name : Name_Id := No_Name;
580       --  The name of the project. Set by Prj.Proc.Process
581
582       Display_Name : Name_Id := No_Name;
583       --  The name of the project with the spelling of its declaration.
584       --  Set by Prj.Proc.Process.
585
586       Path_Name : Path_Name_Type := No_Path;
587       --  The path name of the project file. Set by Prj.Proc.Process
588
589       Display_Path_Name : Path_Name_Type := No_Path;
590       --  The path name used for display purposes. May be different from
591       --  Path_Name for platforms where the file names are case-insensitive.
592
593       Virtual : Boolean := False;
594       --  True for virtual extending projects
595
596       Location : Source_Ptr := No_Location;
597       --  The location in the project file source of the reserved word
598       --  project. Set by Prj.Proc.Process.
599
600       Mains : String_List_Id := Nil_String;
601       --  List of mains specified by attribute Main. Set by Prj.Nmsc.Check
602
603       Directory : Path_Name_Type := No_Path;
604       --  Directory where the project file resides. Set by Prj.Proc.Process
605
606       Display_Directory : Path_Name_Type := No_Path;
607       --  Project directory path name for display purposes. May be different
608       --  from Directory for platforms where file names are case-insensitive.
609
610       Dir_Path : String_Access;
611       --  Same as Directory, but as an access to String. Set by
612       --  Make.Compile_Sources.Collect_Arguments_And_Compile.
613
614       Library : Boolean := False;
615       --  True if this is a library project. Set by
616       --  Prj.Nmsc.Language_Independent_Check.
617
618       Library_Dir : Path_Name_Type := No_Path;
619       --  If a library project, directory where the library Set by
620       --  Prj.Nmsc.Language_Independent_Check.
621
622       Display_Library_Dir : Path_Name_Type := No_Path;
623       --  The name of the library directory, for display purposes. May be
624       --  different from Library_Dir for platforms where the file names are
625       --  case-insensitive.
626
627       Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
628       --  The timestamp of a library file in a library project.
629       --  Set by MLib.Prj.Check_Library.
630
631       Library_Src_Dir : Path_Name_Type := No_Path;
632       --  If a Stand-Alone Library project, directory where the sources
633       --  of the interfaces of the library are copied. By default, if
634       --  attribute Library_Src_Dir is not specified, sources of the interfaces
635       --  are not copied anywhere. Set by Prj.Nmsc.Check_Stand_Alone_Library.
636
637       Display_Library_Src_Dir : Path_Name_Type := No_Path;
638       --  The name of the library source directory, for display purposes.
639       --  May be different from Library_Src_Dir for platforms where the file
640       --  names are case-insensitive.
641
642       Library_ALI_Dir : Path_Name_Type := No_Path;
643       --  In a library project, directory where the ALI files are copied.
644       --  If attribute Library_ALI_Dir is not specified, ALI files are
645       --  copied in the Library_Dir. Set by Prj.Nmsc.Check_Library_Attributes.
646
647       Display_Library_ALI_Dir : Path_Name_Type := No_Path;
648       --  The name of the library ALI directory, for display purposes. May be
649       --  different from Library_ALI_Dir for platforms where the file names are
650       --  case-insensitive.
651
652       Library_Name : File_Name_Type := No_File;
653       --  If a library project, name of the library
654       --  Set by Prj.Nmsc.Language_Independent_Check.
655
656       Library_Kind : Lib_Kind := Static;
657       --  If a library project, kind of library
658       --  Set by Prj.Nmsc.Language_Independent_Check.
659
660       Lib_Internal_Name : File_Name_Type := No_File;
661       --  If a library project, internal name store inside the library Set by
662       --  Prj.Nmsc.Language_Independent_Check.
663
664       Standalone_Library : Boolean := False;
665       --  Indicate that this is a Standalone Library Project File. Set by
666       --  Prj.Nmsc.Check.
667
668       Lib_Interface_ALIs : String_List_Id := Nil_String;
669       --  For Standalone Library Project Files, indicate the list of Interface
670       --  ALI files. Set by Prj.Nmsc.Check.
671
672       Lib_Auto_Init : Boolean := False;
673       --  For non static Standalone Library Project Files, indicate if
674       --  the library initialisation should be automatic.
675
676       Libgnarl_Needed : Yes_No_Unknown := Unknown;
677       --  Set to True when libgnarl is needed to link
678
679       Symbol_Data : Symbol_Record := No_Symbols;
680       --  Symbol file name, reference symbol file name, symbol policy
681
682       Ada_Sources_Present : Boolean := True;
683       --  A flag that indicates if there are Ada sources in this project file.
684       --  There are no sources if any of the following is true:
685       --    1) Source_Dirs is specified as an empty list
686       --    2) Source_Files is specified as an empty list
687       --    3) Ada is not in the list of the specified Languages
688
689       Other_Sources_Present : Boolean := True;
690       --  A flag that indicates that there are non-Ada sources in this project
691
692       Sources : String_List_Id := Nil_String;
693       --  The list of all the source file names.
694       --  Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
695
696       First_Other_Source : Other_Source_Id := No_Other_Source;
697       Last_Other_Source  : Other_Source_Id := No_Other_Source;
698       --  Head and tail of the list of sources of languages other than Ada
699
700       Imported_Directories_Switches : Argument_List_Access := null;
701       --  List of the -I switches to be used when compiling sources of
702       --  languages other than Ada.
703
704       Include_Path : String_Access := null;
705       --  Value to be used as CPATH, when using a GCC, instead of a list of
706       --  -I switches.
707
708       Include_Data_Set : Boolean := False;
709       --  Set True when Imported_Directories_Switches or Include_Path are set
710
711       Source_Dirs : String_List_Id := Nil_String;
712       --  The list of all the source directories.
713       --  Set by Prj.Nmsc.Language_Independent_Check.
714
715       Known_Order_Of_Source_Dirs : Boolean := True;
716       --  False, if there is any /** in the Source_Dirs, because in this case
717       --  the ordering of the source subdirs depend on the OS. If True,
718       --  duplicate file names in the same project file are allowed.
719
720       Object_Directory : Path_Name_Type := No_Path;
721       --  The object directory of this project file.
722       --  Set by Prj.Nmsc.Language_Independent_Check.
723
724       Display_Object_Dir : Path_Name_Type := No_Path;
725       --  The name of the object directory, for display purposes.
726       --  May be different from Object_Directory for platforms where the file
727       --  names are case-insensitive.
728
729       Exec_Directory : Path_Name_Type := No_Path;
730       --  The exec directory of this project file. Default is equal to
731       --  Object_Directory. Set by Prj.Nmsc.Language_Independent_Check.
732
733       Display_Exec_Dir : Path_Name_Type := No_Path;
734       --  The name of the exec directory, for display purposes. May be
735       --  different from Exec_Directory for platforms where the file names are
736       --  case-insensitive.
737
738       Extends : Project_Id := No_Project;
739       --  The reference of the project file, if any, that this project file
740       --  extends. Set by Prj.Proc.Process.
741
742       Extended_By : Project_Id := No_Project;
743       --  The reference of the project file, if any, that extends this project
744       --  file. Set by Prj.Proc.Process.
745
746       Naming : Naming_Data := Standard_Naming_Data;
747       --  The naming scheme of this project file.
748       --  Set by Prj.Nmsc.Check_Naming_Scheme.
749
750       First_Language_Processing : First_Language_Processing_Data :=
751                                     Default_First_Language_Processing_Data;
752       --  Comment needed ???
753
754       Supp_Language_Processing : Supp_Language_Index := No_Supp_Language_Index;
755       --  Comment needed
756
757       Default_Linker      : File_Name_Type := No_File;
758       Default_Linker_Path : Path_Name_Type := No_Path;
759
760       Decl : Declarations := No_Declarations;
761       --  The declarations (variables, attributes and packages) of this
762       --  project file. Set by Prj.Proc.Process.
763
764       Imported_Projects : Project_List := Empty_Project_List;
765       --  The list of all directly imported projects, if any. Set by
766       --  Prj.Proc.Process.
767
768       All_Imported_Projects : Project_List := Empty_Project_List;
769       --  The list of all projects imported directly or indirectly, if any.
770       --  Set by Make.Initialize.
771
772       Ada_Include_Path : String_Access := null;
773       --  The cached value of ADA_INCLUDE_PATH for this project file. Do not
774       --  use this field directly outside of the compiler, use
775       --  Prj.Env.Ada_Include_Path instead. Set by Prj.Env.Ada_Include_Path.
776
777       Ada_Objects_Path : String_Access := null;
778       --  The cached value of ADA_OBJECTS_PATH for this project file. Do not
779       --  use this field directly outside of the compiler, use
780       --  Prj.Env.Ada_Objects_Path instead. Set by Prj.Env.Ada_Objects_Path
781
782       Include_Path_File : Path_Name_Type := No_Path;
783       --  The cached value of the source path temp file for this project file.
784       --  Set by gnatmake (Prj.Env.Set_Ada_Paths).
785
786       Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
787       --  The cached value of the object path temp file (including library
788       --  dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
789
790       Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
791       --  The cached value of the object path temp file (excluding library
792       --  dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
793
794       Config_File_Name : Path_Name_Type := No_Path;
795       --  The name of the configuration pragmas file, if any.
796       --  Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
797
798       Config_File_Temp : Boolean := False;
799       --  An indication that the configuration pragmas file is
800       --  a temporary file that must be deleted at the end.
801       --  Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
802
803       Config_Checked : Boolean := False;
804       --  A flag to avoid checking repetitively the configuration pragmas file.
805       --  Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
806
807       Language_Independent_Checked : Boolean := False;
808       --  A flag that indicates that the project file has been checked
809       --  for language independent features: Object_Directory,
810       --  Source_Directories, Library, non empty Naming Suffixes.
811
812       Checked : Boolean := False;
813       --  A flag to avoid checking repetitively the naming scheme of
814       --  this project file. Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
815
816       Seen : Boolean := False;
817       --  A flag to mark a project as "visited" to avoid processing the same
818       --  project several time.
819
820       Need_To_Build_Lib : Boolean := False;
821       --  Indicates that the library of a Library Project needs to be built or
822       --  rebuilt.
823
824       Depth : Natural := 0;
825       --  The maximum depth of a project in the project graph.
826       --  Depth of main project is 0.
827
828       Unkept_Comments : Boolean := False;
829       --  True if there are comments in the project sources that cannot
830       --  be kept in the project tree.
831    end record;
832
833    function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
834    --  Return the representation of an empty project in project Tree tree.
835    --  The project tree Tree must have been Initialized and/or Reset.
836
837    Project_Error : exception;
838    --  Raised by some subprograms in Prj.Attr
839
840    package Project_Table is new GNAT.Dynamic_Tables (
841      Table_Component_Type => Project_Data,
842      Table_Index_Type     => Project_Id,
843      Table_Low_Bound      => 1,
844      Table_Initial        => 100,
845      Table_Increment      => 100);
846    --  The set of all project files
847
848    type Spec_Or_Body is
849      (Specification, Body_Part);
850
851    type File_Name_Data is record
852       Name         : File_Name_Type := No_File;
853       Index        : Int            := 0;
854       Display_Name : File_Name_Type := No_File;
855       Path         : File_Name_Type := No_File;
856       Display_Path : File_Name_Type := No_File;
857       Project      : Project_Id     := No_Project;
858       Needs_Pragma : Boolean        := False;
859    end record;
860    --  File and Path name of a spec or body
861
862    type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
863
864    type Unit_Id is new Nat;
865    No_Unit : constant Unit_Id := 0;
866    type Unit_Data is record
867       Name       : Name_Id    := No_Name;
868       File_Names : File_Names_Data;
869    end record;
870    --  Name and File and Path names of a unit, with a reference to its
871    --  GNAT Project File(s).
872
873    package Unit_Table is new GNAT.Dynamic_Tables
874      (Table_Component_Type => Unit_Data,
875       Table_Index_Type     => Unit_Id,
876       Table_Low_Bound      => 1,
877       Table_Initial        => 100,
878       Table_Increment      => 100);
879    --  Table of all units in a project tree
880
881    package Units_Htable is new Simple_HTable
882      (Header_Num => Header_Num,
883       Element    => Unit_Id,
884       No_Element => No_Unit,
885       Key        => Name_Id,
886       Hash       => Hash,
887       Equal      => "=");
888    --  Mapping of unit names to indexes in the Units table
889
890    type Unit_Project is record
891       Unit    : Unit_Id    := No_Unit;
892       Project : Project_Id := No_Project;
893    end record;
894
895    No_Unit_Project : constant Unit_Project := (No_Unit, No_Project);
896
897    package Files_Htable is new Simple_HTable
898      (Header_Num => Header_Num,
899       Element    => Unit_Project,
900       No_Element => No_Unit_Project,
901       Key        => File_Name_Type,
902       Hash       => Hash,
903       Equal      => "=");
904    --  Mapping of file names to indexes in the Units table
905
906    type Private_Project_Tree_Data is private;
907    --  Data for a project tree that is used only by the Project Manager
908
909    type Project_Tree_Data is
910       record
911          Present_Languages : Present_Language_Table.Instance;
912          Supp_Suffixes     : Supp_Suffix_Table.Instance;
913          Name_Lists        : Name_List_Table.Instance;
914          Supp_Languages    : Supp_Language_Table.Instance;
915          Other_Sources     : Other_Source_Table.Instance;
916          String_Elements   : String_Element_Table.Instance;
917          Variable_Elements : Variable_Element_Table.Instance;
918          Array_Elements    : Array_Element_Table.Instance;
919          Arrays            : Array_Table.Instance;
920          Packages          : Package_Table.Instance;
921          Project_Lists     : Project_List_Table.Instance;
922          Projects          : Project_Table.Instance;
923          Units             : Unit_Table.Instance;
924          Units_HT          : Units_Htable.Instance;
925          Files_HT          : Files_Htable.Instance;
926          Private_Part      : Private_Project_Tree_Data;
927       end record;
928    --  Data for a project tree
929
930    type Put_Line_Access is access procedure
931      (Line    : String;
932       Project : Project_Id;
933       In_Tree : Project_Tree_Ref);
934    --  Use to customize error reporting in Prj.Proc and Prj.Nmsc
935
936    procedure Expect (The_Token : Token_Type; Token_Image : String);
937    --  Check that the current token is The_Token. If it is not, then
938    --  output an error message.
939
940    procedure Initialize (Tree : Project_Tree_Ref);
941    --  This procedure must be called before using any services from the Prj
942    --  hierarchy. Namet.Initialize must be called before Prj.Initialize.
943
944    procedure Reset (Tree : Project_Tree_Ref);
945    --  This procedure resets all the tables that are used when processing a
946    --  project file tree. Initialize must be called before the call to Reset.
947
948    procedure Register_Default_Naming_Scheme
949      (Language            : Name_Id;
950       Default_Spec_Suffix : File_Name_Type;
951       Default_Body_Suffix : File_Name_Type;
952       In_Tree             : Project_Tree_Ref);
953    --  Register the default suffixes for a given language. These extensions
954    --  will be ignored if the user has specified a new naming scheme in a
955    --  project file.
956    --
957    --  Otherwise, this information will be automatically added to Naming_Data
958    --  when a project is processed, in the lists Spec_Suffix and Body_Suffix.
959
960    generic
961       type State is limited private;
962       with procedure Action
963         (Project    : Project_Id;
964          With_State : in out State);
965    procedure For_Every_Project_Imported
966      (By         : Project_Id;
967       In_Tree    : Project_Tree_Ref;
968       With_State : in out State);
969    --  Call Action for each project imported directly or indirectly by project
970    --  By. Action is called according to the order of importation: if A
971    --  imports B, directly or indirectly, Action will be called for A before
972    --  it is called for B. If two projects import each other directly or
973    --  indirectly (using at least one "limited with"), it is not specified
974    --  for which of these two projects Action will be called first. Projects
975    --  that are extended by other projects are not considered. With_State may
976    --  be used by Action to choose a behavior or to report some global result.
977
978    ----------------------------------------------------------
979    -- Other multi-language stuff that may be modified soon --
980    ----------------------------------------------------------
981
982    function Is_Present
983      (Language   : Language_Index;
984       In_Project : Project_Data;
985       In_Tree    : Project_Tree_Ref) return Boolean;
986    --  Return True when Language is one of the languages used in
987    --  project In_Project.
988
989    procedure Set
990      (Language   : Language_Index;
991       Present    : Boolean;
992       In_Project : in out Project_Data;
993       In_Tree    : Project_Tree_Ref);
994    --  Indicate if Language is or not a language used in project In_Project
995
996    function Language_Processing_Data_Of
997      (Language   : Language_Index;
998       In_Project : Project_Data;
999       In_Tree    : Project_Tree_Ref) return Language_Processing_Data;
1000    --  Return the Language_Processing_Data for language Language in project
1001    --  In_Project. Return the default when no Language_Processing_Data are
1002    --  defined for the language.
1003
1004    procedure Set
1005      (Language_Processing : Language_Processing_Data;
1006       For_Language        : Language_Index;
1007       In_Project          : in out Project_Data;
1008       In_Tree             : Project_Tree_Ref);
1009    --  Set the Language_Processing_Data for language Language in project
1010    --  In_Project.
1011
1012    function Suffix_Of
1013      (Language   : Language_Index;
1014       In_Project : Project_Data;
1015       In_Tree    : Project_Tree_Ref) return File_Name_Type;
1016    --  Return the suffix for language Language in project In_Project. Return
1017    --  No_Name when no suffix is defined for the language.
1018
1019    procedure Set
1020      (Suffix       : File_Name_Type;
1021       For_Language : Language_Index;
1022       In_Project   : in out Project_Data;
1023       In_Tree      : Project_Tree_Ref);
1024    --  Set the suffix for language Language in project In_Project
1025
1026 private
1027
1028    All_Packages : constant String_List_Access := null;
1029
1030    No_Project_Tree : constant Project_Tree_Ref := null;
1031
1032    Ignored : constant Variable_Kind := Single;
1033
1034    Nil_Variable_Value : constant Variable_Value :=
1035      (Project  => No_Project,
1036       Kind     => Undefined,
1037       Location => No_Location,
1038       Default  => False);
1039
1040    Virtual_Prefix : constant String := "v$";
1041    --  The prefix for virtual extending projects. Because of the '$', which is
1042    --  normally forbidden for project names, there cannot be any name clash.
1043
1044    Empty_Name : Name_Id;
1045    --  Name_Id for an empty name (no characters). Initialized by the call
1046    --  to procedure Initialize.
1047
1048    procedure Add_To_Buffer
1049      (S    : String;
1050       To   : in out String_Access;
1051       Last : in out Natural);
1052    --  Append a String to the Buffer
1053
1054    type Naming_Id is new Nat;
1055
1056    package Naming_Table is new GNAT.Dynamic_Tables
1057      (Table_Component_Type => Naming_Data,
1058       Table_Index_Type     => Naming_Id,
1059       Table_Low_Bound      => 1,
1060       Table_Initial        => 5,
1061       Table_Increment      => 100);
1062    --  Comment ???
1063
1064    package Path_File_Table is new GNAT.Dynamic_Tables
1065      (Table_Component_Type => Path_Name_Type,
1066       Table_Index_Type     => Natural,
1067       Table_Low_Bound      => 1,
1068       Table_Initial        => 50,
1069       Table_Increment      => 100);
1070    --  Table storing all the temp path file names.
1071    --  Used by Delete_All_Path_Files.
1072
1073    package Source_Path_Table is new GNAT.Dynamic_Tables
1074      (Table_Component_Type => File_Name_Type,
1075       Table_Index_Type     => Natural,
1076       Table_Low_Bound      => 1,
1077       Table_Initial        => 50,
1078       Table_Increment      => 100);
1079    --  A table to store the source dirs before creating the source path file
1080
1081    package Object_Path_Table is new GNAT.Dynamic_Tables
1082      (Table_Component_Type => Path_Name_Type,
1083       Table_Index_Type     => Natural,
1084       Table_Low_Bound      => 1,
1085       Table_Initial        => 50,
1086       Table_Increment      => 100);
1087    --  A table to store the object dirs, before creating the object path file
1088
1089    type Private_Project_Tree_Data is record
1090       Namings        : Naming_Table.Instance;
1091       Path_Files     : Path_File_Table.Instance;
1092       Source_Paths   : Source_Path_Table.Instance;
1093       Object_Paths   : Object_Path_Table.Instance;
1094       Default_Naming : Naming_Data;
1095    end record;
1096    --  Comment ???
1097 end Prj;