1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2009, 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 All_Other_Names : constant Name_Id := Names_High_Bound;
44 -- Name used to replace others as an index of an associative array
45 -- attribute in situations where this is allowed.
47 Subdirs : String_Ptr := null;
48 -- The value after the equal sign in switch --subdirs=...
49 -- Contains the relative subdirectory.
51 type Library_Support is (None, Static_Only, Full);
52 -- Support for Library Project File.
53 -- - None: Library Project Files are not supported at all
54 -- - Static_Only: Library Project Files are only supported for static
56 -- - Full: Library Project Files are supported for static and dynamic
57 -- (shared) libraries.
59 type Yes_No_Unknown is (Yes, No, Unknown);
60 -- Tri-state to decide if -lgnarl is needed when linking
62 type Mode is (Multi_Language, Ada_Only);
63 -- Ada_Only: mode for gnatmake, gnatclean, gnatname, the GNAT driver
64 -- Multi_Language: mode for gprbuild, gprclean
66 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 ...
81 -- Configuration: configuration project is ...
83 function Get_Mode return Mode;
84 pragma Inline (Get_Mode);
86 procedure Set_Mode (New_Mode : Mode);
87 pragma Inline (Set_Mode);
89 Default_Language_Is_Ada : Boolean := True;
90 -- If no language was defined in the project or the configuration file, it
91 -- is an error, unless this variable is True, in which case it defaults to
92 -- Ada. Calling Set_Mode will reset this variable, default is for Ada_Only.
94 Must_Check_Configuration : Boolean := False;
95 -- True when the contents of the configuration file must be checked. This
96 -- is in general only needed by gprbuild itself, since other applications
97 -- can ignore such errors when they don't need to build directly. Calling
98 -- Set_Mode will reset this variable, default is for Ada_Only.
100 All_Packages : constant String_List_Access;
101 -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
102 -- Prj.Part, indicating that all packages should be checked.
104 type Project_Tree_Data;
105 type Project_Tree_Ref is access all Project_Tree_Data;
106 -- Reference to a project tree. Several project trees may exist in memory
109 No_Project_Tree : constant Project_Tree_Ref;
111 procedure Free (Tree : in out Project_Tree_Ref);
112 -- Free memory associated with the tree
114 function Default_Ada_Spec_Suffix return File_Name_Type;
115 pragma Inline (Default_Ada_Spec_Suffix);
116 -- The name for the standard GNAT suffix for Ada spec source file name
117 -- ".ads". Initialized by Prj.Initialize.
119 function Default_Ada_Body_Suffix return File_Name_Type;
120 pragma Inline (Default_Ada_Body_Suffix);
121 -- The name for the standard GNAT suffix for Ada body source file name
122 -- ".adb". Initialized by Prj.Initialize.
124 function Slash return Path_Name_Type;
125 pragma Inline (Slash);
126 -- "/", used as the path of locally removed files
128 Config_Project_File_Extension : String := ".cgpr";
129 Project_File_Extension : String := ".gpr";
130 -- The standard config and user project file name extensions. They are not
131 -- constants, because Canonical_Case_File_Name is called on these variables
132 -- in the body of Prj.
134 type Error_Warning is (Silent, Warning, Error);
135 -- Severity of some situations, such as: no Ada sources in a project where
136 -- Ada is one of the language.
138 -- When the situation occurs, the behaviour depends on the setting:
140 -- - Silent: no action
141 -- - Warning: issue a warning, does not cause the tool to fail
142 -- - Error: issue an error, causes the tool to fail
144 function Empty_File return File_Name_Type;
145 function Empty_String return Name_Id;
146 -- Return the id for an empty string ""
148 type Path_Information is record
149 Name : Path_Name_Type := No_Path;
150 Display_Name : Path_Name_Type := No_Path;
153 No_Path_Information : constant Path_Information := (No_Path, No_Path);
156 type Project_Id is access all Project_Data;
157 No_Project : constant Project_Id := null;
158 -- Id of a Project File
160 type String_List_Id is new Nat;
161 Nil_String : constant String_List_Id := 0;
162 type String_Element is record
163 Value : Name_Id := No_Name;
165 Display_Value : Name_Id := No_Name;
166 Location : Source_Ptr := No_Location;
167 Flag : Boolean := False;
168 Next : String_List_Id := Nil_String;
170 -- To hold values for string list variables and array elements.
171 -- Component Flag may be used for various purposes. For source
172 -- directories, it indicates if the directory contains Ada source(s).
174 package String_Element_Table is new GNAT.Dynamic_Tables
175 (Table_Component_Type => String_Element,
176 Table_Index_Type => String_List_Id,
177 Table_Low_Bound => 1,
178 Table_Initial => 200,
179 Table_Increment => 100);
180 -- The table for string elements in string lists
182 type Variable_Kind is (Undefined, List, Single);
183 -- Different kinds of variables
185 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
186 -- The defined kinds of variables
188 Ignored : constant Variable_Kind;
189 -- Used to indicate that a package declaration must be ignored
190 -- while processing the project tree (unknown package name).
192 type Variable_Value (Kind : Variable_Kind := Undefined) is record
193 Project : Project_Id := No_Project;
194 Location : Source_Ptr := No_Location;
195 Default : Boolean := False;
200 Values : String_List_Id := Nil_String;
202 Value : Name_Id := No_Name;
206 -- Values for variables and array elements. Default is True if the
207 -- current value is the default one for the variable
209 Nil_Variable_Value : constant Variable_Value;
210 -- Value of a non existing variable or array element
212 type Variable_Id is new Nat;
213 No_Variable : constant Variable_Id := 0;
214 type Variable is record
215 Next : Variable_Id := No_Variable;
217 Value : Variable_Value;
219 -- To hold the list of variables in a project file and in packages
221 package Variable_Element_Table is new GNAT.Dynamic_Tables
222 (Table_Component_Type => Variable,
223 Table_Index_Type => Variable_Id,
224 Table_Low_Bound => 1,
225 Table_Initial => 200,
226 Table_Increment => 100);
227 -- The table of variable in list of variables
229 type Array_Element_Id is new Nat;
230 No_Array_Element : constant Array_Element_Id := 0;
231 type Array_Element is record
233 Src_Index : Int := 0;
234 Index_Case_Sensitive : Boolean := True;
235 Value : Variable_Value;
236 Next : Array_Element_Id := No_Array_Element;
238 -- Each Array_Element represents an array element and is linked (Next)
239 -- to the next array element, if any, in the array.
241 package Array_Element_Table is new GNAT.Dynamic_Tables
242 (Table_Component_Type => Array_Element,
243 Table_Index_Type => Array_Element_Id,
244 Table_Low_Bound => 1,
245 Table_Initial => 200,
246 Table_Increment => 100);
247 -- The table that contains all array elements
249 type Array_Id is new Nat;
250 No_Array : constant Array_Id := 0;
251 type Array_Data is record
252 Name : Name_Id := No_Name;
253 Location : Source_Ptr := No_Location;
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
304 type Language_Ptr is access all Language_Data;
305 -- Index of language data
307 No_Language_Index : constant Language_Ptr := null;
308 -- Constant indicating that there is no language data
310 Max_Header_Num : constant := 6150;
311 type Header_Num is range 0 .. Max_Header_Num;
312 -- Size for hash table below. The upper bound is an arbitrary value, the
313 -- value here was chosen after testing to determine a good compromise
314 -- between speed of access and memory usage.
316 function Hash (Name : Name_Id) return Header_Num;
317 function Hash (Name : File_Name_Type) return Header_Num;
318 function Hash (Name : Path_Name_Type) return Header_Num;
319 function Hash (Project : Project_Id) return Header_Num;
320 -- Used for computing hash values for names put into above hash table
322 type Language_Kind is (File_Based, Unit_Based);
323 -- Type for the kind of language. All languages are file based, except Ada
324 -- which is unit based.
326 type Dependency_File_Kind is (None, Makefile, ALI_File);
327 -- Type of dependency to be checked: no dependency file, Makefile fragment
328 -- or ALI file (for Ada).
330 Makefile_Dependency_Suffix : constant String := ".d";
331 ALI_Dependency_Suffix : constant String := ".ali";
333 Switches_Dependency_Suffix : constant String := ".cswi";
335 Binder_Exchange_Suffix : constant String := ".bexch";
336 -- Suffix for binder exchange files
338 Library_Exchange_Suffix : constant String := ".lexch";
339 -- Suffix for library exchange files
341 type Name_List_Index is new Nat;
342 No_Name_List : constant Name_List_Index := 0;
344 type Name_Node is record
345 Name : Name_Id := No_Name;
346 Next : Name_List_Index := No_Name_List;
349 package Name_List_Table is new GNAT.Dynamic_Tables
350 (Table_Component_Type => Name_Node,
351 Table_Index_Type => Name_List_Index,
352 Table_Low_Bound => 1,
354 Table_Increment => 100);
355 -- The table for lists of names used in package Language_Processing
357 package Mapping_Files_Htable is new Simple_HTable
358 (Header_Num => Header_Num,
359 Element => Path_Name_Type,
360 No_Element => No_Path,
361 Key => Path_Name_Type,
364 -- A hash table to store the mapping files that are not used
366 type Lang_Naming_Data is record
367 Dot_Replacement : File_Name_Type := No_File;
368 -- The string to replace '.' in the source file name (for Ada)
370 Casing : Casing_Type := All_Lower_Case;
371 -- The casing of the source file name (for Ada)
373 Separate_Suffix : File_Name_Type := No_File;
374 -- String to append to unit name for source file name of an Ada subunit
376 Spec_Suffix : File_Name_Type := No_File;
377 -- The string to append to the unit name for the
378 -- source file name of a spec.
380 Body_Suffix : File_Name_Type := No_File;
381 -- The string to append to the unit name for the
382 -- source file name of a body.
385 No_Lang_Naming_Data : constant Lang_Naming_Data :=
386 (Dot_Replacement => No_File,
387 Casing => All_Lower_Case,
388 Separate_Suffix => No_File,
389 Spec_Suffix => No_File,
390 Body_Suffix => No_File);
393 type Source_Id is access all Source_Data;
395 No_Source : constant Source_Id := null;
397 type Path_Syntax_Kind is
402 -- Host specific syntax, for example on VMS (the default)
404 type Language_Config is record
405 Kind : Language_Kind := File_Based;
406 -- Kind of language. All languages are file based, except Ada which is
409 Naming_Data : Lang_Naming_Data;
410 -- The naming data for the languages (prefixes, etc.)
412 Include_Compatible_Languages : Name_List_Index := No_Name_List;
413 -- The list of languages that are "include compatible" with this
414 -- language. A language B (for example "C") is "include compatible" with
415 -- a language A (for example "C++") if it is expected that sources of
416 -- language A may "include" header files from language B.
418 Compiler_Driver : File_Name_Type := No_File;
419 -- The name of the executable for the compiler of the language
421 Compiler_Driver_Path : String_Access := null;
422 -- The path name of the executable for the compiler of the language
424 Compiler_Leading_Required_Switches : Name_List_Index := No_Name_List;
425 -- The list of initial switches that are required as a minimum to invoke
426 -- the compiler driver.
428 Compiler_Trailing_Required_Switches : Name_List_Index := No_Name_List;
429 -- The list of final switches that are required as a minimum to invoke
430 -- the compiler driver.
432 Path_Syntax : Path_Syntax_Kind := Host;
433 -- Value may be Canonical (Unix style) or Host (host syntax, for example
434 -- on VMS for DEC C).
436 Object_File_Suffix : Name_Id := No_Name;
437 -- Optional alternate object file suffix
439 Object_File_Switches : Name_List_Index := No_Name_List;
440 -- Optional object file switches. When this is defined, the switches
441 -- are used to specify the object file. The object file name is appended
442 -- to the last switch in the list. Example: ("-o", "").
444 Compilation_PIC_Option : Name_List_Index := No_Name_List;
445 -- The option(s) to compile a source in Position Independent Code for
446 -- shared libraries. Specified in the configuration. When not specified,
447 -- there is no need for such switch.
449 Object_Generated : Boolean := True;
450 -- False in no object file is generated
452 Objects_Linked : Boolean := True;
453 -- False if object files are not use to link executables and build
456 Runtime_Library_Dir : Name_Id := No_Name;
457 -- Path name of the runtime library directory, if any
459 Runtime_Source_Dir : Name_Id := No_Name;
460 -- Path name of the runtime source directory, if any
462 Mapping_File_Switches : Name_List_Index := No_Name_List;
463 -- The option(s) to provide a mapping file to the compiler. Specified in
464 -- the configuration. When value is No_Name_List, there is no mapping
467 Mapping_Spec_Suffix : File_Name_Type := No_File;
468 -- Placeholder representing the spec suffix in a mapping file
470 Mapping_Body_Suffix : File_Name_Type := No_File;
471 -- Placeholder representing the body suffix in a mapping file
473 Config_File_Switches : Name_List_Index := No_Name_List;
474 -- The option(s) to provide a config file to the compiler. Specified in
475 -- the configuration. When value is No_Name_List, there is no config
478 Dependency_Kind : Dependency_File_Kind := None;
479 -- The kind of dependency to be checked: none, Makefile fragment or
480 -- ALI file (for Ada).
482 Dependency_Option : Name_List_Index := No_Name_List;
483 -- The option(s) to be used to create the dependency file. When value is
484 -- No_Name_List, there is not such option(s).
486 Compute_Dependency : Name_List_Index := No_Name_List;
487 -- Hold the value of attribute Dependency_Driver, if declared for the
490 Include_Option : Name_List_Index := No_Name_List;
491 -- Hold the value of attribute Include_Switches, if declared for the
494 Include_Path : Name_Id := No_Name;
495 -- Name of environment variable declared by attribute Include_Path for
498 Include_Path_File : Name_Id := No_Name;
499 -- Name of environment variable declared by attribute Include_Path_File
502 Objects_Path : Name_Id := No_Name;
503 -- Name of environment variable declared by attribute Objects_Path for
506 Objects_Path_File : Name_Id := No_Name;
507 -- Name of environment variable declared by attribute Objects_Path_File
510 Config_Body : Name_Id := No_Name;
511 -- The template for a pragma Source_File_Name(_Project) for a specific
512 -- file name of a body.
514 Config_Spec : Name_Id := No_Name;
515 -- The template for a pragma Source_File_Name(_Project) for a specific
516 -- file name of a spec.
518 Config_Body_Pattern : Name_Id := No_Name;
519 -- The template for a pragma Source_File_Name(_Project) for a naming
522 Config_Spec_Pattern : Name_Id := No_Name;
523 -- The template for a pragma Source_File_Name(_Project) for a naming
526 Config_File_Unique : Boolean := False;
527 -- Indicate if the config file specified to the compiler needs to be
528 -- unique. If it is unique, then all config files are concatenated into
529 -- a temp config file.
531 Binder_Driver : File_Name_Type := No_File;
532 -- The name of the binder driver for the language, if any
534 Binder_Driver_Path : Path_Name_Type := No_Path;
535 -- The path name of the binder driver
537 Binder_Required_Switches : Name_List_Index := No_Name_List;
538 -- Hold the value of attribute Binder'Required_Switches for the language
540 Binder_Prefix : Name_Id := No_Name;
541 -- Hold the value of attribute Binder'Prefix for the language
543 Toolchain_Version : Name_Id := No_Name;
544 -- Hold the value of attribute Toolchain_Version for the language
546 Toolchain_Description : Name_Id := No_Name;
547 -- Hold the value of attribute Toolchain_Description for the language
550 -- Record describing the configuration of a language
552 No_Language_Config : constant Language_Config :=
554 Naming_Data => No_Lang_Naming_Data,
555 Include_Compatible_Languages => No_Name_List,
556 Compiler_Driver => No_File,
557 Compiler_Driver_Path => null,
558 Compiler_Leading_Required_Switches => No_Name_List,
559 Compiler_Trailing_Required_Switches => No_Name_List,
560 Path_Syntax => Canonical,
561 Object_File_Suffix => No_Name,
562 Object_File_Switches => No_Name_List,
563 Compilation_PIC_Option => No_Name_List,
564 Object_Generated => True,
565 Objects_Linked => True,
566 Runtime_Library_Dir => No_Name,
567 Runtime_Source_Dir => No_Name,
568 Mapping_File_Switches => No_Name_List,
569 Mapping_Spec_Suffix => No_File,
570 Mapping_Body_Suffix => No_File,
571 Config_File_Switches => No_Name_List,
572 Dependency_Kind => Makefile,
573 Dependency_Option => No_Name_List,
574 Compute_Dependency => No_Name_List,
575 Include_Option => No_Name_List,
576 Include_Path => No_Name,
577 Include_Path_File => No_Name,
578 Objects_Path => No_Name,
579 Objects_Path_File => No_Name,
580 Config_Body => No_Name,
581 Config_Spec => No_Name,
582 Config_Body_Pattern => No_Name,
583 Config_Spec_Pattern => No_Name,
584 Config_File_Unique => False,
585 Binder_Driver => No_File,
586 Binder_Driver_Path => No_Path,
587 Binder_Required_Switches => No_Name_List,
588 Binder_Prefix => No_Name,
589 Toolchain_Version => No_Name,
590 Toolchain_Description => No_Name);
592 type Language_Data is record
593 Name : Name_Id := No_Name;
594 Display_Name : Name_Id := No_Name;
595 Config : Language_Config := No_Language_Config;
596 First_Source : Source_Id := No_Source;
597 Mapping_Files : Mapping_Files_Htable.Instance :=
598 Mapping_Files_Htable.Nil;
599 Next : Language_Ptr := No_Language_Index;
602 No_Language_Data : constant Language_Data :=
604 Display_Name => No_Name,
605 Config => No_Language_Config,
606 First_Source => No_Source,
607 Mapping_Files => Mapping_Files_Htable.Nil,
608 Next => No_Language_Index);
610 type Language_List_Element;
611 type Language_List is access all Language_List_Element;
612 type Language_List_Element is record
613 Language : Language_Ptr := No_Language_Index;
614 Next : Language_List;
617 type Source_Kind is (Spec, Impl, Sep);
619 type Source_Data is record
620 Project : Project_Id := No_Project;
621 -- Project of the source
623 Language : Language_Ptr := No_Language_Index;
624 -- Index of the language. This is an index into
625 -- Project_Tree.Languages_Data.
627 Lang_Kind : Language_Kind := File_Based;
628 -- Kind of the language
630 Compiled : Boolean := True;
631 -- False when there is no compiler for the language
633 In_Interfaces : Boolean := True;
634 -- False when the source is not included in interfaces, when attribute
635 -- Interfaces is declared.
637 Declared_In_Interfaces : Boolean := False;
638 -- True when source is declared in attribute Interfaces
640 Alternate_Languages : Language_List;
641 -- List of languages a header file may also be, in addition of language
644 Kind : Source_Kind := Spec;
645 -- Kind of the source: spec, body or subunit
647 Dependency : Dependency_File_Kind := None;
648 -- Kind of dependency: none, Makefile fragment or ALI file
650 Other_Part : Source_Id := No_Source;
651 -- Source ID for the other part, if any: for a spec, indicates its body;
652 -- for a body, indicates its spec.
654 Unit : Name_Id := No_Name;
655 -- Name of the unit, if language is unit based
658 -- Index of the source in a multi unit source file
660 Locally_Removed : Boolean := False;
661 -- True if the source has been "excluded"
663 Get_Object : Boolean := False;
664 -- Indicates that the object of the source should be put in the global
665 -- archive. This is for Ada, when only the closure of a main needs to
666 -- be compiled/recompiled.
668 Replaced_By : Source_Id := No_Source;
670 File : File_Name_Type := No_File;
671 -- Canonical file name of the source
673 Display_File : File_Name_Type := No_File;
674 -- File name of the source, for display purposes
676 Path : Path_Information := No_Path_Information;
677 -- Path name of the source
679 Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
680 -- Time stamp of the source file
682 Object_Project : Project_Id := No_Project;
683 -- Project where the object file is. This might be different from
684 -- Project when using extending project files.
686 Object_Exists : Boolean := True;
687 -- True if an object file exists
689 Object_Linked : Boolean := True;
690 -- False if the object file is not use to link executables or included
693 Object : File_Name_Type := No_File;
694 -- File name of the object file
696 Current_Object_Path : Path_Name_Type := No_Path;
697 -- Object path of an existing object file
699 Object_Path : Path_Name_Type := No_Path;
700 -- Object path of the real object file
702 Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
703 -- Object file time stamp
705 Dep_Name : File_Name_Type := No_File;
706 -- Dependency file simple name
708 Current_Dep_Path : Path_Name_Type := No_Path;
709 -- Path name of an existing dependency file
711 Dep_Path : Path_Name_Type := No_Path;
712 -- Path name of the real dependency file
714 Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
715 -- Dependency file time stamp
717 Switches : File_Name_Type := No_File;
718 -- File name of the switches file. For all languages, this is a file
719 -- that ends with the .cswi extension.
721 Switches_Path : Path_Name_Type := No_Path;
722 -- Path name of the switches file
724 Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
725 -- Switches file time stamp
727 Naming_Exception : Boolean := False;
728 -- True if the source has an exceptional name
730 Next_In_Lang : Source_Id := No_Source;
731 -- Link to another source of the same language in the same project
734 No_Source_Data : constant Source_Data :=
735 (Project => No_Project,
736 Language => No_Language_Index,
737 Lang_Kind => File_Based,
739 In_Interfaces => True,
740 Declared_In_Interfaces => False,
741 Alternate_Languages => null,
744 Other_Part => No_Source,
747 Locally_Removed => False,
749 Replaced_By => No_Source,
751 Display_File => No_File,
752 Path => No_Path_Information,
753 Source_TS => Empty_Time_Stamp,
754 Object_Project => No_Project,
755 Object_Exists => True,
756 Object_Linked => True,
758 Current_Object_Path => No_Path,
759 Object_Path => No_Path,
760 Object_TS => Empty_Time_Stamp,
762 Current_Dep_Path => No_Path,
764 Dep_TS => Empty_Time_Stamp,
766 Switches_Path => No_Path,
767 Switches_TS => Empty_Time_Stamp,
768 Naming_Exception => False,
769 Next_In_Lang => No_Source);
771 package Source_Paths_Htable is new Simple_HTable
772 (Header_Num => Header_Num,
773 Element => Source_Id,
774 No_Element => No_Source,
775 Key => Path_Name_Type,
778 -- Mapping of source paths to source ids
780 package Unit_Sources_Htable is new Simple_HTable
781 (Header_Num => Header_Num,
782 Element => Source_Id,
783 No_Element => No_Source,
788 type Verbosity is (Default, Medium, High);
789 -- Verbosity when parsing GNAT Project Files
790 -- Default is default (very quiet, if no errors).
791 -- Medium is more verbose.
792 -- High is extremely verbose.
794 Current_Verbosity : Verbosity := Default;
795 -- The current value of the verbosity the project files are parsed with
797 type Lib_Kind is (Static, Dynamic, Relocatable);
799 type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
800 -- Type to specify the symbol policy, when symbol control is supported.
801 -- See full explanation about this type in package Symbols.
802 -- Autonomous: Create a symbol file without considering any reference
803 -- Compliant: Try to be as compatible as possible with an existing ref
804 -- Controlled: Fail if symbols are not the same as those in the reference
805 -- Restricted: Restrict the symbols to those in the symbol file
806 -- Direct: The symbol file is used as is
808 type Symbol_Record is record
809 Symbol_File : Path_Name_Type := No_Path;
810 Reference : Path_Name_Type := No_Path;
811 Symbol_Policy : Policy := Autonomous;
813 -- Type to keep the symbol data to be used when building a shared library
815 No_Symbols : constant Symbol_Record :=
816 (Symbol_File => No_Path,
817 Reference => No_Path,
818 Symbol_Policy => Autonomous);
819 -- The default value of the symbol data
821 function Image (Casing : Casing_Type) return String;
822 -- Similar to 'Image (but avoid use of this attribute in compiler)
824 function Value (Image : String) return Casing_Type;
825 -- Similar to 'Value (but avoid use of this attribute in compiler)
826 -- Raises Constraint_Error if not a Casing_Type image.
828 -- The following record contains data for a naming scheme
830 type Naming_Data is record
832 Dot_Replacement : File_Name_Type := No_File;
833 -- The string to replace '.' in the source file name (for Ada)
835 Casing : Casing_Type := All_Lower_Case;
836 -- The casing of the source file name (for Ada)
838 Spec_Suffix : Array_Element_Id := No_Array_Element;
839 -- The string to append to the unit name for the
840 -- source file name of a spec.
841 -- Indexed by the programming language.
843 Body_Suffix : Array_Element_Id := No_Array_Element;
844 -- The string to append to the unit name for the
845 -- source file name of a body.
846 -- Indexed by the programming language.
848 Separate_Suffix : File_Name_Type := No_File;
849 -- String to append to unit name for source file name of an Ada subunit
851 Specs : Array_Element_Id := No_Array_Element;
852 -- An associative array mapping individual specs to source file names
853 -- This is specific to unit-based languages.
855 Bodies : Array_Element_Id := No_Array_Element;
856 -- An associative array mapping individual bodies to source file names
857 -- This is specific to unit-based languages.
859 Specification_Exceptions : Array_Element_Id := No_Array_Element;
860 -- An associative array listing spec file names that do not have the
861 -- spec suffix. Not used by Ada. Indexed by programming language name.
863 Implementation_Exceptions : Array_Element_Id := No_Array_Element;
864 -- An associative array listing body file names that do not have the
865 -- body suffix. Not used by Ada. Indexed by programming language name.
869 function Spec_Suffix_Of
870 (In_Tree : Project_Tree_Ref;
872 Naming : Naming_Data) return String;
874 function Spec_Suffix_Id_Of
875 (In_Tree : Project_Tree_Ref;
876 Language_Id : Name_Id;
877 Naming : Naming_Data) return File_Name_Type;
879 procedure Set_Spec_Suffix
880 (In_Tree : Project_Tree_Ref;
882 Naming : in out Naming_Data;
883 Suffix : File_Name_Type);
885 function Body_Suffix_Id_Of
886 (In_Tree : Project_Tree_Ref;
887 Language_Id : Name_Id;
888 Naming : Naming_Data) return File_Name_Type;
890 function Body_Suffix_Of
891 (In_Tree : Project_Tree_Ref;
893 Naming : Naming_Data) return String;
895 procedure Set_Body_Suffix
896 (In_Tree : Project_Tree_Ref;
898 Naming : in out Naming_Data;
899 Suffix : File_Name_Type);
901 function Get_Object_Directory
902 (Project : Project_Id;
903 Including_Libraries : Boolean;
904 Only_If_Ada : Boolean := False) return Path_Name_Type;
905 -- Return the object directory to use for the project. This depends on
906 -- whether we have a library project or a standard project. This function
907 -- might return No_Name when no directory applies.
908 -- If we have a a library project file and Including_Libraries is True then
909 -- the library dir is returned instead of the object dir.
910 -- If Only_If_Ada is True, then No_Name will be returned when the project
911 -- doesn't Ada sources.
913 procedure Compute_All_Imported_Projects (Project : Project_Id);
914 -- Compute, the list of the projects imported directly or indirectly by
915 -- project Project. The result is stored in Project.All_Imported_Projects
917 function Ultimate_Extending_Project_Of
918 (Proj : Project_Id) return Project_Id;
919 -- Returns the ultimate extending project of project Proj. If project Proj
920 -- is not extended, returns Proj.
922 function Standard_Naming_Data
923 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
924 pragma Inline (Standard_Naming_Data);
925 -- The standard GNAT naming scheme when Tree is No_Project_Tree.
926 -- Otherwise, return the default naming scheme for the project tree Tree,
927 -- which must have been Initialized.
929 function Same_Naming_Scheme
930 (Left, Right : Naming_Data) return Boolean;
931 -- Returns True if Left and Right are the same naming scheme
932 -- not considering Specs and Bodies.
934 type Project_List_Element;
935 type Project_List is access all Project_List_Element;
936 type Project_List_Element is record
937 Project : Project_Id := No_Project;
938 Next : Project_List := null;
940 -- A list of projects
943 (List : in out Project_List;
944 Free_Project : Boolean);
945 -- Free the list of projects, if Free_Project, each project is also freed
947 type Response_File_Format is
952 -- The format of the different response files
954 type Project_Configuration is record
955 Target : Name_Id := No_Name;
956 -- The target of the configuration, when specified
958 Run_Path_Option : Name_List_Index := No_Name_List;
959 -- The option to use when linking to specify the path where to look for
962 Separate_Run_Path_Options : Boolean := False;
963 -- True if each directory needs to be specified in a separate run path
966 Executable_Suffix : Name_Id := No_Name;
967 -- The suffix of executables, when specified in the configuration or in
968 -- package Builder of the main project. When this is not specified, the
969 -- executable suffix is the default for the platform.
973 Linker : Path_Name_Type := No_Path;
974 -- Path name of the linker driver. Specified in the configuration or in
975 -- the package Builder of the main project.
977 Map_File_Option : Name_Id := No_Name;
978 -- Option to use when invoking the linker to build a map file
980 Minimum_Linker_Options : Name_List_Index := No_Name_List;
981 -- The minimum options for the linker driver. Specified in the
984 Linker_Executable_Option : Name_List_Index := No_Name_List;
985 -- The option(s) to indicate the name of the executable in the linker
986 -- command. Specified in the configuration. When not specified, default
987 -- to -o <executable name>.
989 Linker_Lib_Dir_Option : Name_Id := No_Name;
990 -- The option to specify where to find a library for linking. Specified
991 -- in the configuration. When not specified, defaults to "-L".
993 Linker_Lib_Name_Option : Name_Id := No_Name;
994 -- The option to specify the name of a library for linking. Specified in
995 -- the configuration. When not specified, defaults to "-l".
997 Max_Command_Line_Length : Natural := 0;
998 -- When positive and when Resp_File_Format (see below) is not None,
999 -- if the command line for the invocation of the linker would be greater
1000 -- than this value, a response file is used to invoke the linker.
1002 Resp_File_Format : Response_File_Format := None;
1003 -- The format of a response file, when linking with a response file is
1006 Resp_File_Options : Name_List_Index := No_Name_List;
1007 -- The switches, if any, that precede the path name of the response
1008 -- file in the invocation of the linker.
1012 Library_Builder : Path_Name_Type := No_Path;
1013 -- The executable to build library (specified in the configuration)
1015 Lib_Support : Library_Support := None;
1016 -- The level of library support. Specified in the configuration. Support
1017 -- is none, static libraries only or both static and shared libraries.
1019 Archive_Builder : Name_List_Index := No_Name_List;
1020 -- The name of the executable to build archives, with the minimum
1021 -- switches. Specified in the configuration.
1023 Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
1024 -- The options to append object files to an archive
1026 Archive_Indexer : Name_List_Index := No_Name_List;
1027 -- The name of the executable to index archives, with the minimum
1028 -- switches. Specified in the configuration.
1030 Archive_Suffix : File_Name_Type := No_File;
1031 -- The suffix of archives. Specified in the configuration. When not
1032 -- specified, defaults to ".a".
1034 Lib_Partial_Linker : Name_List_Index := No_Name_List;
1038 Shared_Lib_Driver : File_Name_Type := No_File;
1039 -- The driver to link shared libraries. Set with attribute Library_GCC.
1042 Shared_Lib_Prefix : File_Name_Type := No_File;
1043 -- Part of a shared library file name that precedes the name of the
1044 -- library. Specified in the configuration. When not specified, defaults
1047 Shared_Lib_Suffix : File_Name_Type := No_File;
1048 -- Suffix of shared libraries, after the library name in the shared
1049 -- library name. Specified in the configuration. When not specified,
1050 -- default to ".so".
1052 Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
1053 -- The minimum options to use when building a shared library
1055 Lib_Version_Options : Name_List_Index := No_Name_List;
1056 -- The options to use to specify a library version
1058 Symbolic_Link_Supported : Boolean := False;
1059 -- True if the platform supports symbolic link files
1061 Lib_Maj_Min_Id_Supported : Boolean := False;
1062 -- True if platform supports library major and minor options, such as
1063 -- libname.so -> libname.so.2 -> libname.so.2.4
1065 Auto_Init_Supported : Boolean := False;
1066 -- True if automatic initialisation is supported for shared stand-alone
1070 Default_Project_Config : constant Project_Configuration :=
1072 Run_Path_Option => No_Name_List,
1073 Separate_Run_Path_Options => False,
1074 Executable_Suffix => No_Name,
1076 Map_File_Option => No_Name,
1077 Minimum_Linker_Options => No_Name_List,
1078 Linker_Executable_Option => No_Name_List,
1079 Linker_Lib_Dir_Option => No_Name,
1080 Linker_Lib_Name_Option => No_Name,
1081 Library_Builder => No_Path,
1082 Max_Command_Line_Length => 0,
1083 Resp_File_Format => None,
1084 Resp_File_Options => No_Name_List,
1085 Lib_Support => None,
1086 Archive_Builder => No_Name_List,
1087 Archive_Builder_Append_Option => No_Name_List,
1088 Archive_Indexer => No_Name_List,
1089 Archive_Suffix => No_File,
1090 Lib_Partial_Linker => No_Name_List,
1091 Shared_Lib_Driver => No_File,
1092 Shared_Lib_Prefix => No_File,
1093 Shared_Lib_Suffix => No_File,
1094 Shared_Lib_Min_Options => No_Name_List,
1095 Lib_Version_Options => No_Name_List,
1096 Symbolic_Link_Supported => False,
1097 Lib_Maj_Min_Id_Supported => False,
1098 Auto_Init_Supported => False);
1100 -- The following record describes a project file representation
1102 -- Note that it is not specified if the path names of directories (source,
1103 -- object, library or exec directories) end with or without a directory
1106 type Project_Data is record
1112 Name : Name_Id := No_Name;
1113 -- The name of the project
1115 Display_Name : Name_Id := No_Name;
1116 -- The name of the project with the spelling of its declaration
1118 Qualifier : Project_Qualifier := Unspecified;
1119 -- The eventual qualifier for this project
1121 Externally_Built : Boolean := False;
1122 -- True if the project is externally built. In such case, the Project
1123 -- Manager will not modify anything in this project.
1125 Config : Project_Configuration;
1127 Path : Path_Information := No_Path_Information;
1128 -- The path name of the project file. This include base name of the
1131 Virtual : Boolean := False;
1132 -- True for virtual extending projects
1134 Location : Source_Ptr := No_Location;
1135 -- The location in the project file source of the reserved word project
1137 Naming : Naming_Data := Standard_Naming_Data;
1138 -- The naming scheme of this project file
1144 Languages : Language_Ptr := No_Language_Index;
1145 -- First index of the language data in the project.
1146 -- This is an index into the project_tree_data.languages_data.
1147 -- Traversing the list gives access to all the languages supported by
1154 Mains : String_List_Id := Nil_String;
1155 -- List of mains specified by attribute Main
1157 Extends : Project_Id := No_Project;
1158 -- The reference of the project file, if any, that this project file
1161 Extended_By : Project_Id := No_Project;
1162 -- The reference of the project file, if any, that extends this project
1165 Decl : Declarations := No_Declarations;
1166 -- The declarations (variables, attributes and packages) of this project
1169 Imported_Projects : Project_List;
1170 -- The list of all directly imported projects, if any
1172 All_Imported_Projects : Project_List;
1173 -- The list of all projects imported directly or indirectly, if any
1179 Directory : Path_Information := No_Path_Information;
1180 -- Path name of the directory where the project file resides
1182 Object_Directory : Path_Information := No_Path_Information;
1183 -- The path name of the object directory of this project file
1185 Exec_Directory : Path_Information := No_Path_Information;
1186 -- The path name of the exec directory of this project file. Default is
1187 -- equal to Object_Directory.
1193 Library : Boolean := False;
1194 -- True if this is a library project
1196 Library_Name : Name_Id := No_Name;
1197 -- If a library project, name of the library
1199 Library_Kind : Lib_Kind := Static;
1200 -- If a library project, kind of library
1202 Library_Dir : Path_Information := No_Path_Information;
1203 -- If a library project, path name of the directory where the library
1206 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
1207 -- The timestamp of a library file in a library project
1209 Library_Src_Dir : Path_Information := No_Path_Information;
1210 -- If a Stand-Alone Library project, path name of the directory where
1211 -- the sources of the interfaces of the library are copied. By default,
1212 -- if attribute Library_Src_Dir is not specified, sources of the
1213 -- interfaces are not copied anywhere.
1215 Library_ALI_Dir : Path_Information := No_Path_Information;
1216 -- In a library project, path name of the directory where the ALI files
1217 -- are copied. If attribute Library_ALI_Dir is not specified, ALI files
1218 -- are copied in the Library_Dir.
1220 Lib_Internal_Name : Name_Id := No_Name;
1221 -- If a library project, internal name store inside the library
1223 Standalone_Library : Boolean := False;
1224 -- Indicate that this is a Standalone Library Project File
1226 Lib_Interface_ALIs : String_List_Id := Nil_String;
1227 -- For Standalone Library Project Files, indicate the list of Interface
1230 Lib_Auto_Init : Boolean := False;
1231 -- For non static Stand-Alone Library Project Files, indicate if
1232 -- the library initialisation should be automatic.
1234 Symbol_Data : Symbol_Record := No_Symbols;
1235 -- Symbol file name, reference symbol file name, symbol policy
1237 Need_To_Build_Lib : Boolean := False;
1238 -- Indicates that the library of a Library Project needs to be built or
1244 -- The sources for all languages including Ada are accessible through
1245 -- the Source_Iterator type
1247 Interfaces_Defined : Boolean := False;
1248 -- True if attribute Interfaces is declared for the project or any
1249 -- project it extends.
1251 Include_Path : String_Access := null;
1252 -- The search source path for the project. Used as the value for an
1253 -- environment variable, specified by attribute Include_Path
1254 -- (<language>). The names of the environment variables are in component
1255 -- Include_Path of the records Language_Config.
1257 Include_Path_File : Path_Name_Type := No_Path;
1258 -- The path name of the of the source search directory file
1260 Include_Data_Set : Boolean := False;
1261 -- Set True when Imported_Directories_Switches or Include_Path are set
1263 Source_Dirs : String_List_Id := Nil_String;
1264 -- The list of all the source directories
1266 Known_Order_Of_Source_Dirs : Boolean := True;
1267 -- False, if there is any /** in the Source_Dirs, because in this case
1268 -- the ordering of the source subdirs depend on the OS. If True,
1269 -- duplicate file names in the same project file are allowed.
1271 Ada_Include_Path : String_Access := null;
1272 -- The cached value of source search path for this project file. Set by
1273 -- the first call to Prj.Env.Ada_Include_Path for the project. Do not
1274 -- use this field directly outside of the project manager, use
1275 -- Prj.Env.Ada_Include_Path instead.
1281 Ada_Objects_Path : String_Access := null;
1282 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
1283 -- use this field directly outside of the compiler, use
1284 -- Prj.Env.Ada_Objects_Path instead.
1286 Libgnarl_Needed : Yes_No_Unknown := Unknown;
1287 -- Set to True when libgnarl is needed to link
1289 Objects_Path : String_Access := null;
1290 -- The cached value of the object dir path, used during the binding
1291 -- phase of gprbuild.
1293 Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
1294 -- The cached value of the object path temp file (including library
1295 -- dirs) for this project file.
1297 Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
1298 -- The cached value of the object path temp file (excluding library
1299 -- dirs) for this project file.
1301 Config_File_Name : Path_Name_Type := No_Path;
1302 -- The path name of the configuration pragmas file, if any
1304 Config_File_Temp : Boolean := False;
1305 -- An indication that the configuration pragmas file is a temporary file
1306 -- that must be deleted at the end.
1308 Config_Checked : Boolean := False;
1309 -- A flag to avoid checking repetitively the configuration pragmas file
1311 Depth : Natural := 0;
1312 -- The maximum depth of a project in the project graph. Depth of main
1315 Unkept_Comments : Boolean := False;
1316 -- True if there are comments in the project sources that cannot be kept
1317 -- in the project tree.
1321 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
1322 -- Return the representation of an empty project in project Tree tree.
1323 -- The project tree Tree must have been Initialized and/or Reset.
1325 function Is_Extending
1326 (Extending : Project_Id;
1327 Extended : Project_Id) return Boolean;
1328 -- Return True if Extending is extending the Extended project
1330 function Is_A_Language
1331 (Project : Project_Id;
1332 Language_Name : Name_Id) return Boolean;
1333 -- Return True when Language_Name (which must be lower case) is one of the
1334 -- languages used for the project.
1336 function Has_Ada_Sources (Data : Project_Id) return Boolean;
1337 -- Return True if the project has Ada sources
1339 function Has_Foreign_Sources (Data : Project_Id) return Boolean;
1340 -- Return True if the project has foreign sources
1342 Project_Error : exception;
1343 -- Raised by some subprograms in Prj.Attr
1345 type Spec_Or_Body is (Specification, Body_Part);
1347 type File_Name_Data is record
1348 Name : File_Name_Type := No_File;
1350 Display_Name : File_Name_Type := No_File;
1351 Path : Path_Information := No_Path_Information;
1352 Project : Project_Id := No_Project;
1353 Needs_Pragma : Boolean := False;
1355 -- File and Path name of a spec or body
1357 type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
1359 type Unit_Index is new Nat;
1360 No_Unit_Index : constant Unit_Index := 0;
1361 type Unit_Data is record
1362 Name : Name_Id := No_Name;
1363 File_Names : File_Names_Data;
1365 -- Name and File and Path names of a unit, with a reference to its
1366 -- GNAT Project File(s).
1368 package Unit_Table is new GNAT.Dynamic_Tables
1369 (Table_Component_Type => Unit_Data,
1370 Table_Index_Type => Unit_Index,
1371 Table_Low_Bound => 1,
1372 Table_Initial => 100,
1373 Table_Increment => 100);
1374 -- Table of all units in a project tree
1376 package Units_Htable is new Simple_HTable
1377 (Header_Num => Header_Num,
1378 Element => Unit_Index,
1379 No_Element => No_Unit_Index,
1383 -- Mapping of unit names to indexes in the Units table
1385 package Files_Htable is new Simple_HTable
1386 (Header_Num => Header_Num,
1387 Element => Project_Id,
1388 No_Element => No_Project,
1389 Key => File_Name_Type,
1392 -- Mapping of file names to indexes in the Units table
1394 ---------------------
1395 -- Source_Iterator --
1396 ---------------------
1398 type Source_Iterator is private;
1400 function For_Each_Source
1401 (In_Tree : Project_Tree_Ref;
1402 Project : Project_Id := No_Project;
1403 Language : Name_Id := No_Name) return Source_Iterator;
1404 -- Returns an iterator for all the sources of a project tree, or a specific
1405 -- project, or a specific language.
1407 function Element (Iter : Source_Iterator) return Source_Id;
1408 -- Return the current source (or No_Source if there are no more sources)
1410 procedure Next (Iter : in out Source_Iterator);
1411 -- Move on to the next source
1413 -----------------------
1414 -- Project_Tree_Data --
1415 -----------------------
1417 type Private_Project_Tree_Data is private;
1418 -- Data for a project tree that is used only by the Project Manager
1420 type Project_Tree_Data is
1422 Name_Lists : Name_List_Table.Instance;
1423 String_Elements : String_Element_Table.Instance;
1424 Variable_Elements : Variable_Element_Table.Instance;
1425 Array_Elements : Array_Element_Table.Instance;
1426 Arrays : Array_Table.Instance;
1427 Packages : Package_Table.Instance;
1428 Projects : Project_List;
1429 Units : Unit_Table.Instance;
1430 Units_HT : Units_Htable.Instance;
1431 Source_Paths_HT : Source_Paths_Htable.Instance;
1432 Unit_Sources_HT : Unit_Sources_Htable.Instance;
1436 Private_Part : Private_Project_Tree_Data;
1438 -- Data for a project tree
1440 type Put_Line_Access is access procedure
1442 Project : Project_Id;
1443 In_Tree : Project_Tree_Ref);
1444 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
1446 procedure Expect (The_Token : Token_Type; Token_Image : String);
1447 -- Check that the current token is The_Token. If it is not, then output
1448 -- an error message.
1450 procedure Initialize (Tree : Project_Tree_Ref);
1451 -- This procedure must be called before using any services from the Prj
1452 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
1454 procedure Reset (Tree : Project_Tree_Ref);
1455 -- This procedure resets all the tables that are used when processing a
1456 -- project file tree. Initialize must be called before the call to Reset.
1458 procedure Register_Default_Naming_Scheme
1459 (Language : Name_Id;
1460 Default_Spec_Suffix : File_Name_Type;
1461 Default_Body_Suffix : File_Name_Type;
1462 In_Tree : Project_Tree_Ref);
1463 -- Register the default suffixes for a given language. These extensions
1464 -- will be ignored if the user has specified a new naming scheme in a
1467 -- Otherwise, this information will be automatically added to Naming_Data
1468 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
1470 package Project_Boolean_Htable is new Simple_HTable
1471 (Header_Num => Header_Num,
1473 No_Element => False,
1477 -- A table that associates a project to a boolean. This is used to detect
1478 -- whether a project was already processed for instance.
1481 type State is limited private;
1482 with procedure Action
1483 (Project : Project_Id;
1484 With_State : in out State);
1485 procedure For_Every_Project_Imported
1487 With_State : in out State;
1488 Imported_First : Boolean := False);
1489 -- Call Action for each project imported directly or indirectly by project
1490 -- By, as well as extended projects.
1491 -- The order of processing depends on Imported_First:
1492 -- If False, Action is called according to the order of importation: if A
1493 -- imports B, directly or indirectly, Action will be called for A before
1494 -- it is called for B. If two projects import each other directly or
1495 -- indirectly (using at least one "limited with"), it is not specified
1496 -- for which of these two projects Action will be called first.
1497 -- The order is reversed if Imported_First is True.
1498 -- With_State may be used by Action to choose a behavior or to report some
1501 function Extend_Name
1502 (File : File_Name_Type;
1503 With_Suffix : String) return File_Name_Type;
1504 -- Replace the extension of File with With_Suffix
1506 function Object_Name
1507 (Source_File_Name : File_Name_Type;
1508 Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
1509 -- Returns the object file name corresponding to a source file name
1511 function Dependency_Name
1512 (Source_File_Name : File_Name_Type;
1513 Dependency : Dependency_File_Kind) return File_Name_Type;
1514 -- Returns the dependency file name corresponding to a source file name
1516 function Switches_Name
1517 (Source_File_Name : File_Name_Type) return File_Name_Type;
1518 -- Returns the switches file name corresponding to a source file name
1524 procedure Record_Temp_File (Path : Path_Name_Type);
1525 -- Record the path of a newly created temporary file, so that it can be
1528 procedure Delete_All_Temp_Files;
1529 -- Delete all recorded temporary files
1533 All_Packages : constant String_List_Access := null;
1535 No_Project_Tree : constant Project_Tree_Ref := null;
1537 Ignored : constant Variable_Kind := Single;
1539 Nil_Variable_Value : constant Variable_Value :=
1540 (Project => No_Project,
1542 Location => No_Location,
1545 Virtual_Prefix : constant String := "v$";
1546 -- The prefix for virtual extending projects. Because of the '$', which is
1547 -- normally forbidden for project names, there cannot be any name clash.
1549 Empty_Name : Name_Id;
1550 -- Name_Id for an empty name (no characters). Initialized in procedure
1553 Empty_File_Name : File_Name_Type;
1554 -- Empty File_Name_Type (no characters). Initialized in procedure
1557 type Source_Iterator is record
1558 In_Tree : Project_Tree_Ref;
1560 Project : Project_List;
1561 All_Projects : Boolean;
1562 -- Current project and whether we should move on to the next
1564 Language : Language_Ptr;
1565 -- Current language processed
1567 Language_Name : Name_Id;
1568 -- Only sources of this language will be returned (or all if No_Name)
1570 Current : Source_Id;
1573 procedure Add_To_Buffer
1575 To : in out String_Access;
1576 Last : in out Natural);
1577 -- Append a String to the Buffer
1579 type Naming_Id is new Nat;
1581 package Naming_Table is new GNAT.Dynamic_Tables
1582 (Table_Component_Type => Naming_Data,
1583 Table_Index_Type => Naming_Id,
1584 Table_Low_Bound => 1,
1586 Table_Increment => 100);
1587 -- Table storing the naming data for gnatmake/gprmake
1589 package Path_File_Table is new GNAT.Dynamic_Tables
1590 (Table_Component_Type => Path_Name_Type,
1591 Table_Index_Type => Natural,
1592 Table_Low_Bound => 1,
1593 Table_Initial => 50,
1594 Table_Increment => 100);
1595 -- Table storing all the temp path file names.
1596 -- Used by Delete_All_Path_Files.
1598 package Source_Path_Table is new GNAT.Dynamic_Tables
1599 (Table_Component_Type => Name_Id,
1600 Table_Index_Type => Natural,
1601 Table_Low_Bound => 1,
1602 Table_Initial => 50,
1603 Table_Increment => 100);
1604 -- A table to store the source dirs before creating the source path file
1606 package Object_Path_Table is new GNAT.Dynamic_Tables
1607 (Table_Component_Type => Path_Name_Type,
1608 Table_Index_Type => Natural,
1609 Table_Low_Bound => 1,
1610 Table_Initial => 50,
1611 Table_Increment => 100);
1612 -- A table to store the object dirs, before creating the object path file
1614 type Private_Project_Tree_Data is record
1615 Namings : Naming_Table.Instance;
1616 Path_Files : Path_File_Table.Instance;
1617 Source_Paths : Source_Path_Table.Instance;
1618 Object_Paths : Object_Path_Table.Instance;
1619 Default_Naming : Naming_Data;
1621 Current_Source_Path_File : Path_Name_Type := No_Path;
1622 -- Current value of project source path file env var. Used to avoid
1623 -- setting the env var to the same value.
1625 Current_Object_Path_File : Path_Name_Type := No_Path;
1626 -- Current value of project object path file env var. Used to avoid
1627 -- setting the env var to the same value.
1629 Ada_Path_Buffer : String_Access := new String (1 .. 1024);
1630 -- A buffer where values for ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are
1633 Ada_Path_Length : Natural := 0;
1634 -- Index of the last valid character in Ada_Path_Buffer
1636 Ada_Prj_Include_File_Set : Boolean := False;
1637 Ada_Prj_Objects_File_Set : Boolean := False;
1638 -- These flags are set to True when the corresponding environment
1639 -- variables are set and are used to give these environment variables an
1640 -- empty string value at the end of the program. This has no practical
1641 -- effect on most platforms, except on VMS where the logical names are
1642 -- deassigned, thus avoiding the pollution of the environment of the
1645 Fill_Mapping_File : Boolean := True;
1648 -- Type to represent the part of a project tree which is private to the