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