OSDN Git Service

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