1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2008, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- The following package declares the data types for GNAT project.
27 -- These data types may be used by GNAT Project-aware tools.
29 -- Children of these package implements various services on these data types.
30 -- See in particular Prj.Pars and Prj.Env.
32 with Casing; use Casing;
33 with Namet; use Namet;
34 with Scans; use Scans;
36 with Types; use Types;
38 with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
39 with GNAT.Dynamic_Tables;
40 with GNAT.OS_Lib; use GNAT.OS_Lib;
46 Subdirs_Option : constant String := "--subdirs=";
47 -- Switch used to indicate that the real directories (object, exec,
48 -- library, ...) are subdirectories of what is indicated in the project
51 Subdirs : String_Ptr := null;
52 -- The value after the equal sign in switch --subdirs=...
53 -- Contains the relative subdirectory.
55 type Library_Support is (None, Static_Only, Full);
56 -- Support for Library Project File.
57 -- - None: Library Project Files are not supported at all
58 -- - Static_Only: Library Project Files are only supported for static
60 -- - Full: Library Project Files are supported for static and dynamic
61 -- (shared) libraries.
63 type Yes_No_Unknown is (Yes, No, Unknown);
64 -- Tri-state to decide if -lgnarl is needed when linking
66 type Mode is (Multi_Language, Ada_Only);
67 -- Ada_Only: mode for gnatmake, gnatname, the GNAT driver
68 -- Multi_Language: mode for gprbuild, gprclean
70 type Project_Qualifier is
77 -- Qualifiers that can prefix the reserved word "project" in a project
79 -- Standard: standard project ...
80 -- Library: library project is ...
81 -- Dry: abstract project is
82 -- Aggregate: aggregate project is
83 -- Aggregate_Library: aggregate library project is ...
85 function Get_Mode return Mode;
86 pragma Inline (Get_Mode);
88 procedure Set_Mode (New_Mode : Mode);
89 pragma Inline (Set_Mode);
91 Default_Language_Is_Ada : Boolean := True;
92 -- If no language was defined in the project or the configuration file, it
93 -- is an error, unless this variable is True, in which case it defaults to
94 -- Ada. Calling Set_Mode will reset this variable, default is for Ada_Only.
96 Must_Check_Configuration : Boolean := False;
97 -- True when the contents of the configuration file must be checked. This
98 -- is in general only needed by gprbuild itself, since other applications
99 -- can ignore such errors when they don't need to build directly. Calling
100 -- Set_Mode will reset this variable, default is for Ada_Only.
102 function In_Configuration return Boolean;
103 pragma Inline (In_Configuration);
105 procedure Set_In_Configuration (Value : Boolean);
106 pragma Inline (Set_In_Configuration);
108 All_Packages : constant String_List_Access;
109 -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
110 -- Prj.Part, indicating that all packages should be checked.
112 type Project_Tree_Data;
113 type Project_Tree_Ref is access all Project_Tree_Data;
114 -- Reference to a project tree. Several project trees may exist in memory
117 No_Project_Tree : constant Project_Tree_Ref;
119 function Default_Ada_Spec_Suffix return File_Name_Type;
120 pragma Inline (Default_Ada_Spec_Suffix);
121 -- The name for the standard GNAT suffix for Ada spec source file name
122 -- ".ads". Initialized by Prj.Initialize.
124 function Default_Ada_Body_Suffix return File_Name_Type;
125 pragma Inline (Default_Ada_Body_Suffix);
126 -- The name for the standard GNAT suffix for Ada body source file name
127 -- ".adb". Initialized by Prj.Initialize.
129 function Slash return Path_Name_Type;
130 pragma Inline (Slash);
131 -- "/", used as the path of locally removed files
133 Config_Project_File_Extension : String := ".cgpr";
134 Project_File_Extension : String := ".gpr";
135 -- The standard config and user project file name extensions. They are not
136 -- constants, because Canonical_Case_File_Name is called on these variables
137 -- in the body of Prj.
139 type Error_Warning is (Silent, Warning, Error);
140 -- Severity of some situations, such as: no Ada sources in a project where
141 -- Ada is one of the language.
143 -- When the situation occurs, the behaviour depends on the setting:
145 -- - Silent: no action
146 -- - Warning: issue a warning, does not cause the tool to fail
147 -- - Error: issue an error, causes the tool to fail
149 function Empty_File return File_Name_Type;
150 function Empty_String return Name_Id;
151 -- Return the id for an empty string ""
153 type Project_Id is new Nat;
154 No_Project : constant Project_Id := 0;
155 -- Id of a Project File
157 type String_List_Id is new Nat;
158 Nil_String : constant String_List_Id := 0;
159 type String_Element is record
160 Value : Name_Id := No_Name;
162 Display_Value : Name_Id := No_Name;
163 Location : Source_Ptr := No_Location;
164 Flag : Boolean := False;
165 Next : String_List_Id := Nil_String;
167 -- To hold values for string list variables and array elements.
168 -- Component Flag may be used for various purposes. For source
169 -- directories, it indicates if the directory contains Ada source(s).
171 package String_Element_Table is new GNAT.Dynamic_Tables
172 (Table_Component_Type => String_Element,
173 Table_Index_Type => String_List_Id,
174 Table_Low_Bound => 1,
175 Table_Initial => 200,
176 Table_Increment => 100);
177 -- The table for string elements in string lists
179 type Variable_Kind is (Undefined, List, Single);
180 -- Different kinds of variables
182 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
183 -- The defined kinds of variables
185 Ignored : constant Variable_Kind;
186 -- Used to indicate that a package declaration must be ignored
187 -- while processing the project tree (unknown package name).
189 type Variable_Value (Kind : Variable_Kind := Undefined) is record
190 Project : Project_Id := No_Project;
191 Location : Source_Ptr := No_Location;
192 Default : Boolean := False;
197 Values : String_List_Id := Nil_String;
199 Value : Name_Id := No_Name;
203 -- Values for variables and array elements. Default is True if the
204 -- current value is the default one for the variable
206 Nil_Variable_Value : constant Variable_Value;
207 -- Value of a non existing variable or array element
209 type Variable_Id is new Nat;
210 No_Variable : constant Variable_Id := 0;
211 type Variable is record
212 Next : Variable_Id := No_Variable;
214 Value : Variable_Value;
216 -- To hold the list of variables in a project file and in packages
218 package Variable_Element_Table is new GNAT.Dynamic_Tables
219 (Table_Component_Type => Variable,
220 Table_Index_Type => Variable_Id,
221 Table_Low_Bound => 1,
222 Table_Initial => 200,
223 Table_Increment => 100);
224 -- The table of variable in list of variables
226 type Array_Element_Id is new Nat;
227 No_Array_Element : constant Array_Element_Id := 0;
228 type Array_Element is record
230 Src_Index : Int := 0;
231 Index_Case_Sensitive : Boolean := True;
232 Value : Variable_Value;
233 Next : Array_Element_Id := No_Array_Element;
235 -- Each Array_Element represents an array element and is linked (Next)
236 -- to the next array element, if any, in the array.
238 package Array_Element_Table is new GNAT.Dynamic_Tables
239 (Table_Component_Type => Array_Element,
240 Table_Index_Type => Array_Element_Id,
241 Table_Low_Bound => 1,
242 Table_Initial => 200,
243 Table_Increment => 100);
244 -- The table that contains all array elements
246 type Array_Id is new Nat;
247 No_Array : constant Array_Id := 0;
248 type Array_Data is record
249 Name : Name_Id := No_Name;
250 Value : Array_Element_Id := No_Array_Element;
251 Next : Array_Id := No_Array;
253 -- Each Array_Data value represents an array.
254 -- Value is the id of the first element.
255 -- Next is the id of the next array in the project file or package.
257 package Array_Table is new GNAT.Dynamic_Tables
258 (Table_Component_Type => Array_Data,
259 Table_Index_Type => Array_Id,
260 Table_Low_Bound => 1,
261 Table_Initial => 200,
262 Table_Increment => 100);
263 -- The table that contains all arrays
265 type Package_Id is new Nat;
266 No_Package : constant Package_Id := 0;
267 type Declarations is record
268 Variables : Variable_Id := No_Variable;
269 Attributes : Variable_Id := No_Variable;
270 Arrays : Array_Id := No_Array;
271 Packages : Package_Id := No_Package;
273 -- Contains the declarations (variables, single and array attributes,
274 -- packages) for a project or a package in a project.
276 No_Declarations : constant Declarations :=
277 (Variables => No_Variable,
278 Attributes => No_Variable,
280 Packages => No_Package);
281 -- Default value of Declarations: indicates that there is no declarations
283 type Package_Element is record
284 Name : Name_Id := No_Name;
285 Decl : Declarations := No_Declarations;
286 Parent : Package_Id := No_Package;
287 Next : Package_Id := No_Package;
289 -- A package (includes declarations that may include other packages)
291 package Package_Table is new GNAT.Dynamic_Tables
292 (Table_Component_Type => Package_Element,
293 Table_Index_Type => Package_Id,
294 Table_Low_Bound => 1,
295 Table_Initial => 100,
296 Table_Increment => 100);
297 -- The table that contains all packages
299 type Language_Index is new Nat;
300 -- Index of language data
302 No_Language_Index : constant Language_Index := 0;
303 -- Constant indicating that there is no language data
305 procedure Display_Language_Name
306 (In_Tree : Project_Tree_Ref;
307 Language : Language_Index);
308 -- Output the name of a language
310 type Header_Num is range 0 .. 6150;
311 -- Size for hash table below. The upper bound is an arbitrary value, the
312 -- value here was chosen after testing to determine a good compromise
313 -- between speed of access and memory usage.
315 function Hash (Name : Name_Id) return Header_Num;
316 function Hash (Name : File_Name_Type) return Header_Num;
317 function Hash (Name : Path_Name_Type) return Header_Num;
318 -- Used for computing hash values for names put into above hash table
320 type Language_Kind is (File_Based, Unit_Based);
321 -- Type for the kind of language. All languages are file based, except Ada
322 -- which is unit based.
324 type Dependency_File_Kind is (None, Makefile, ALI_File);
325 -- Type of dependency to be checked: no dependency file, Makefile fragment
326 -- or ALI file (for Ada).
328 Makefile_Dependency_Suffix : constant String := ".d";
329 ALI_Dependency_Suffix : constant String := ".ali";
331 Switches_Dependency_Suffix : constant String := ".cswi";
333 Binder_Exchange_Suffix : constant String := ".bexch";
334 -- Suffix for binder exchange files
336 Library_Exchange_Suffix : constant String := ".lexch";
337 -- Suffix for library exchange files
339 type Name_List_Index is new Nat;
340 No_Name_List : constant Name_List_Index := 0;
342 type Name_Node is record
343 Name : Name_Id := No_Name;
344 Next : Name_List_Index := No_Name_List;
347 package Name_List_Table is new GNAT.Dynamic_Tables
348 (Table_Component_Type => Name_Node,
349 Table_Index_Type => Name_List_Index,
350 Table_Low_Bound => 1,
352 Table_Increment => 100);
353 -- The table for lists of names used in package Language_Processing
355 package Mapping_Files_Htable is new Simple_HTable
356 (Header_Num => Header_Num,
357 Element => Path_Name_Type,
358 No_Element => No_Path,
359 Key => Path_Name_Type,
362 -- A hash table to store the mapping files that are not used
364 type Lang_Naming_Data is record
365 Dot_Replacement : File_Name_Type := No_File;
366 -- The string to replace '.' in the source file name (for Ada)
368 Casing : Casing_Type := All_Lower_Case;
369 -- The casing of the source file name (for Ada)
371 Separate_Suffix : File_Name_Type := No_File;
372 -- String to append to unit name for source file name of an Ada subunit
374 Spec_Suffix : File_Name_Type := No_File;
375 -- The string to append to the unit name for the
376 -- source file name of a spec.
378 Body_Suffix : File_Name_Type := No_File;
379 -- The string to append to the unit name for the
380 -- source file name of a body.
383 No_Lang_Naming_Data : constant Lang_Naming_Data :=
384 (Dot_Replacement => No_File,
385 Casing => All_Lower_Case,
386 Separate_Suffix => No_File,
387 Spec_Suffix => No_File,
388 Body_Suffix => No_File);
390 type Source_Id is new Nat;
392 No_Source : constant Source_Id := 0;
394 type Language_Config is record
395 Kind : Language_Kind := File_Based;
396 -- Kind of language. All languages are file based, except Ada which is
399 Naming_Data : Lang_Naming_Data;
400 -- The naming data for the languages (prefixes, etc.)
402 Include_Compatible_Languages : Name_List_Index := No_Name_List;
403 -- The list of languages that are "include compatible" with this
404 -- language. A language B (for example "C") is "include compatible" with
405 -- a language A (for example "C++") if it is expected that sources of
406 -- language A may "include" header files from language B.
408 Compiler_Driver : File_Name_Type := No_File;
409 -- The name of the executable for the compiler of the language
411 Compiler_Driver_Path : String_Access := null;
412 -- The path name of the executable for the compiler of the language
414 Compiler_Required_Switches : Name_List_Index := No_Name_List;
415 -- The list of switches that are required as a minimum to invoke the
418 Compilation_PIC_Option : Name_List_Index := No_Name_List;
419 -- The option(s) to compile a source in Position Independent Code for
420 -- shared libraries. Specified in the configuration. When not specified,
421 -- there is no need for such switch.
423 Runtime_Library_Dir : Name_Id := No_Name;
424 -- Path name of the runtime library directory, if any
426 Mapping_File_Switches : Name_List_Index := No_Name_List;
427 -- The option(s) to provide a mapping file to the compiler. Specified in
428 -- the configuration. When value is No_Name_List, there is no mapping
431 Mapping_Spec_Suffix : File_Name_Type := No_File;
432 -- Placeholder representing the spec suffix in a mapping file
434 Mapping_Body_Suffix : File_Name_Type := No_File;
435 -- Placeholder representing the body suffix in a mapping file
437 Config_File_Switches : Name_List_Index := No_Name_List;
438 -- The option(s) to provide a config file to the compiler. Specified in
439 -- the configuration. When value is No_Name_List, there is no config
442 Dependency_Kind : Dependency_File_Kind := None;
443 -- The kind of dependency to be checked: none, Makefile fragment or
444 -- ALI file (for Ada).
446 Dependency_Option : Name_List_Index := No_Name_List;
447 -- The option(s) to be used to create the dependency file. When value is
448 -- No_Name_List, there is not such option(s).
450 Compute_Dependency : Name_List_Index := No_Name_List;
451 -- Hold the value of attribute Dependency_Driver, if declared for the
454 Include_Option : Name_List_Index := No_Name_List;
455 -- Hold the value of attribute Include_Switches, if declared for the
458 Include_Path : Name_Id := No_Name;
459 -- Name of environment variable declared by attribute Include_Path for
462 Include_Path_File : Name_Id := No_Name;
463 -- Name of environment variable declared by attribute Include_Path_File
466 Objects_Path : Name_Id := No_Name;
467 -- Name of environment variable declared by attribute Objects_Path for
470 Objects_Path_File : Name_Id := No_Name;
471 -- Name of environment variable declared by attribute Objects_Path_File
474 Config_Body : Name_Id := No_Name;
475 -- The template for a pragma Source_File_Name(_Project) for a specific
476 -- file name of a body.
478 Config_Spec : Name_Id := No_Name;
479 -- The template for a pragma Source_File_Name(_Project) for a specific
480 -- file name of a spec.
482 Config_Body_Pattern : Name_Id := No_Name;
483 -- The template for a pragma Source_File_Name(_Project) for a naming
486 Config_Spec_Pattern : Name_Id := No_Name;
487 -- The template for a pragma Source_File_Name(_Project) for a naming
490 Config_File_Unique : Boolean := False;
491 -- Indicate if the config file specified to the compiler needs to be
492 -- unique. If it is unique, then all config files are concatenated into
493 -- a temp config file.
495 Binder_Driver : File_Name_Type := No_File;
496 -- The name of the binder driver for the language, if any
498 Binder_Driver_Path : Path_Name_Type := No_Path;
499 -- The path name of the binder driver
501 Binder_Required_Switches : Name_List_Index := No_Name_List;
502 -- Hold the value of attribute Binder'Required_Switches for the language
504 Binder_Prefix : Name_Id := No_Name;
505 -- Hold the value of attribute Binder'Prefix for the language
507 Toolchain_Version : Name_Id := No_Name;
508 -- Hold the value of attribute Toolchain_Version for the language
510 Toolchain_Description : Name_Id := No_Name;
511 -- Hold the value of attribute Toolchain_Description for the language
513 PIC_Option : Name_Id := No_Name;
514 -- Hold the value of attribute Compiler'PIC_Option for the language
516 Objects_Generated : Boolean := True;
517 -- Indicates if objects are generated for the language
520 -- Record describing the configuration of a language
522 No_Language_Config : constant Language_Config :=
524 Naming_Data => No_Lang_Naming_Data,
525 Include_Compatible_Languages => No_Name_List,
526 Compiler_Driver => No_File,
527 Compiler_Driver_Path => null,
528 Compiler_Required_Switches => No_Name_List,
529 Compilation_PIC_Option => No_Name_List,
530 Runtime_Library_Dir => No_Name,
531 Mapping_File_Switches => No_Name_List,
532 Mapping_Spec_Suffix => No_File,
533 Mapping_Body_Suffix => No_File,
534 Config_File_Switches => No_Name_List,
535 Dependency_Kind => Makefile,
536 Dependency_Option => No_Name_List,
537 Compute_Dependency => No_Name_List,
538 Include_Option => No_Name_List,
539 Include_Path => No_Name,
540 Include_Path_File => No_Name,
541 Objects_Path => No_Name,
542 Objects_Path_File => No_Name,
543 Config_Body => No_Name,
544 Config_Spec => No_Name,
545 Config_Body_Pattern => No_Name,
546 Config_Spec_Pattern => No_Name,
547 Config_File_Unique => False,
548 Binder_Driver => No_File,
549 Binder_Driver_Path => No_Path,
550 Binder_Required_Switches => No_Name_List,
551 Binder_Prefix => No_Name,
552 Toolchain_Version => No_Name,
553 Toolchain_Description => No_Name,
554 PIC_Option => No_Name,
555 Objects_Generated => True);
557 type Language_Data is record
558 Name : Name_Id := No_Name;
559 Display_Name : Name_Id := No_Name;
560 Config : Language_Config := No_Language_Config;
561 First_Source : Source_Id := No_Source;
562 Mapping_Files : Mapping_Files_Htable.Instance :=
563 Mapping_Files_Htable.Nil;
564 Next : Language_Index := No_Language_Index;
567 No_Language_Data : constant Language_Data :=
569 Display_Name => No_Name,
570 Config => No_Language_Config,
571 First_Source => No_Source,
572 Mapping_Files => Mapping_Files_Htable.Nil,
573 Next => No_Language_Index);
575 package Language_Data_Table is new GNAT.Dynamic_Tables
576 (Table_Component_Type => Language_Data,
577 Table_Index_Type => Language_Index,
578 Table_Low_Bound => 1,
580 Table_Increment => 100);
581 -- The table for lists of names used in package Language_Processing
583 type Alternate_Language_Id is new Nat;
585 No_Alternate_Language : constant Alternate_Language_Id := 0;
587 type Alternate_Language_Data is record
588 Language : Language_Index := No_Language_Index;
589 Next : Alternate_Language_Id := No_Alternate_Language;
592 package Alternate_Language_Table is new GNAT.Dynamic_Tables
593 (Table_Component_Type => Alternate_Language_Data,
594 Table_Index_Type => Alternate_Language_Id,
595 Table_Low_Bound => 1,
597 Table_Increment => 100);
598 -- The table for storing the alternate languages of a header file that
599 -- is used for several languages.
601 type Source_Kind is (Spec, Impl, Sep);
603 type Source_Data is record
604 Project : Project_Id := No_Project;
605 -- Project of the source
607 Language_Name : Name_Id := No_Name;
608 -- Name of the language of the source
610 Language : Language_Index := No_Language_Index;
611 -- Index of the language
613 Lang_Kind : Language_Kind := File_Based;
614 -- Kind of the language
616 Compiled : Boolean := True;
617 -- False when there is no compiler for the language
619 Alternate_Languages : Alternate_Language_Id := No_Alternate_Language;
620 -- List of languages a header file may also be, in addition of
621 -- language Language_Name.
623 Kind : Source_Kind := Spec;
624 -- Kind of the source: spec, body or subunit
626 Dependency : Dependency_File_Kind := None;
627 -- Kind of dependency: none, Makefile fragment or ALI file
629 Other_Part : Source_Id := No_Source;
630 -- Source ID for the other part, if any: for a spec, indicates its body;
631 -- for a body, indicates its spec.
633 Unit : Name_Id := No_Name;
634 -- Name of the unit, if language is unit based
637 -- Index of the source in a multi unit source file
639 Locally_Removed : Boolean := False;
640 -- True if the source has been "excluded"
642 Get_Object : Boolean := False;
643 -- Indicates that the object of the source should be put in the global
644 -- archive. This is for Ada, when only the closure of a main needs to
645 -- be compiled/recompiled.
647 Replaced_By : Source_Id := No_Source;
649 File : File_Name_Type := No_File;
650 -- Canonical file name of the source
652 Display_File : File_Name_Type := No_File;
653 -- File name of the source, for display purposes
655 Path : Path_Name_Type := No_Path;
656 -- Canonical path name of the source
658 Display_Path : Path_Name_Type := No_Path;
659 -- Path name of the source, for display purposes
661 Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
662 -- Time stamp of the source file
664 Object_Project : Project_Id := No_Project;
665 -- Project where the object file is
667 Object_Exists : Boolean := True;
668 -- True if an object file exists
670 Object : File_Name_Type := No_File;
671 -- File name of the object file
673 Current_Object_Path : Path_Name_Type := No_Path;
674 -- Object path of an existing object file
676 Object_Path : Path_Name_Type := No_Path;
677 -- Object path of the real object file
679 Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
680 -- Object file time stamp
682 Dep_Name : File_Name_Type := No_File;
683 -- Dependency file simple name
685 Current_Dep_Path : Path_Name_Type := No_Path;
686 -- Path name of an existing dependency file
688 Dep_Path : Path_Name_Type := No_Path;
689 -- Path name of the real dependency file
691 Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
692 -- Dependency file time stamp
694 Switches : File_Name_Type := No_File;
695 -- File name of the switches file
697 Switches_Path : Path_Name_Type := No_Path;
698 -- Path name of the switches file
700 Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
701 -- Switches file time stamp
703 Naming_Exception : Boolean := False;
704 -- True if the source has an exceptional name
706 Next_In_Sources : Source_Id := No_Source;
707 -- Link to another source in the project tree
709 Next_In_Project : Source_Id := No_Source;
710 -- Link to another source in the project
712 Next_In_Lang : Source_Id := No_Source;
713 -- Link to another source of the same language
716 No_Source_Data : constant Source_Data :=
717 (Project => No_Project,
718 Language_Name => No_Name,
719 Language => No_Language_Index,
720 Lang_Kind => File_Based,
722 Alternate_Languages => No_Alternate_Language,
725 Other_Part => No_Source,
728 Locally_Removed => False,
730 Replaced_By => No_Source,
732 Display_File => No_File,
734 Display_Path => No_Path,
735 Source_TS => Empty_Time_Stamp,
736 Object_Project => No_Project,
737 Object_Exists => True,
739 Current_Object_Path => No_Path,
740 Object_Path => No_Path,
741 Object_TS => Empty_Time_Stamp,
743 Current_Dep_Path => No_Path,
745 Dep_TS => Empty_Time_Stamp,
747 Switches_Path => No_Path,
748 Switches_TS => Empty_Time_Stamp,
749 Naming_Exception => False,
750 Next_In_Sources => No_Source,
751 Next_In_Project => No_Source,
752 Next_In_Lang => No_Source);
754 package Source_Data_Table is new GNAT.Dynamic_Tables
755 (Table_Component_Type => Source_Data,
756 Table_Index_Type => Source_Id,
757 Table_Low_Bound => 1,
758 Table_Initial => 1000,
759 Table_Increment => 100);
760 -- The table for the sources
762 package Source_Paths_Htable is new Simple_HTable
763 (Header_Num => Header_Num,
764 Element => Source_Id,
765 No_Element => No_Source,
766 Key => Path_Name_Type,
769 -- Mapping of source paths to source ids
771 type Verbosity is (Default, Medium, High);
772 -- Verbosity when parsing GNAT Project Files
773 -- Default is default (very quiet, if no errors).
774 -- Medium is more verbose.
775 -- High is extremely verbose.
777 Current_Verbosity : Verbosity := Default;
778 -- The current value of the verbosity the project files are parsed with
780 type Lib_Kind is (Static, Dynamic, Relocatable);
782 type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
783 -- Type to specify the symbol policy, when symbol control is supported.
784 -- See full explanation about this type in package Symbols.
785 -- Autonomous: Create a symbol file without considering any reference
786 -- Compliant: Try to be as compatible as possible with an existing ref
787 -- Controlled: Fail if symbols are not the same as those in the reference
788 -- Restricted: Restrict the symbols to those in the symbol file
789 -- Direct: The symbol file is used as is
791 type Symbol_Record is record
792 Symbol_File : Path_Name_Type := No_Path;
793 Reference : Path_Name_Type := No_Path;
794 Symbol_Policy : Policy := Autonomous;
796 -- Type to keep the symbol data to be used when building a shared library
798 No_Symbols : constant Symbol_Record :=
799 (Symbol_File => No_Path,
800 Reference => No_Path,
801 Symbol_Policy => Autonomous);
802 -- The default value of the symbol data
804 function Image (Casing : Casing_Type) return String;
805 -- Similar to 'Image (but avoid use of this attribute in compiler)
807 function Value (Image : String) return Casing_Type;
808 -- Similar to 'Value (but avoid use of this attribute in compiler)
809 -- Raises Constraint_Error if not a Casing_Type image.
811 -- Declarations for gprmake:
813 First_Language_Index : constant Language_Index := 1;
814 First_Language_Indexes_Last : constant Language_Index := 5;
816 Ada_Language_Index : constant Language_Index :=
817 First_Language_Index;
818 C_Language_Index : constant Language_Index :=
819 Ada_Language_Index + 1;
820 C_Plus_Plus_Language_Index : constant Language_Index :=
821 C_Language_Index + 1;
823 Last_Language_Index : Language_Index := No_Language_Index;
825 subtype First_Language_Indexes is Language_Index
826 range First_Language_Index .. First_Language_Indexes_Last;
828 package Language_Indexes is new System.HTable.Simple_HTable
829 (Header_Num => Header_Num,
830 Element => Language_Index,
831 No_Element => No_Language_Index,
835 -- Mapping of language names to language indexes
837 package Language_Names is new Table.Table
838 (Table_Component_Type => Name_Id,
839 Table_Index_Type => Language_Index,
840 Table_Low_Bound => 1,
842 Table_Increment => 100,
843 Table_Name => "Prj.Language_Names");
844 -- The table for the name of programming languages
846 procedure Add_Language_Name (Name : Name_Id);
848 procedure Display_Language_Name (Language : Language_Index);
850 type Languages_In_Project is array (First_Language_Indexes) of Boolean;
851 -- Set of supported languages used in a project
853 No_Languages : constant Languages_In_Project := (others => False);
854 -- No supported languages are used
856 type Supp_Language_Index is new Nat;
857 No_Supp_Language_Index : constant Supp_Language_Index := 0;
859 type Supp_Language is record
860 Index : Language_Index := No_Language_Index;
861 Present : Boolean := False;
862 Next : Supp_Language_Index := No_Supp_Language_Index;
865 package Present_Language_Table is new GNAT.Dynamic_Tables
866 (Table_Component_Type => Supp_Language,
867 Table_Index_Type => Supp_Language_Index,
868 Table_Low_Bound => 1,
870 Table_Increment => 100);
871 -- The table for the presence of languages with an index that is outside
872 -- of First_Language_Indexes.
874 type Impl_Suffix_Array is array (First_Language_Indexes) of File_Name_Type;
875 -- Suffixes for the non spec sources of the different supported languages
878 No_Impl_Suffixes : constant Impl_Suffix_Array := (others => No_File);
879 -- A default value for the non spec source suffixes
881 type Supp_Suffix is record
882 Index : Language_Index := No_Language_Index;
883 Suffix : File_Name_Type := No_File;
884 Next : Supp_Language_Index := No_Supp_Language_Index;
887 package Supp_Suffix_Table is new GNAT.Dynamic_Tables
888 (Table_Component_Type => Supp_Suffix,
889 Table_Index_Type => Supp_Language_Index,
890 Table_Low_Bound => 1,
892 Table_Increment => 100);
893 -- The table for the presence of languages with an index that is outside
894 -- of First_Language_Indexes.
896 type Lang_Kind is (GNU, Other);
898 type Language_Processing_Data is record
899 Compiler_Drivers : Name_List_Index := No_Name_List;
900 Compiler_Paths : Name_Id := No_Name;
901 Compiler_Kinds : Lang_Kind := GNU;
902 Dependency_Options : Name_List_Index := No_Name_List;
903 Compute_Dependencies : Name_List_Index := No_Name_List;
904 Include_Options : Name_List_Index := No_Name_List;
905 Binder_Drivers : Name_Id := No_Name;
906 Binder_Driver_Paths : Name_Id := No_Name;
909 Default_Language_Processing_Data :
910 constant Language_Processing_Data :=
911 (Compiler_Drivers => No_Name_List,
912 Compiler_Paths => No_Name,
913 Compiler_Kinds => GNU,
914 Dependency_Options => No_Name_List,
915 Compute_Dependencies => No_Name_List,
916 Include_Options => No_Name_List,
917 Binder_Drivers => No_Name,
918 Binder_Driver_Paths => No_Name);
920 type First_Language_Processing_Data is
921 array (First_Language_Indexes) of Language_Processing_Data;
923 Default_First_Language_Processing_Data :
924 constant First_Language_Processing_Data :=
925 (others => Default_Language_Processing_Data);
927 type Supp_Language_Data is record
928 Index : Language_Index := No_Language_Index;
929 Data : Language_Processing_Data := Default_Language_Processing_Data;
930 Next : Supp_Language_Index := No_Supp_Language_Index;
933 package Supp_Language_Table is new GNAT.Dynamic_Tables
934 (Table_Component_Type => Supp_Language_Data,
935 Table_Index_Type => Supp_Language_Index,
936 Table_Low_Bound => 1,
938 Table_Increment => 100);
939 -- The table for language data when there are more languages than
940 -- in First_Language_Indexes.
942 type Other_Source_Id is new Nat;
943 No_Other_Source : constant Other_Source_Id := 0;
945 type Other_Source is record
946 Language : Language_Index; -- language of the source
947 File_Name : File_Name_Type; -- source file simple name
948 Path_Name : Path_Name_Type; -- source full path name
949 Source_TS : Time_Stamp_Type; -- source file time stamp
950 Object_Name : File_Name_Type; -- object file simple name
951 Object_Path : Path_Name_Type; -- object full path name
952 Object_TS : Time_Stamp_Type; -- object file time stamp
953 Dep_Name : File_Name_Type; -- dependency file simple name
954 Dep_Path : Path_Name_Type; -- dependency full path name
955 Dep_TS : Time_Stamp_Type; -- dependency file time stamp
956 Naming_Exception : Boolean := False; -- True if a naming exception
957 Next : Other_Source_Id := No_Other_Source;
959 -- Data for a source in a language other than Ada
961 package Other_Source_Table is new GNAT.Dynamic_Tables
962 (Table_Component_Type => Other_Source,
963 Table_Index_Type => Other_Source_Id,
964 Table_Low_Bound => 1,
965 Table_Initial => 200,
966 Table_Increment => 100);
967 -- The table for sources of languages other than Ada
969 -- The following record contains data for a naming scheme
971 type Naming_Data is record
973 Dot_Replacement : File_Name_Type := No_File;
974 -- The string to replace '.' in the source file name (for Ada)
976 Dot_Repl_Loc : Source_Ptr := No_Location;
978 Casing : Casing_Type := All_Lower_Case;
979 -- The casing of the source file name (for Ada)
981 Spec_Suffix : Array_Element_Id := No_Array_Element;
982 -- The string to append to the unit name for the
983 -- source file name of a spec.
984 -- Indexed by the programming language.
986 Ada_Spec_Suffix_Loc : Source_Ptr := No_Location;
988 Body_Suffix : Array_Element_Id := No_Array_Element;
989 -- The string to append to the unit name for the
990 -- source file name of a body.
991 -- Indexed by the programming language.
993 Ada_Body_Suffix_Loc : Source_Ptr := No_Location;
995 Separate_Suffix : File_Name_Type := No_File;
996 -- String to append to unit name for source file name of an Ada subunit
998 Sep_Suffix_Loc : Source_Ptr := No_Location;
999 -- Position in the project file source where Separate_Suffix is defined
1001 Specs : Array_Element_Id := No_Array_Element;
1002 -- An associative array mapping individual specs to source file names
1003 -- This is specific to Ada.
1005 Bodies : Array_Element_Id := No_Array_Element;
1006 -- An associative array mapping individual bodies to source file names
1007 -- This is specific to Ada.
1009 Specification_Exceptions : Array_Element_Id := No_Array_Element;
1010 -- An associative array listing spec file names that do not have the
1011 -- spec suffix. Not used by Ada. Indexed by programming language name.
1013 Implementation_Exceptions : Array_Element_Id := No_Array_Element;
1014 -- An associative array listing body file names that do not have the
1015 -- body suffix. Not used by Ada. Indexed by programming language name.
1019 Impl_Suffixes : Impl_Suffix_Array := No_Impl_Suffixes;
1020 Supp_Suffixes : Supp_Language_Index := No_Supp_Language_Index;
1023 function Spec_Suffix_Of
1024 (In_Tree : Project_Tree_Ref;
1026 Naming : Naming_Data) return String;
1028 function Spec_Suffix_Id_Of
1029 (In_Tree : Project_Tree_Ref;
1031 Naming : Naming_Data) return File_Name_Type;
1033 function Spec_Suffix_Id_Of
1034 (In_Tree : Project_Tree_Ref;
1035 Language_Id : Name_Id;
1036 Naming : Naming_Data) return File_Name_Type;
1038 procedure Set_Spec_Suffix
1039 (In_Tree : Project_Tree_Ref;
1041 Naming : in out Naming_Data;
1042 Suffix : File_Name_Type);
1044 function Body_Suffix_Id_Of
1045 (In_Tree : Project_Tree_Ref;
1047 Naming : Naming_Data) return File_Name_Type;
1049 function Body_Suffix_Id_Of
1050 (In_Tree : Project_Tree_Ref;
1051 Language_Id : Name_Id;
1052 Naming : Naming_Data) return File_Name_Type;
1054 function Body_Suffix_Of
1055 (In_Tree : Project_Tree_Ref;
1057 Naming : Naming_Data) return String;
1059 procedure Set_Body_Suffix
1060 (In_Tree : Project_Tree_Ref;
1062 Naming : in out Naming_Data;
1063 Suffix : File_Name_Type);
1065 function Objects_Exist_For
1067 In_Tree : Project_Tree_Ref) return Boolean;
1069 function Standard_Naming_Data
1070 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
1071 pragma Inline (Standard_Naming_Data);
1072 -- The standard GNAT naming scheme when Tree is No_Project_Tree.
1073 -- Otherwise, return the default naming scheme for the project tree Tree,
1074 -- which must have been Initialized.
1076 function Same_Naming_Scheme
1077 (Left, Right : Naming_Data) return Boolean;
1078 -- Returns True if Left and Right are the same naming scheme
1079 -- not considering Specs and Bodies.
1081 type Project_List is new Nat;
1082 Empty_Project_List : constant Project_List := 0;
1083 -- A list of project files
1085 type Project_Element is record
1086 Project : Project_Id := No_Project;
1087 Next : Project_List := Empty_Project_List;
1089 -- Element in a list of project files. Next is the id of the next
1090 -- project file in the list.
1092 package Project_List_Table is new GNAT.Dynamic_Tables
1093 (Table_Component_Type => Project_Element,
1094 Table_Index_Type => Project_List,
1095 Table_Low_Bound => 1,
1096 Table_Initial => 100,
1097 Table_Increment => 100);
1098 -- The table that contains the lists of project files
1100 type Project_Configuration is record
1101 Run_Path_Option : Name_List_Index := No_Name_List;
1102 -- The option to use when linking to specify the path where to look
1105 Executable_Suffix : Name_Id := No_Name;
1106 -- The suffix of executables, when specified in the configuration
1107 -- or in package Builder of the main project. When this is not
1108 -- specified, the executable suffix is the default for the platform.
1112 Linker : Path_Name_Type := No_Path;
1113 -- Path name of the linker driver. Specified in the configuration
1114 -- or in the package Builder of the main project.
1116 Minimum_Linker_Options : Name_List_Index := No_Name_List;
1117 -- The minimum options for the linker driver. Specified in the
1120 Linker_Executable_Option : Name_List_Index := No_Name_List;
1121 -- The option(s) to indicate the name of the executable in the
1122 -- linker command. Specified in the configuration. When not
1123 -- specified, default to -o <executable name>.
1125 Linker_Lib_Dir_Option : Name_Id := No_Name;
1126 -- The option to specify where to find a library for linking.
1127 -- Specified in the configuration. When not specified, defaults to
1130 Linker_Lib_Name_Option : Name_Id := No_Name;
1131 -- The option to specify the name of a library for linking. Specified
1132 -- in the configuration. When not specified, defaults to "-l".
1136 Library_Builder : Path_Name_Type := No_Path;
1137 -- The executable to build library (specified in the configuration)
1139 Lib_Support : Library_Support := None;
1140 -- The level of library support. Specified in the configuration.
1141 -- Support is none, static libraries only or both static and shared
1146 Archive_Builder : Name_List_Index := No_Name_List;
1147 -- The name of the executable to build archives, with the minimum
1148 -- switches. Specified in the configuration.
1150 Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
1151 -- The options to append object files to an archive
1153 Archive_Indexer : Name_List_Index := No_Name_List;
1154 -- The name of the executable to index archives, with the minimum
1155 -- switches. Specified in the configuration.
1157 Archive_Suffix : File_Name_Type := No_File;
1158 -- The suffix of archives. Specified in the configuration. When not
1159 -- specified, defaults to ".a".
1161 Lib_Partial_Linker : Name_List_Index := No_Name_List;
1165 Shared_Lib_Prefix : File_Name_Type := No_File;
1166 -- Part of a shared library file name that precedes the name of the
1167 -- library. Specified in the configuration. When not specified,
1168 -- defaults to "lib".
1170 Shared_Lib_Suffix : File_Name_Type := No_File;
1171 -- Suffix of shared libraries, after the library name in the shared
1172 -- library name. Specified in the configuration. When not specified,
1173 -- default to ".so".
1175 Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
1178 Lib_Version_Options : Name_List_Index := No_Name_List;
1181 Symbolic_Link_Supported : Boolean := False;
1184 Lib_Maj_Min_Id_Supported : Boolean := False;
1187 Auto_Init_Supported : Boolean := False;
1191 Default_Project_Config : constant Project_Configuration :=
1192 (Run_Path_Option => No_Name_List,
1193 Executable_Suffix => No_Name,
1195 Minimum_Linker_Options => No_Name_List,
1196 Linker_Executable_Option => No_Name_List,
1197 Linker_Lib_Dir_Option => No_Name,
1198 Linker_Lib_Name_Option => No_Name,
1199 Library_Builder => No_Path,
1200 Lib_Support => None,
1201 Archive_Builder => No_Name_List,
1202 Archive_Builder_Append_Option => No_Name_List,
1203 Archive_Indexer => No_Name_List,
1204 Archive_Suffix => No_File,
1205 Lib_Partial_Linker => No_Name_List,
1206 Shared_Lib_Prefix => No_File,
1207 Shared_Lib_Suffix => No_File,
1208 Shared_Lib_Min_Options => No_Name_List,
1209 Lib_Version_Options => No_Name_List,
1210 Symbolic_Link_Supported => False,
1211 Lib_Maj_Min_Id_Supported => False,
1212 Auto_Init_Supported => False);
1214 -- The following record describes a project file representation
1216 -- Note that it is not specified if the path names of directories (source,
1217 -- object, library or exec directories) end with or without a directory
1220 type Project_Data is record
1221 Qualifier : Project_Qualifier := Unspecified;
1222 -- The eventual qualifier for this project
1224 Externally_Built : Boolean := False;
1225 -- True if the project is externally built. In such case, the Project
1226 -- Manager will not modify anything in this project.
1228 Languages : Name_List_Index := No_Name_List;
1229 -- The list of languages of the sources of this project
1231 Config : Project_Configuration;
1233 First_Referred_By : Project_Id := No_Project;
1234 -- The project, if any, that was the first to be known as importing or
1235 -- extending this project
1237 Name : Name_Id := No_Name;
1238 -- The name of the project
1240 Display_Name : Name_Id := No_Name;
1241 -- The name of the project with the spelling of its declaration
1243 Path_Name : Path_Name_Type := No_Path;
1244 -- The path name of the project file
1246 Display_Path_Name : Path_Name_Type := No_Path;
1247 -- The path name used for display purposes. May be different from
1248 -- Path_Name for platforms where the file names are case-insensitive.
1250 Virtual : Boolean := False;
1251 -- True for virtual extending projects
1253 Location : Source_Ptr := No_Location;
1254 -- The location in the project file source of the reserved word project
1256 Mains : String_List_Id := Nil_String;
1257 -- List of mains specified by attribute Main
1259 Directory : Path_Name_Type := No_Path;
1260 -- Path name of the directory where the project file resides
1262 Display_Directory : Path_Name_Type := No_Path;
1263 -- The path name of the project directory, for display purposes. May be
1264 -- different from Directory for platforms where the file names are
1265 -- case-insensitive.
1267 Dir_Path : String_Access;
1268 -- Same as Directory, but as an access to String
1270 Library : Boolean := False;
1271 -- True if this is a library project
1273 Library_Dir : Path_Name_Type := No_Path;
1274 -- If a library project, path name of the directory where the library
1277 Display_Library_Dir : Path_Name_Type := No_Path;
1278 -- The path name of the library directory, for display purposes. May be
1279 -- different from Library_Dir for platforms where the file names are
1280 -- case-insensitive.
1282 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
1283 -- The timestamp of a library file in a library project
1285 Library_Src_Dir : Path_Name_Type := No_Path;
1286 -- If a Stand-Alone Library project, path name of the directory where
1287 -- the sources of the interfaces of the library are copied. By default,
1288 -- if attribute Library_Src_Dir is not specified, sources of the
1289 -- interfaces are not copied anywhere.
1291 Display_Library_Src_Dir : Path_Name_Type := No_Path;
1292 -- The path name of the library source directory, for display purposes.
1293 -- May be different from Library_Src_Dir for platforms where the file
1294 -- names are case-insensitive.
1296 Library_ALI_Dir : Path_Name_Type := No_Path;
1297 -- In a library project, path name of the directory where the ALI files
1298 -- are copied. If attribute Library_ALI_Dir is not specified, ALI files
1299 -- are copied in the Library_Dir.
1301 Display_Library_ALI_Dir : Path_Name_Type := No_Path;
1302 -- The path name of the library ALI directory, for display purposes. May
1303 -- be different from Library_ALI_Dir for platforms where the file names
1304 -- are case-insensitive.
1306 Library_Name : Name_Id := No_Name;
1307 -- If a library project, name of the library
1309 Library_Kind : Lib_Kind := Static;
1310 -- If a library project, kind of library
1312 Lib_Internal_Name : Name_Id := No_Name;
1313 -- If a library project, internal name store inside the library
1315 Standalone_Library : Boolean := False;
1316 -- Indicate that this is a Standalone Library Project File
1318 Lib_Interface_ALIs : String_List_Id := Nil_String;
1319 -- For Standalone Library Project Files, indicate the list of Interface
1322 Lib_Auto_Init : Boolean := False;
1323 -- For non static Stand-Alone Library Project Files, indicate if
1324 -- the library initialisation should be automatic.
1326 Libgnarl_Needed : Yes_No_Unknown := Unknown;
1327 -- Set to True when libgnarl is needed to link
1329 Symbol_Data : Symbol_Record := No_Symbols;
1330 -- Symbol file name, reference symbol file name, symbol policy
1332 Ada_Sources : String_List_Id := Nil_String;
1333 -- The list of all the Ada source file names (gnatmake only)
1335 Sources : String_List_Id := Nil_String;
1336 -- Identical to Ada_Sources (for upward compatibility with GPS)
1338 First_Source : Source_Id := No_Source;
1339 Last_Source : Source_Id := No_Source;
1340 -- Head and tail of the list of sources
1342 Unit_Based_Language_Name : Name_Id := No_Name;
1343 Unit_Based_Language_Index : Language_Index := No_Language_Index;
1344 -- The name and index, if any, of the unit-based language of some
1345 -- sources of the project. There may be only one unit-based language
1348 Imported_Directories_Switches : Argument_List_Access := null;
1349 -- List of the source search switches (-I<source dir>) to be used when
1352 Include_Path : String_Access := null;
1353 -- Value of the environment variable to indicate the source search path,
1354 -- instead of a list of switches (Imported_Directories_Switches).
1356 Include_Path_File : Path_Name_Type := No_Path;
1357 -- The path name of the of the source search directory file
1359 Include_Data_Set : Boolean := False;
1360 -- Set True when Imported_Directories_Switches or Include_Path are set
1362 Include_Language : Language_Index := No_Language_Index;
1364 Source_Dirs : String_List_Id := Nil_String;
1365 -- The list of all the source directories
1367 Known_Order_Of_Source_Dirs : Boolean := True;
1368 -- False, if there is any /** in the Source_Dirs, because in this case
1369 -- the ordering of the source subdirs depend on the OS. If True,
1370 -- duplicate file names in the same project file are allowed.
1372 Object_Directory : Path_Name_Type := No_Path;
1373 -- The path name of the object directory of this project file
1375 Display_Object_Dir : Path_Name_Type := No_Path;
1376 -- The path name of the object directory, for display purposes. May be
1377 -- different from Object_Directory for platforms where the file names
1378 -- are case-insensitive.
1380 Exec_Directory : Path_Name_Type := No_Path;
1381 -- The path name of the exec directory of this project file. Default is
1382 -- equal to Object_Directory.
1384 Display_Exec_Dir : Path_Name_Type := No_Path;
1385 -- The path name of the exec directory, for display purposes. May be
1386 -- different from Exec_Directory for platforms where the file names are
1387 -- case-insensitive.
1389 Extends : Project_Id := No_Project;
1390 -- The reference of the project file, if any, that this project file
1393 Extended_By : Project_Id := No_Project;
1394 -- The reference of the project file, if any, that extends this project
1397 Naming : Naming_Data := Standard_Naming_Data;
1398 -- The naming scheme of this project file
1400 First_Language_Processing : Language_Index := No_Language_Index;
1401 -- First index of the language data in the project
1403 Decl : Declarations := No_Declarations;
1404 -- The declarations (variables, attributes and packages) of this project
1407 Imported_Projects : Project_List := Empty_Project_List;
1408 -- The list of all directly imported projects, if any
1410 All_Imported_Projects : Project_List := Empty_Project_List;
1411 -- The list of all projects imported directly or indirectly, if any
1413 Ada_Include_Path : String_Access := null;
1414 -- The cached value of ADA_INCLUDE_PATH for this project file. Do not
1415 -- use this field directly outside of the compiler, use
1416 -- Prj.Env.Ada_Include_Path instead.
1418 Ada_Objects_Path : String_Access := null;
1419 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
1420 -- use this field directly outside of the compiler, use
1421 -- Prj.Env.Ada_Objects_Path instead.
1423 Objects_Path : String_Access := null;
1424 -- The cached value of the object dir path, used during the binding
1425 -- phase of gprbuild.
1427 Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
1428 -- The cached value of the object path temp file (including library
1429 -- dirs) for this project file.
1431 Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
1432 -- The cached value of the object path temp file (excluding library
1433 -- dirs) for this project file.
1435 Config_File_Name : Path_Name_Type := No_Path;
1436 -- The path name of the configuration pragmas file, if any
1438 Config_File_Temp : Boolean := False;
1439 -- An indication that the configuration pragmas file is a temporary file
1440 -- that must be deleted at the end.
1442 Linker_Name : File_Name_Type := No_File;
1443 -- Value of attribute Language_Processing'Linker in the project file
1445 Linker_Path : Path_Name_Type := No_Path;
1446 -- Path of linker when attribute Language_Processing'Linker is specified
1448 Minimum_Linker_Options : Name_List_Index := No_Name_List;
1449 -- List of options specified in attribute
1450 -- Language_Processing'Minimum_Linker_Options.
1452 Config_Checked : Boolean := False;
1453 -- A flag to avoid checking repetitively the configuration pragmas file
1455 Checked : Boolean := False;
1456 -- A flag to avoid checking repetitively the naming scheme of this
1459 Seen : Boolean := False;
1460 -- A flag to mark a project as "visited" to avoid processing the same
1461 -- project several time.
1463 Need_To_Build_Lib : Boolean := False;
1464 -- Indicates that the library of a Library Project needs to be built or
1467 Depth : Natural := 0;
1468 -- The maximum depth of a project in the project graph. Depth of main
1471 Unkept_Comments : Boolean := False;
1472 -- True if there are comments in the project sources that cannot be kept
1473 -- in the project tree.
1479 Langs : Languages_In_Project := No_Languages;
1480 Supp_Languages : Supp_Language_Index := No_Supp_Language_Index;
1481 -- Indicate the different languages of the source of this project
1483 Ada_Sources_Present : Boolean := True;
1484 -- True if there are Ada sources in the project
1486 Other_Sources_Present : Boolean := True;
1487 -- True if there are sources from languages other than Ada in the
1490 First_Other_Source : Other_Source_Id := No_Other_Source;
1491 -- First source of a language other than Ada
1493 Last_Other_Source : Other_Source_Id := No_Other_Source;
1494 -- Last source of a language other than Ada
1496 First_Lang_Processing : First_Language_Processing_Data :=
1497 Default_First_Language_Processing_Data;
1498 Supp_Language_Processing : Supp_Language_Index :=
1499 No_Supp_Language_Index;
1500 -- Language configurations
1503 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
1504 -- Return the representation of an empty project in project Tree tree.
1505 -- The project tree Tree must have been Initialized and/or Reset.
1507 function Is_Extending
1508 (Extending : Project_Id;
1509 Extended : Project_Id;
1510 In_Tree : Project_Tree_Ref) return Boolean;
1511 -- ??? needs comment
1513 function Is_A_Language
1514 (Tree : Project_Tree_Ref;
1515 Data : Project_Data;
1516 Language_Name : Name_Id) return Boolean;
1517 -- Return True when Language_Name (which must be lower case) is one of the
1518 -- languages used for the project.
1520 function There_Are_Ada_Sources
1521 (In_Tree : Project_Tree_Ref;
1522 Project : Project_Id) return Boolean;
1523 -- ??? needs comment
1524 -- ??? Name sounds strange, suggested replacement: Ada_Sources_Present
1526 Project_Error : exception;
1527 -- Raised by some subprograms in Prj.Attr
1529 package Project_Table is new GNAT.Dynamic_Tables (
1530 Table_Component_Type => Project_Data,
1531 Table_Index_Type => Project_Id,
1532 Table_Low_Bound => 1,
1533 Table_Initial => 100,
1534 Table_Increment => 100);
1535 -- The set of all project files
1537 type Spec_Or_Body is (Specification, Body_Part);
1539 type File_Name_Data is record
1540 Name : File_Name_Type := No_File;
1542 Display_Name : File_Name_Type := No_File;
1543 Path : Path_Name_Type := No_Path;
1544 Display_Path : Path_Name_Type := No_Path;
1545 Project : Project_Id := No_Project;
1546 Needs_Pragma : Boolean := False;
1548 -- File and Path name of a spec or body
1550 type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
1552 type Unit_Index is new Nat;
1553 No_Unit_Index : constant Unit_Index := 0;
1554 type Unit_Data is record
1555 Name : Name_Id := No_Name;
1556 File_Names : File_Names_Data;
1558 -- Name and File and Path names of a unit, with a reference to its
1559 -- GNAT Project File(s).
1561 package Unit_Table is new GNAT.Dynamic_Tables
1562 (Table_Component_Type => Unit_Data,
1563 Table_Index_Type => Unit_Index,
1564 Table_Low_Bound => 1,
1565 Table_Initial => 100,
1566 Table_Increment => 100);
1567 -- Table of all units in a project tree
1569 package Units_Htable is new Simple_HTable
1570 (Header_Num => Header_Num,
1571 Element => Unit_Index,
1572 No_Element => No_Unit_Index,
1576 -- Mapping of unit names to indexes in the Units table
1578 type Unit_Project is record
1579 Unit : Unit_Index := No_Unit_Index;
1580 Project : Project_Id := No_Project;
1583 No_Unit_Project : constant Unit_Project := (No_Unit_Index, No_Project);
1585 package Files_Htable is new Simple_HTable
1586 (Header_Num => Header_Num,
1587 Element => Unit_Project,
1588 No_Element => No_Unit_Project,
1589 Key => File_Name_Type,
1592 -- Mapping of file names to indexes in the Units table
1594 type Private_Project_Tree_Data is private;
1595 -- Data for a project tree that is used only by the Project Manager
1597 type Project_Tree_Data is
1599 -- Languages and sources of the project
1601 First_Language : Language_Index := No_Language_Index;
1604 First_Source : Source_Id := No_Source;
1609 Languages_Data : Language_Data_Table.Instance;
1610 Name_Lists : Name_List_Table.Instance;
1611 String_Elements : String_Element_Table.Instance;
1612 Variable_Elements : Variable_Element_Table.Instance;
1613 Array_Elements : Array_Element_Table.Instance;
1614 Arrays : Array_Table.Instance;
1615 Packages : Package_Table.Instance;
1616 Project_Lists : Project_List_Table.Instance;
1617 Projects : Project_Table.Instance;
1618 Sources : Source_Data_Table.Instance;
1619 Alt_Langs : Alternate_Language_Table.Instance;
1620 Units : Unit_Table.Instance;
1621 Units_HT : Units_Htable.Instance;
1622 Files_HT : Files_Htable.Instance;
1623 Source_Paths_HT : Source_Paths_Htable.Instance;
1627 Present_Languages : Present_Language_Table.Instance;
1628 Supp_Suffixes : Supp_Suffix_Table.Instance;
1629 Supp_Languages : Supp_Language_Table.Instance;
1630 Other_Sources : Other_Source_Table.Instance;
1634 Private_Part : Private_Project_Tree_Data;
1636 -- Data for a project tree
1638 type Put_Line_Access is access procedure
1640 Project : Project_Id;
1641 In_Tree : Project_Tree_Ref);
1642 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
1644 procedure Expect (The_Token : Token_Type; Token_Image : String);
1645 -- Check that the current token is The_Token. If it is not, then output
1646 -- an error message.
1648 procedure Initialize (Tree : Project_Tree_Ref);
1649 -- This procedure must be called before using any services from the Prj
1650 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
1652 procedure Reset (Tree : Project_Tree_Ref);
1653 -- This procedure resets all the tables that are used when processing a
1654 -- project file tree. Initialize must be called before the call to Reset.
1656 procedure Register_Default_Naming_Scheme
1657 (Language : Name_Id;
1658 Default_Spec_Suffix : File_Name_Type;
1659 Default_Body_Suffix : File_Name_Type;
1660 In_Tree : Project_Tree_Ref);
1661 -- Register the default suffixes for a given language. These extensions
1662 -- will be ignored if the user has specified a new naming scheme in a
1665 -- Otherwise, this information will be automatically added to Naming_Data
1666 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
1669 type State is limited private;
1670 with procedure Action
1671 (Project : Project_Id;
1672 With_State : in out State);
1673 procedure For_Every_Project_Imported
1675 In_Tree : Project_Tree_Ref;
1676 With_State : in out State);
1677 -- Call Action for each project imported directly or indirectly by project
1678 -- By. Action is called according to the order of importation: if A
1679 -- imports B, directly or indirectly, Action will be called for A before
1680 -- it is called for B. If two projects import each other directly or
1681 -- indirectly (using at least one "limited with"), it is not specified
1682 -- for which of these two projects Action will be called first. Projects
1683 -- that are extended by other projects are not considered. With_State may
1684 -- be used by Action to choose a behavior or to report some global result.
1686 function Extend_Name
1687 (File : File_Name_Type;
1688 With_Suffix : String) return File_Name_Type;
1689 -- Replace the extension of File with With_Suffix
1691 function Object_Name
1692 (Source_File_Name : File_Name_Type) return File_Name_Type;
1693 -- Returns the object file name corresponding to a source file name
1695 function Dependency_Name
1696 (Source_File_Name : File_Name_Type;
1697 Dependency : Dependency_File_Kind) return File_Name_Type;
1698 -- Returns the dependency file name corresponding to a source file name
1700 function Switches_Name
1701 (Source_File_Name : File_Name_Type) return File_Name_Type;
1702 -- Returns the switches file name corresponding to a source file name
1706 function Body_Suffix_Of
1707 (Language : Language_Index;
1708 In_Project : Project_Data;
1709 In_Tree : Project_Tree_Ref) return String;
1710 -- Returns the suffix of sources of language Language in project In_Project
1711 -- in project tree In_Tree.
1714 (Language : Language_Index;
1715 In_Project : Project_Data;
1716 In_Tree : Project_Tree_Ref) return Boolean;
1717 -- Return True when Language is one of the languages used in
1718 -- project In_Project.
1721 (Language : Language_Index;
1723 In_Project : in out Project_Data;
1724 In_Tree : Project_Tree_Ref);
1725 -- Indicate if Language is or not a language used in project In_Project
1727 function Language_Processing_Data_Of
1728 (Language : Language_Index;
1729 In_Project : Project_Data;
1730 In_Tree : Project_Tree_Ref) return Language_Processing_Data;
1731 -- Return the Language_Processing_Data for language Language in project
1732 -- In_Project. Return the default when no Language_Processing_Data are
1733 -- defined for the language.
1736 (Language_Processing : Language_Processing_Data;
1737 For_Language : Language_Index;
1738 In_Project : in out Project_Data;
1739 In_Tree : Project_Tree_Ref);
1740 -- Set the Language_Processing_Data for language Language in project
1744 (Language : Language_Index;
1745 In_Project : Project_Data;
1746 In_Tree : Project_Tree_Ref) return File_Name_Type;
1747 -- Return the suffix for language Language in project In_Project. Return
1748 -- No_Name when no suffix is defined for the language.
1751 (Suffix : File_Name_Type;
1752 For_Language : Language_Index;
1753 In_Project : in out Project_Data;
1754 In_Tree : Project_Tree_Ref);
1755 -- Set the suffix for language Language in project In_Project
1761 procedure Record_Temp_File (Path : Path_Name_Type);
1762 -- Record the path of a newly created temporary file, so that it can be
1765 procedure Delete_All_Temp_Files;
1766 -- Delete all recorded temporary files
1770 All_Packages : constant String_List_Access := null;
1772 No_Project_Tree : constant Project_Tree_Ref := null;
1774 Ignored : constant Variable_Kind := Single;
1776 Nil_Variable_Value : constant Variable_Value :=
1777 (Project => No_Project,
1779 Location => No_Location,
1782 Virtual_Prefix : constant String := "v$";
1783 -- The prefix for virtual extending projects. Because of the '$', which is
1784 -- normally forbidden for project names, there cannot be any name clash.
1786 Empty_Name : Name_Id;
1787 -- Name_Id for an empty name (no characters). Initialized in procedure
1790 Empty_File_Name : File_Name_Type;
1791 -- Empty File_Name_Type (no characters). Initialized in procedure
1794 procedure Add_To_Buffer
1796 To : in out String_Access;
1797 Last : in out Natural);
1798 -- Append a String to the Buffer
1800 type Naming_Id is new Nat;
1802 package Naming_Table is new GNAT.Dynamic_Tables
1803 (Table_Component_Type => Naming_Data,
1804 Table_Index_Type => Naming_Id,
1805 Table_Low_Bound => 1,
1807 Table_Increment => 100);
1808 -- Table storing the naming data for gnatmake/gprmake
1810 package Path_File_Table is new GNAT.Dynamic_Tables
1811 (Table_Component_Type => Path_Name_Type,
1812 Table_Index_Type => Natural,
1813 Table_Low_Bound => 1,
1814 Table_Initial => 50,
1815 Table_Increment => 100);
1816 -- Table storing all the temp path file names.
1817 -- Used by Delete_All_Path_Files.
1819 package Source_Path_Table is new GNAT.Dynamic_Tables
1820 (Table_Component_Type => Name_Id,
1821 Table_Index_Type => Natural,
1822 Table_Low_Bound => 1,
1823 Table_Initial => 50,
1824 Table_Increment => 100);
1825 -- A table to store the source dirs before creating the source path file
1827 package Object_Path_Table is new GNAT.Dynamic_Tables
1828 (Table_Component_Type => Path_Name_Type,
1829 Table_Index_Type => Natural,
1830 Table_Low_Bound => 1,
1831 Table_Initial => 50,
1832 Table_Increment => 100);
1833 -- A table to store the object dirs, before creating the object path file
1835 type Private_Project_Tree_Data is record
1836 Namings : Naming_Table.Instance;
1837 Path_Files : Path_File_Table.Instance;
1838 Source_Paths : Source_Path_Table.Instance;
1839 Object_Paths : Object_Path_Table.Instance;
1840 Default_Naming : Naming_Data;
1842 -- Type to represent the part of a project tree which is private to the