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;
35 with Types; use Types;
37 with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
38 with GNAT.Dynamic_Tables;
39 with GNAT.OS_Lib; use GNAT.OS_Lib;
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
48 Subdirs : String_Ptr := null;
49 -- The value after the equal sign in switch --subdirs=...
50 -- Contains the relative subdirectory.
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
57 -- - Full: Library Project Files are supported for static and dynamic
58 -- (shared) libraries.
60 type Yes_No_Unknown is (Yes, No, Unknown);
61 -- Tri-state to decide if -lgnarl is needed when linking
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
67 type Project_Qualifier is
74 -- Qualifiers that can prefix the reserved word "project" in a project
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 ...
82 function Get_Mode return Mode;
83 pragma Inline (Get_Mode);
85 procedure Set_Mode (New_Mode : Mode);
86 pragma Inline (Set_Mode);
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.
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.
99 function In_Configuration return Boolean;
100 pragma Inline (In_Configuration);
102 procedure Set_In_Configuration (Value : Boolean);
103 pragma Inline (Set_In_Configuration);
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.
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
114 No_Project_Tree : constant Project_Tree_Ref;
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.
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.
126 function Slash return Path_Name_Type;
127 pragma Inline (Slash);
128 -- "/", used as the path of locally removed files
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.
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.
140 -- When the situation occurs, the behaviour depends on the setting:
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
146 function Empty_File return File_Name_Type;
147 function Empty_String return Name_Id;
148 -- Return the id for an empty string ""
150 type Path_Information is record
151 Name : Path_Name_Type := No_Path;
152 Display_Name : Path_Name_Type := No_Path;
155 No_Path_Information : constant Path_Information := (No_Path, No_Path);
157 type Project_Id is new Nat;
158 No_Project : constant Project_Id := 0;
159 -- Id of a Project File
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;
166 Display_Value : Name_Id := No_Name;
167 Location : Source_Ptr := No_Location;
168 Flag : Boolean := False;
169 Next : String_List_Id := Nil_String;
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).
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
183 type Variable_Kind is (Undefined, List, Single);
184 -- Different kinds of variables
186 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
187 -- The defined kinds of variables
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).
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;
201 Values : String_List_Id := Nil_String;
203 Value : Name_Id := No_Name;
207 -- Values for variables and array elements. Default is True if the
208 -- current value is the default one for the variable
210 Nil_Variable_Value : constant Variable_Value;
211 -- Value of a non existing variable or array element
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;
218 Value : Variable_Value;
220 -- To hold the list of variables in a project file and in packages
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
230 type Array_Element_Id is new Nat;
231 No_Array_Element : constant Array_Element_Id := 0;
232 type Array_Element is record
234 Src_Index : Int := 0;
235 Index_Case_Sensitive : Boolean := True;
236 Value : Variable_Value;
237 Next : Array_Element_Id := No_Array_Element;
239 -- Each Array_Element represents an array element and is linked (Next)
240 -- to the next array element, if any, in the array.
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
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;
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.
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
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;
277 -- Contains the declarations (variables, single and array attributes,
278 -- packages) for a project or a package in a project.
280 No_Declarations : constant Declarations :=
281 (Variables => No_Variable,
282 Attributes => No_Variable,
284 Packages => No_Package);
285 -- Default value of Declarations: indicates that there is no declarations
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;
293 -- A package (includes declarations that may include other packages)
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
303 type Language_Index is new Nat;
304 -- Index of language data
306 No_Language_Index : constant Language_Index := 0;
307 -- Constant indicating that there is no language data
309 procedure Display_Language_Name
310 (In_Tree : Project_Tree_Ref;
311 Language : Language_Index);
312 -- Output the name of a language
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.
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
325 function Hash (Project : Project_Id) return Header_Num;
326 -- Used for hash tables where Project_Id is the Key
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.
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).
336 Makefile_Dependency_Suffix : constant String := ".d";
337 ALI_Dependency_Suffix : constant String := ".ali";
339 Switches_Dependency_Suffix : constant String := ".cswi";
341 Binder_Exchange_Suffix : constant String := ".bexch";
342 -- Suffix for binder exchange files
344 Library_Exchange_Suffix : constant String := ".lexch";
345 -- Suffix for library exchange files
347 type Name_List_Index is new Nat;
348 No_Name_List : constant Name_List_Index := 0;
350 type Name_Node is record
351 Name : Name_Id := No_Name;
352 Next : Name_List_Index := No_Name_List;
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,
360 Table_Increment => 100);
361 -- The table for lists of names used in package Language_Processing
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,
370 -- A hash table to store the mapping files that are not used
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)
376 Casing : Casing_Type := All_Lower_Case;
377 -- The casing of the source file name (for Ada)
379 Separate_Suffix : File_Name_Type := No_File;
380 -- String to append to unit name for source file name of an Ada subunit
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.
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.
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);
398 type Source_Id is new Nat;
400 No_Source : constant Source_Id := 0;
402 type Path_Syntax_Kind is
407 -- Host specific syntax, for example on VMS (the default)
409 type Language_Config is record
410 Kind : Language_Kind := File_Based;
411 -- Kind of language. All languages are file based, except Ada which is
414 Naming_Data : Lang_Naming_Data;
415 -- The naming data for the languages (prefixes, etc.)
417 Include_Compatible_Languages : Name_List_Index := No_Name_List;
418 -- The list of languages that are "include compatible" with this
419 -- language. A language B (for example "C") is "include compatible" with
420 -- a language A (for example "C++") if it is expected that sources of
421 -- language A may "include" header files from language B.
423 Compiler_Driver : File_Name_Type := No_File;
424 -- The name of the executable for the compiler of the language
426 Compiler_Driver_Path : String_Access := null;
427 -- The path name of the executable for the compiler of the language
429 Compiler_Required_Switches : Name_List_Index := No_Name_List;
430 -- The list of switches that are required as a minimum to invoke the
433 Path_Syntax : Path_Syntax_Kind := Host;
434 -- Value may be Canonical (Unix style) or Host (host syntax, for example
435 -- on VMS for DEC C).
437 Compilation_PIC_Option : Name_List_Index := No_Name_List;
438 -- The option(s) to compile a source in Position Independent Code for
439 -- shared libraries. Specified in the configuration. When not specified,
440 -- there is no need for such switch.
442 Object_Generated : Boolean := True;
443 -- False in no object file is generated
445 Objects_Linked : Boolean := True;
446 -- False if object files are not use to link executables and build
449 Runtime_Library_Dir : Name_Id := No_Name;
450 -- Path name of the runtime library directory, if any
452 Mapping_File_Switches : Name_List_Index := No_Name_List;
453 -- The option(s) to provide a mapping file to the compiler. Specified in
454 -- the configuration. When value is No_Name_List, there is no mapping
457 Mapping_Spec_Suffix : File_Name_Type := No_File;
458 -- Placeholder representing the spec suffix in a mapping file
460 Mapping_Body_Suffix : File_Name_Type := No_File;
461 -- Placeholder representing the body suffix in a mapping file
463 Config_File_Switches : Name_List_Index := No_Name_List;
464 -- The option(s) to provide a config file to the compiler. Specified in
465 -- the configuration. When value is No_Name_List, there is no config
468 Dependency_Kind : Dependency_File_Kind := None;
469 -- The kind of dependency to be checked: none, Makefile fragment or
470 -- ALI file (for Ada).
472 Dependency_Option : Name_List_Index := No_Name_List;
473 -- The option(s) to be used to create the dependency file. When value is
474 -- No_Name_List, there is not such option(s).
476 Compute_Dependency : Name_List_Index := No_Name_List;
477 -- Hold the value of attribute Dependency_Driver, if declared for the
480 Include_Option : Name_List_Index := No_Name_List;
481 -- Hold the value of attribute Include_Switches, if declared for the
484 Include_Path : Name_Id := No_Name;
485 -- Name of environment variable declared by attribute Include_Path for
488 Include_Path_File : Name_Id := No_Name;
489 -- Name of environment variable declared by attribute Include_Path_File
492 Objects_Path : Name_Id := No_Name;
493 -- Name of environment variable declared by attribute Objects_Path for
496 Objects_Path_File : Name_Id := No_Name;
497 -- Name of environment variable declared by attribute Objects_Path_File
500 Config_Body : Name_Id := No_Name;
501 -- The template for a pragma Source_File_Name(_Project) for a specific
502 -- file name of a body.
504 Config_Spec : Name_Id := No_Name;
505 -- The template for a pragma Source_File_Name(_Project) for a specific
506 -- file name of a spec.
508 Config_Body_Pattern : Name_Id := No_Name;
509 -- The template for a pragma Source_File_Name(_Project) for a naming
512 Config_Spec_Pattern : Name_Id := No_Name;
513 -- The template for a pragma Source_File_Name(_Project) for a naming
516 Config_File_Unique : Boolean := False;
517 -- Indicate if the config file specified to the compiler needs to be
518 -- unique. If it is unique, then all config files are concatenated into
519 -- a temp config file.
521 Binder_Driver : File_Name_Type := No_File;
522 -- The name of the binder driver for the language, if any
524 Binder_Driver_Path : Path_Name_Type := No_Path;
525 -- The path name of the binder driver
527 Binder_Required_Switches : Name_List_Index := No_Name_List;
528 -- Hold the value of attribute Binder'Required_Switches for the language
530 Binder_Prefix : Name_Id := No_Name;
531 -- Hold the value of attribute Binder'Prefix for the language
533 Toolchain_Version : Name_Id := No_Name;
534 -- Hold the value of attribute Toolchain_Version for the language
536 Toolchain_Description : Name_Id := No_Name;
537 -- Hold the value of attribute Toolchain_Description for the language
540 -- Record describing the configuration of a language
542 No_Language_Config : constant Language_Config :=
544 Naming_Data => No_Lang_Naming_Data,
545 Include_Compatible_Languages => No_Name_List,
546 Compiler_Driver => No_File,
547 Compiler_Driver_Path => null,
548 Compiler_Required_Switches => No_Name_List,
549 Path_Syntax => Canonical,
550 Compilation_PIC_Option => No_Name_List,
551 Object_Generated => True,
552 Objects_Linked => True,
553 Runtime_Library_Dir => No_Name,
554 Mapping_File_Switches => No_Name_List,
555 Mapping_Spec_Suffix => No_File,
556 Mapping_Body_Suffix => No_File,
557 Config_File_Switches => No_Name_List,
558 Dependency_Kind => Makefile,
559 Dependency_Option => No_Name_List,
560 Compute_Dependency => No_Name_List,
561 Include_Option => No_Name_List,
562 Include_Path => No_Name,
563 Include_Path_File => No_Name,
564 Objects_Path => No_Name,
565 Objects_Path_File => No_Name,
566 Config_Body => No_Name,
567 Config_Spec => No_Name,
568 Config_Body_Pattern => No_Name,
569 Config_Spec_Pattern => No_Name,
570 Config_File_Unique => False,
571 Binder_Driver => No_File,
572 Binder_Driver_Path => No_Path,
573 Binder_Required_Switches => No_Name_List,
574 Binder_Prefix => No_Name,
575 Toolchain_Version => No_Name,
576 Toolchain_Description => No_Name);
578 type Language_Data is record
579 Name : Name_Id := No_Name;
580 Display_Name : Name_Id := No_Name;
581 Config : Language_Config := No_Language_Config;
582 First_Source : Source_Id := No_Source;
583 Mapping_Files : Mapping_Files_Htable.Instance :=
584 Mapping_Files_Htable.Nil;
585 Next : Language_Index := No_Language_Index;
588 No_Language_Data : constant Language_Data :=
590 Display_Name => No_Name,
591 Config => No_Language_Config,
592 First_Source => No_Source,
593 Mapping_Files => Mapping_Files_Htable.Nil,
594 Next => No_Language_Index);
596 package Language_Data_Table is new GNAT.Dynamic_Tables
597 (Table_Component_Type => Language_Data,
598 Table_Index_Type => Language_Index,
599 Table_Low_Bound => 1,
601 Table_Increment => 100);
602 -- The table for lists of names used in package Language_Processing
604 type Alternate_Language_Id is new Nat;
606 No_Alternate_Language : constant Alternate_Language_Id := 0;
608 type Alternate_Language_Data is record
609 Language : Language_Index := No_Language_Index;
610 Next : Alternate_Language_Id := No_Alternate_Language;
613 package Alternate_Language_Table is new GNAT.Dynamic_Tables
614 (Table_Component_Type => Alternate_Language_Data,
615 Table_Index_Type => Alternate_Language_Id,
616 Table_Low_Bound => 1,
618 Table_Increment => 100);
619 -- The table for storing the alternate languages of a header file that
620 -- is used for several languages.
622 type Source_Kind is (Spec, Impl, Sep);
624 type Source_Data is record
625 Project : Project_Id := No_Project;
626 -- Project of the source
628 Language_Name : Name_Id := No_Name;
629 -- Name of the language of the source
631 Language : Language_Index := No_Language_Index;
632 -- Index of the language
634 Lang_Kind : Language_Kind := File_Based;
635 -- Kind of the language
637 Compiled : Boolean := True;
638 -- False when there is no compiler for the language
640 In_Interfaces : Boolean := True;
641 -- False when the source is not included in interfaces, when attribute
642 -- Interfaces is declared.
644 Declared_In_Interfaces : Boolean := False;
645 -- True when source is declared in attribute Interfaces
647 Alternate_Languages : Alternate_Language_Id := No_Alternate_Language;
648 -- List of languages a header file may also be, in addition of
649 -- language Language_Name.
651 Kind : Source_Kind := Spec;
652 -- Kind of the source: spec, body or subunit
654 Dependency : Dependency_File_Kind := None;
655 -- Kind of dependency: none, Makefile fragment or ALI file
657 Other_Part : Source_Id := No_Source;
658 -- Source ID for the other part, if any: for a spec, indicates its body;
659 -- for a body, indicates its spec.
661 Unit : Name_Id := No_Name;
662 -- Name of the unit, if language is unit based
665 -- Index of the source in a multi unit source file
667 Locally_Removed : Boolean := False;
668 -- True if the source has been "excluded"
670 Get_Object : Boolean := False;
671 -- Indicates that the object of the source should be put in the global
672 -- archive. This is for Ada, when only the closure of a main needs to
673 -- be compiled/recompiled.
675 Replaced_By : Source_Id := No_Source;
677 File : File_Name_Type := No_File;
678 -- Canonical file name of the source
680 Display_File : File_Name_Type := No_File;
681 -- File name of the source, for display purposes
683 Path : Path_Information := No_Path_Information;
684 -- Path name of the source
686 Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
687 -- Time stamp of the source file
689 Object_Project : Project_Id := No_Project;
690 -- Project where the object file is
692 Object_Exists : Boolean := True;
693 -- True if an object file exists
695 Object_Linked : Boolean := True;
696 -- False if the object file is not use to link executables or included
699 Object : File_Name_Type := No_File;
700 -- File name of the object file
702 Current_Object_Path : Path_Name_Type := No_Path;
703 -- Object path of an existing object file
705 Object_Path : Path_Name_Type := No_Path;
706 -- Object path of the real object file
708 Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
709 -- Object file time stamp
711 Dep_Name : File_Name_Type := No_File;
712 -- Dependency file simple name
714 Current_Dep_Path : Path_Name_Type := No_Path;
715 -- Path name of an existing dependency file
717 Dep_Path : Path_Name_Type := No_Path;
718 -- Path name of the real dependency file
720 Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
721 -- Dependency file time stamp
723 Switches : File_Name_Type := No_File;
724 -- File name of the switches file
726 Switches_Path : Path_Name_Type := No_Path;
727 -- Path name of the switches file
729 Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
730 -- Switches file time stamp
732 Naming_Exception : Boolean := False;
733 -- True if the source has an exceptional name
735 Next_In_Sources : Source_Id := No_Source;
736 -- Link to another source in the project tree
738 Next_In_Project : Source_Id := No_Source;
739 -- Link to another source in the project
741 Next_In_Lang : Source_Id := No_Source;
742 -- Link to another source of the same language
745 No_Source_Data : constant Source_Data :=
746 (Project => No_Project,
747 Language_Name => No_Name,
748 Language => No_Language_Index,
749 Lang_Kind => File_Based,
751 In_Interfaces => True,
752 Declared_In_Interfaces => False,
753 Alternate_Languages => No_Alternate_Language,
756 Other_Part => No_Source,
759 Locally_Removed => False,
761 Replaced_By => No_Source,
763 Display_File => No_File,
764 Path => No_Path_Information,
765 Source_TS => Empty_Time_Stamp,
766 Object_Project => No_Project,
767 Object_Exists => True,
768 Object_Linked => True,
770 Current_Object_Path => No_Path,
771 Object_Path => No_Path,
772 Object_TS => Empty_Time_Stamp,
774 Current_Dep_Path => No_Path,
776 Dep_TS => Empty_Time_Stamp,
778 Switches_Path => No_Path,
779 Switches_TS => Empty_Time_Stamp,
780 Naming_Exception => False,
781 Next_In_Sources => No_Source,
782 Next_In_Project => No_Source,
783 Next_In_Lang => No_Source);
785 package Source_Data_Table is new GNAT.Dynamic_Tables
786 (Table_Component_Type => Source_Data,
787 Table_Index_Type => Source_Id,
788 Table_Low_Bound => 1,
789 Table_Initial => 1000,
790 Table_Increment => 100);
791 -- The table for the sources
793 package Source_Paths_Htable is new Simple_HTable
794 (Header_Num => Header_Num,
795 Element => Source_Id,
796 No_Element => No_Source,
797 Key => Path_Name_Type,
800 -- Mapping of source paths to source ids
802 type Verbosity is (Default, Medium, High);
803 -- Verbosity when parsing GNAT Project Files
804 -- Default is default (very quiet, if no errors).
805 -- Medium is more verbose.
806 -- High is extremely verbose.
808 Current_Verbosity : Verbosity := Default;
809 -- The current value of the verbosity the project files are parsed with
811 type Lib_Kind is (Static, Dynamic, Relocatable);
813 type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
814 -- Type to specify the symbol policy, when symbol control is supported.
815 -- See full explanation about this type in package Symbols.
816 -- Autonomous: Create a symbol file without considering any reference
817 -- Compliant: Try to be as compatible as possible with an existing ref
818 -- Controlled: Fail if symbols are not the same as those in the reference
819 -- Restricted: Restrict the symbols to those in the symbol file
820 -- Direct: The symbol file is used as is
822 type Symbol_Record is record
823 Symbol_File : Path_Name_Type := No_Path;
824 Reference : Path_Name_Type := No_Path;
825 Symbol_Policy : Policy := Autonomous;
827 -- Type to keep the symbol data to be used when building a shared library
829 No_Symbols : constant Symbol_Record :=
830 (Symbol_File => No_Path,
831 Reference => No_Path,
832 Symbol_Policy => Autonomous);
833 -- The default value of the symbol data
835 function Image (Casing : Casing_Type) return String;
836 -- Similar to 'Image (but avoid use of this attribute in compiler)
838 function Value (Image : String) return Casing_Type;
839 -- Similar to 'Value (but avoid use of this attribute in compiler)
840 -- Raises Constraint_Error if not a Casing_Type image.
842 -- The following record contains data for a naming scheme
844 type Naming_Data is record
846 Dot_Replacement : File_Name_Type := No_File;
847 -- The string to replace '.' in the source file name (for Ada)
849 Dot_Repl_Loc : Source_Ptr := No_Location;
851 Casing : Casing_Type := All_Lower_Case;
852 -- The casing of the source file name (for Ada)
854 Spec_Suffix : Array_Element_Id := No_Array_Element;
855 -- The string to append to the unit name for the
856 -- source file name of a spec.
857 -- Indexed by the programming language.
859 Ada_Spec_Suffix_Loc : Source_Ptr := No_Location;
861 Body_Suffix : Array_Element_Id := No_Array_Element;
862 -- The string to append to the unit name for the
863 -- source file name of a body.
864 -- Indexed by the programming language.
866 Ada_Body_Suffix_Loc : Source_Ptr := No_Location;
868 Separate_Suffix : File_Name_Type := No_File;
869 -- String to append to unit name for source file name of an Ada subunit
871 Sep_Suffix_Loc : Source_Ptr := No_Location;
872 -- Position in the project file source where Separate_Suffix is defined
874 Specs : Array_Element_Id := No_Array_Element;
875 -- An associative array mapping individual specs to source file names
876 -- This is specific to Ada.
878 Bodies : Array_Element_Id := No_Array_Element;
879 -- An associative array mapping individual bodies to source file names
880 -- This is specific to Ada.
882 Specification_Exceptions : Array_Element_Id := No_Array_Element;
883 -- An associative array listing spec file names that do not have the
884 -- spec suffix. Not used by Ada. Indexed by programming language name.
886 Implementation_Exceptions : Array_Element_Id := No_Array_Element;
887 -- An associative array listing body file names that do not have the
888 -- body suffix. Not used by Ada. Indexed by programming language name.
892 function Spec_Suffix_Of
893 (In_Tree : Project_Tree_Ref;
895 Naming : Naming_Data) return String;
897 function Spec_Suffix_Id_Of
898 (In_Tree : Project_Tree_Ref;
900 Naming : Naming_Data) return File_Name_Type;
902 function Spec_Suffix_Id_Of
903 (In_Tree : Project_Tree_Ref;
904 Language_Id : Name_Id;
905 Naming : Naming_Data) return File_Name_Type;
907 procedure Set_Spec_Suffix
908 (In_Tree : Project_Tree_Ref;
910 Naming : in out Naming_Data;
911 Suffix : File_Name_Type);
913 function Body_Suffix_Id_Of
914 (In_Tree : Project_Tree_Ref;
916 Naming : Naming_Data) return File_Name_Type;
918 function Body_Suffix_Id_Of
919 (In_Tree : Project_Tree_Ref;
920 Language_Id : Name_Id;
921 Naming : Naming_Data) return File_Name_Type;
923 function Body_Suffix_Of
924 (In_Tree : Project_Tree_Ref;
926 Naming : Naming_Data) return String;
928 procedure Set_Body_Suffix
929 (In_Tree : Project_Tree_Ref;
931 Naming : in out Naming_Data;
932 Suffix : File_Name_Type);
934 function Objects_Exist_For
936 In_Tree : Project_Tree_Ref) return Boolean;
938 function Standard_Naming_Data
939 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
940 pragma Inline (Standard_Naming_Data);
941 -- The standard GNAT naming scheme when Tree is No_Project_Tree.
942 -- Otherwise, return the default naming scheme for the project tree Tree,
943 -- which must have been Initialized.
945 function Same_Naming_Scheme
946 (Left, Right : Naming_Data) return Boolean;
947 -- Returns True if Left and Right are the same naming scheme
948 -- not considering Specs and Bodies.
950 type Project_List is new Nat;
951 Empty_Project_List : constant Project_List := 0;
952 -- A list of project files
954 type Project_Element is record
955 Project : Project_Id := No_Project;
956 Next : Project_List := Empty_Project_List;
958 -- Element in a list of project files. Next is the id of the next
959 -- project file in the list.
961 package Project_List_Table is new GNAT.Dynamic_Tables
962 (Table_Component_Type => Project_Element,
963 Table_Index_Type => Project_List,
964 Table_Low_Bound => 1,
965 Table_Initial => 100,
966 Table_Increment => 100);
967 -- The table that contains the lists of project files
969 type Project_Configuration is record
970 Run_Path_Option : Name_List_Index := No_Name_List;
971 -- The option to use when linking to specify the path where to look for
974 Executable_Suffix : Name_Id := No_Name;
975 -- The suffix of executables, when specified in the configuration or in
976 -- package Builder of the main project. When this is not specified, the
977 -- executable suffix is the default for the platform.
981 Linker : Path_Name_Type := No_Path;
982 -- Path name of the linker driver. Specified in the configuration or in
983 -- the package Builder of the main project.
985 Map_File_Option : Name_Id := No_Name;
986 -- Option to use when invoking the linker to build a map file
988 Minimum_Linker_Options : Name_List_Index := No_Name_List;
989 -- The minimum options for the linker driver. Specified in the
992 Linker_Executable_Option : Name_List_Index := No_Name_List;
993 -- The option(s) to indicate the name of the executable in the linker
994 -- command. Specified in the configuration. When not specified, default
995 -- to -o <executable name>.
997 Linker_Lib_Dir_Option : Name_Id := No_Name;
998 -- The option to specify where to find a library for linking. Specified
999 -- in the configuration. When not specified, defaults to "-L".
1001 Linker_Lib_Name_Option : Name_Id := No_Name;
1002 -- The option to specify the name of a library for linking. Specified in
1003 -- the configuration. When not specified, defaults to "-l".
1007 Library_Builder : Path_Name_Type := No_Path;
1008 -- The executable to build library (specified in the configuration)
1010 Lib_Support : Library_Support := None;
1011 -- The level of library support. Specified in the configuration. Support
1012 -- is none, static libraries only or both static and shared libraries.
1014 Archive_Builder : Name_List_Index := No_Name_List;
1015 -- The name of the executable to build archives, with the minimum
1016 -- switches. Specified in the configuration.
1018 Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
1019 -- The options to append object files to an archive
1021 Archive_Indexer : Name_List_Index := No_Name_List;
1022 -- The name of the executable to index archives, with the minimum
1023 -- switches. Specified in the configuration.
1025 Archive_Suffix : File_Name_Type := No_File;
1026 -- The suffix of archives. Specified in the configuration. When not
1027 -- specified, defaults to ".a".
1029 Lib_Partial_Linker : Name_List_Index := No_Name_List;
1033 Shared_Lib_Driver : File_Name_Type := No_File;
1034 -- The driver to link shared libraries. Set with attribute Library_GCC.
1037 Shared_Lib_Prefix : File_Name_Type := No_File;
1038 -- Part of a shared library file name that precedes the name of the
1039 -- library. Specified in the configuration. When not specified, defaults
1042 Shared_Lib_Suffix : File_Name_Type := No_File;
1043 -- Suffix of shared libraries, after the library name in the shared
1044 -- library name. Specified in the configuration. When not specified,
1045 -- default to ".so".
1047 Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
1048 -- The minimum options to use when building a shared library
1050 Lib_Version_Options : Name_List_Index := No_Name_List;
1051 -- The options to use to specify a library version
1053 Symbolic_Link_Supported : Boolean := False;
1054 -- True if the platform supports symbolic link files
1056 Lib_Maj_Min_Id_Supported : Boolean := False;
1057 -- True if platform supports library major and minor options, such as
1058 -- libname.so -> libname.so.2 -> libname.so.2.4
1060 Auto_Init_Supported : Boolean := False;
1061 -- True if automatic initialisation is supported for shared stand-alone
1065 Default_Project_Config : constant Project_Configuration :=
1066 (Run_Path_Option => No_Name_List,
1067 Executable_Suffix => No_Name,
1069 Map_File_Option => No_Name,
1070 Minimum_Linker_Options => No_Name_List,
1071 Linker_Executable_Option => No_Name_List,
1072 Linker_Lib_Dir_Option => No_Name,
1073 Linker_Lib_Name_Option => No_Name,
1074 Library_Builder => No_Path,
1075 Lib_Support => None,
1076 Archive_Builder => No_Name_List,
1077 Archive_Builder_Append_Option => No_Name_List,
1078 Archive_Indexer => No_Name_List,
1079 Archive_Suffix => No_File,
1080 Lib_Partial_Linker => No_Name_List,
1081 Shared_Lib_Driver => No_File,
1082 Shared_Lib_Prefix => No_File,
1083 Shared_Lib_Suffix => No_File,
1084 Shared_Lib_Min_Options => No_Name_List,
1085 Lib_Version_Options => No_Name_List,
1086 Symbolic_Link_Supported => False,
1087 Lib_Maj_Min_Id_Supported => False,
1088 Auto_Init_Supported => False);
1090 -- The following record describes a project file representation
1092 -- Note that it is not specified if the path names of directories (source,
1093 -- object, library or exec directories) end with or without a directory
1096 type Project_Data is record
1102 Name : Name_Id := No_Name;
1103 -- The name of the project
1105 Display_Name : Name_Id := No_Name;
1106 -- The name of the project with the spelling of its declaration
1108 Qualifier : Project_Qualifier := Unspecified;
1109 -- The eventual qualifier for this project
1111 Externally_Built : Boolean := False;
1112 -- True if the project is externally built. In such case, the Project
1113 -- Manager will not modify anything in this project.
1115 Config : Project_Configuration;
1117 Path : Path_Information := No_Path_Information;
1118 -- The path name of the project file
1120 Virtual : Boolean := False;
1121 -- True for virtual extending projects
1123 Location : Source_Ptr := No_Location;
1124 -- The location in the project file source of the reserved word project
1126 Naming : Naming_Data := Standard_Naming_Data;
1127 -- The naming scheme of this project file
1133 Languages : Name_List_Index := No_Name_List;
1134 -- The list of languages of the sources of this project
1136 Include_Language : Language_Index := No_Language_Index;
1138 First_Language_Processing : Language_Index := No_Language_Index;
1139 -- First index of the language data in the project
1141 Unit_Based_Language_Name : Name_Id := No_Name;
1142 Unit_Based_Language_Index : Language_Index := No_Language_Index;
1143 -- The name and index, if any, of the unit-based language of some
1144 -- sources of the project. There may be only one unit-based language
1151 First_Referred_By : Project_Id := No_Project;
1152 -- The project, if any, that was the first to be known as importing or
1153 -- extending this project
1155 Mains : String_List_Id := Nil_String;
1156 -- List of mains specified by attribute Main
1158 Extends : Project_Id := No_Project;
1159 -- The reference of the project file, if any, that this project file
1162 Extended_By : Project_Id := No_Project;
1163 -- The reference of the project file, if any, that extends this project
1166 Decl : Declarations := No_Declarations;
1167 -- The declarations (variables, attributes and packages) of this project
1170 Imported_Projects : Project_List := Empty_Project_List;
1171 -- The list of all directly imported projects, if any
1173 All_Imported_Projects : Project_List := Empty_Project_List;
1174 -- The list of all projects imported directly or indirectly, if any
1180 Directory : Path_Information := No_Path_Information;
1181 -- Path name of the directory where the project file resides
1183 Dir_Path : String_Access;
1184 -- Same as Directory.Name, but as an access to String
1186 Object_Directory : Path_Information := No_Path_Information;
1187 -- The path name of the object directory of this project file
1189 Exec_Directory : Path_Information := No_Path_Information;
1190 -- The path name of the exec directory of this project file. Default is
1191 -- equal to Object_Directory.
1197 Library : Boolean := False;
1198 -- True if this is a library project
1200 Library_Name : Name_Id := No_Name;
1201 -- If a library project, name of the library
1203 Library_Kind : Lib_Kind := Static;
1204 -- If a library project, kind of library
1206 Library_Dir : Path_Information := No_Path_Information;
1207 -- If a library project, path name of the directory where the library
1210 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
1211 -- The timestamp of a library file in a library project
1213 Library_Src_Dir : Path_Information := No_Path_Information;
1214 -- If a Stand-Alone Library project, path name of the directory where
1215 -- the sources of the interfaces of the library are copied. By default,
1216 -- if attribute Library_Src_Dir is not specified, sources of the
1217 -- interfaces are not copied anywhere.
1219 Library_ALI_Dir : Path_Information := No_Path_Information;
1220 -- In a library project, path name of the directory where the ALI files
1221 -- are copied. If attribute Library_ALI_Dir is not specified, ALI files
1222 -- are copied in the Library_Dir.
1224 Lib_Internal_Name : Name_Id := No_Name;
1225 -- If a library project, internal name store inside the library
1227 Standalone_Library : Boolean := False;
1228 -- Indicate that this is a Standalone Library Project File
1230 Lib_Interface_ALIs : String_List_Id := Nil_String;
1231 -- For Standalone Library Project Files, indicate the list of Interface
1234 Lib_Auto_Init : Boolean := False;
1235 -- For non static Stand-Alone Library Project Files, indicate if
1236 -- the library initialisation should be automatic.
1238 Symbol_Data : Symbol_Record := No_Symbols;
1239 -- Symbol file name, reference symbol file name, symbol policy
1241 Need_To_Build_Lib : Boolean := False;
1242 -- Indicates that the library of a Library Project needs to be built or
1249 Ada_Sources_Present : Boolean := True;
1250 -- True if there are Ada sources in the project
1252 Other_Sources_Present : Boolean := True;
1253 -- True if there are non-Ada sources in the project
1255 Ada_Sources : String_List_Id := Nil_String;
1256 -- The list of all the Ada source file names (gnatmake only)
1258 First_Source : Source_Id := No_Source;
1259 Last_Source : Source_Id := No_Source;
1260 -- Head and tail of the list of sources
1262 Interfaces_Defined : Boolean := False;
1263 -- True if attribute Interfaces is declared for the project or any
1264 -- project it extends.
1266 Imported_Directories_Switches : Argument_List_Access := null;
1267 -- List of the source search switches (-I<source dir>) to be used when
1270 Include_Path : String_Access := null;
1271 -- The search source path for the project. Used as the value for an
1272 -- environment variable, specified by attribute Include_Path
1273 -- (<language>). The names of the environment variables are in component
1274 -- Include_Path of the records Language_Config.
1276 Include_Path_File : Path_Name_Type := No_Path;
1277 -- The path name of the of the source search directory file
1279 Include_Data_Set : Boolean := False;
1280 -- Set True when Imported_Directories_Switches or Include_Path are set
1282 Source_Dirs : String_List_Id := Nil_String;
1283 -- The list of all the source directories
1285 Known_Order_Of_Source_Dirs : Boolean := True;
1286 -- False, if there is any /** in the Source_Dirs, because in this case
1287 -- the ordering of the source subdirs depend on the OS. If True,
1288 -- duplicate file names in the same project file are allowed.
1290 Ada_Include_Path : String_Access := null;
1291 -- The cached value of source search path for this project file. Set by
1292 -- the first call to Prj.Env.Ada_Include_Path for the project. Do not
1293 -- use this field directly outside of the project manager, use
1294 -- Prj.Env.Ada_Include_Path instead.
1300 Ada_Objects_Path : String_Access := null;
1301 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
1302 -- use this field directly outside of the compiler, use
1303 -- Prj.Env.Ada_Objects_Path instead.
1305 Libgnarl_Needed : Yes_No_Unknown := Unknown;
1306 -- Set to True when libgnarl is needed to link
1308 Objects_Path : String_Access := null;
1309 -- The cached value of the object dir path, used during the binding
1310 -- phase of gprbuild.
1312 Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
1313 -- The cached value of the object path temp file (including library
1314 -- dirs) for this project file.
1316 Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
1317 -- The cached value of the object path temp file (excluding library
1318 -- dirs) for this project file.
1320 Config_File_Name : Path_Name_Type := No_Path;
1321 -- The path name of the configuration pragmas file, if any
1323 Config_File_Temp : Boolean := False;
1324 -- An indication that the configuration pragmas file is a temporary file
1325 -- that must be deleted at the end.
1327 Config_Checked : Boolean := False;
1328 -- A flag to avoid checking repetitively the configuration pragmas file
1330 Checked : Boolean := False;
1331 -- A flag to avoid checking repetitively the naming scheme of this
1334 Seen : Boolean := False;
1335 -- A flag to mark a project as "visited" to avoid processing the same
1336 -- project several time.
1338 Depth : Natural := 0;
1339 -- The maximum depth of a project in the project graph. Depth of main
1342 Unkept_Comments : Boolean := False;
1343 -- True if there are comments in the project sources that cannot be kept
1344 -- in the project tree.
1348 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
1349 -- Return the representation of an empty project in project Tree tree.
1350 -- The project tree Tree must have been Initialized and/or Reset.
1352 function Is_Extending
1353 (Extending : Project_Id;
1354 Extended : Project_Id;
1355 In_Tree : Project_Tree_Ref) return Boolean;
1356 -- ??? needs comment
1358 function Is_A_Language
1359 (Tree : Project_Tree_Ref;
1360 Data : Project_Data;
1361 Language_Name : Name_Id) return Boolean;
1362 -- Return True when Language_Name (which must be lower case) is one of the
1363 -- languages used for the project.
1365 Project_Error : exception;
1366 -- Raised by some subprograms in Prj.Attr
1368 package Project_Table is new GNAT.Dynamic_Tables (
1369 Table_Component_Type => Project_Data,
1370 Table_Index_Type => Project_Id,
1371 Table_Low_Bound => 1,
1372 Table_Initial => 100,
1373 Table_Increment => 100);
1374 -- The set of all project files
1376 type Spec_Or_Body is (Specification, Body_Part);
1378 type File_Name_Data is record
1379 Name : File_Name_Type := No_File;
1381 Display_Name : File_Name_Type := No_File;
1382 Path : Path_Information := No_Path_Information;
1383 Project : Project_Id := No_Project;
1384 Needs_Pragma : Boolean := False;
1386 -- File and Path name of a spec or body
1388 type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
1390 type Unit_Index is new Nat;
1391 No_Unit_Index : constant Unit_Index := 0;
1392 type Unit_Data is record
1393 Name : Name_Id := No_Name;
1394 File_Names : File_Names_Data;
1396 -- Name and File and Path names of a unit, with a reference to its
1397 -- GNAT Project File(s).
1399 package Unit_Table is new GNAT.Dynamic_Tables
1400 (Table_Component_Type => Unit_Data,
1401 Table_Index_Type => Unit_Index,
1402 Table_Low_Bound => 1,
1403 Table_Initial => 100,
1404 Table_Increment => 100);
1405 -- Table of all units in a project tree
1407 package Units_Htable is new Simple_HTable
1408 (Header_Num => Header_Num,
1409 Element => Unit_Index,
1410 No_Element => No_Unit_Index,
1414 -- Mapping of unit names to indexes in the Units table
1416 type Unit_Project is record
1417 Unit : Unit_Index := No_Unit_Index;
1418 Project : Project_Id := No_Project;
1421 No_Unit_Project : constant Unit_Project := (No_Unit_Index, No_Project);
1423 package Files_Htable is new Simple_HTable
1424 (Header_Num => Header_Num,
1425 Element => Unit_Project,
1426 No_Element => No_Unit_Project,
1427 Key => File_Name_Type,
1430 -- Mapping of file names to indexes in the Units table
1432 type Private_Project_Tree_Data is private;
1433 -- Data for a project tree that is used only by the Project Manager
1435 type Project_Tree_Data is
1437 -- Languages and sources of the project
1439 First_Language : Language_Index := No_Language_Index;
1442 First_Source : Source_Id := No_Source;
1447 Languages_Data : Language_Data_Table.Instance;
1448 Name_Lists : Name_List_Table.Instance;
1449 String_Elements : String_Element_Table.Instance;
1450 Variable_Elements : Variable_Element_Table.Instance;
1451 Array_Elements : Array_Element_Table.Instance;
1452 Arrays : Array_Table.Instance;
1453 Packages : Package_Table.Instance;
1454 Project_Lists : Project_List_Table.Instance;
1455 Projects : Project_Table.Instance;
1456 Sources : Source_Data_Table.Instance;
1457 Alt_Langs : Alternate_Language_Table.Instance;
1458 Units : Unit_Table.Instance;
1459 Units_HT : Units_Htable.Instance;
1460 Files_HT : Files_Htable.Instance;
1461 Source_Paths_HT : Source_Paths_Htable.Instance;
1465 Private_Part : Private_Project_Tree_Data;
1467 -- Data for a project tree
1469 type Put_Line_Access is access procedure
1471 Project : Project_Id;
1472 In_Tree : Project_Tree_Ref);
1473 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
1475 procedure Expect (The_Token : Token_Type; Token_Image : String);
1476 -- Check that the current token is The_Token. If it is not, then output
1477 -- an error message.
1479 procedure Initialize (Tree : Project_Tree_Ref);
1480 -- This procedure must be called before using any services from the Prj
1481 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
1483 procedure Reset (Tree : Project_Tree_Ref);
1484 -- This procedure resets all the tables that are used when processing a
1485 -- project file tree. Initialize must be called before the call to Reset.
1487 procedure Register_Default_Naming_Scheme
1488 (Language : Name_Id;
1489 Default_Spec_Suffix : File_Name_Type;
1490 Default_Body_Suffix : File_Name_Type;
1491 In_Tree : Project_Tree_Ref);
1492 -- Register the default suffixes for a given language. These extensions
1493 -- will be ignored if the user has specified a new naming scheme in a
1496 -- Otherwise, this information will be automatically added to Naming_Data
1497 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
1500 type State is limited private;
1501 with procedure Action
1502 (Project : Project_Id;
1503 With_State : in out State);
1504 procedure For_Every_Project_Imported
1506 In_Tree : Project_Tree_Ref;
1507 With_State : in out State);
1508 -- Call Action for each project imported directly or indirectly by project
1509 -- By. Action is called according to the order of importation: if A
1510 -- imports B, directly or indirectly, Action will be called for A before
1511 -- it is called for B. If two projects import each other directly or
1512 -- indirectly (using at least one "limited with"), it is not specified
1513 -- for which of these two projects Action will be called first. Projects
1514 -- that are extended by other projects are not considered. With_State may
1515 -- be used by Action to choose a behavior or to report some global result.
1517 function Extend_Name
1518 (File : File_Name_Type;
1519 With_Suffix : String) return File_Name_Type;
1520 -- Replace the extension of File with With_Suffix
1522 function Object_Name
1523 (Source_File_Name : File_Name_Type) return File_Name_Type;
1524 -- Returns the object file name corresponding to a source file name
1526 function Dependency_Name
1527 (Source_File_Name : File_Name_Type;
1528 Dependency : Dependency_File_Kind) return File_Name_Type;
1529 -- Returns the dependency file name corresponding to a source file name
1531 function Switches_Name
1532 (Source_File_Name : File_Name_Type) return File_Name_Type;
1533 -- Returns the switches file name corresponding to a source file name
1539 procedure Record_Temp_File (Path : Path_Name_Type);
1540 -- Record the path of a newly created temporary file, so that it can be
1543 procedure Delete_All_Temp_Files;
1544 -- Delete all recorded temporary files
1548 All_Packages : constant String_List_Access := null;
1550 No_Project_Tree : constant Project_Tree_Ref := null;
1552 Ignored : constant Variable_Kind := Single;
1554 Nil_Variable_Value : constant Variable_Value :=
1555 (Project => No_Project,
1557 Location => No_Location,
1560 Virtual_Prefix : constant String := "v$";
1561 -- The prefix for virtual extending projects. Because of the '$', which is
1562 -- normally forbidden for project names, there cannot be any name clash.
1564 Empty_Name : Name_Id;
1565 -- Name_Id for an empty name (no characters). Initialized in procedure
1568 Empty_File_Name : File_Name_Type;
1569 -- Empty File_Name_Type (no characters). Initialized in procedure
1572 procedure Add_To_Buffer
1574 To : in out String_Access;
1575 Last : in out Natural);
1576 -- Append a String to the Buffer
1578 type Naming_Id is new Nat;
1580 package Naming_Table is new GNAT.Dynamic_Tables
1581 (Table_Component_Type => Naming_Data,
1582 Table_Index_Type => Naming_Id,
1583 Table_Low_Bound => 1,
1585 Table_Increment => 100);
1586 -- Table storing the naming data for gnatmake/gprmake
1588 package Path_File_Table is new GNAT.Dynamic_Tables
1589 (Table_Component_Type => Path_Name_Type,
1590 Table_Index_Type => Natural,
1591 Table_Low_Bound => 1,
1592 Table_Initial => 50,
1593 Table_Increment => 100);
1594 -- Table storing all the temp path file names.
1595 -- Used by Delete_All_Path_Files.
1597 package Source_Path_Table is new GNAT.Dynamic_Tables
1598 (Table_Component_Type => Name_Id,
1599 Table_Index_Type => Natural,
1600 Table_Low_Bound => 1,
1601 Table_Initial => 50,
1602 Table_Increment => 100);
1603 -- A table to store the source dirs before creating the source path file
1605 package Object_Path_Table is new GNAT.Dynamic_Tables
1606 (Table_Component_Type => Path_Name_Type,
1607 Table_Index_Type => Natural,
1608 Table_Low_Bound => 1,
1609 Table_Initial => 50,
1610 Table_Increment => 100);
1611 -- A table to store the object dirs, before creating the object path file
1613 type Private_Project_Tree_Data is record
1614 Namings : Naming_Table.Instance;
1615 Path_Files : Path_File_Table.Instance;
1616 Source_Paths : Source_Path_Table.Instance;
1617 Object_Paths : Object_Path_Table.Instance;
1618 Default_Naming : Naming_Data;
1620 -- Type to represent the part of a project tree which is private to the