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 Config_Project_File_Extension : String := ".cgpr";
125 Project_File_Extension : String := ".gpr";
126 -- The standard config and user project file name extensions. They are not
127 -- constants, because Canonical_Case_File_Name is called on these variables
128 -- in the body of Prj.
130 type Error_Warning is (Silent, Warning, Error);
131 -- Severity of some situations, such as: no Ada sources in a project where
132 -- Ada is one of the language.
134 -- When the situation occurs, the behaviour depends on the setting:
136 -- - Silent: no action
137 -- - Warning: issue a warning, does not cause the tool to fail
138 -- - Error: issue an error, causes the tool to fail
140 function Empty_File return File_Name_Type;
141 function Empty_String return Name_Id;
142 -- Return the id for an empty string ""
144 type Path_Information is record
145 Name : Path_Name_Type := No_Path;
146 Display_Name : Path_Name_Type := No_Path;
148 -- Directory names always end with a directory separator
150 No_Path_Information : constant Path_Information := (No_Path, No_Path);
153 type Project_Id is access all Project_Data;
154 No_Project : constant Project_Id := null;
155 -- Id of a Project File
157 type String_List_Id is new Nat;
158 Nil_String : constant String_List_Id := 0;
159 type String_Element is record
160 Value : Name_Id := No_Name;
162 Display_Value : Name_Id := No_Name;
163 Location : Source_Ptr := No_Location;
164 Flag : Boolean := False;
165 Next : String_List_Id := Nil_String;
167 -- To hold values for string list variables and array elements.
168 -- Component Flag may be used for various purposes. For source
169 -- directories, it indicates if the directory contains Ada source(s).
171 package String_Element_Table is new GNAT.Dynamic_Tables
172 (Table_Component_Type => String_Element,
173 Table_Index_Type => String_List_Id,
174 Table_Low_Bound => 1,
175 Table_Initial => 200,
176 Table_Increment => 100);
177 -- The table for string elements in string lists
179 type Variable_Kind is (Undefined, List, Single);
180 -- Different kinds of variables
182 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
183 -- The defined kinds of variables
185 Ignored : constant Variable_Kind;
186 -- Used to indicate that a package declaration must be ignored
187 -- while processing the project tree (unknown package name).
189 type Variable_Value (Kind : Variable_Kind := Undefined) is record
190 Project : Project_Id := No_Project;
191 Location : Source_Ptr := No_Location;
192 Default : Boolean := False;
197 Values : String_List_Id := Nil_String;
199 Value : Name_Id := No_Name;
203 -- Values for variables and array elements. Default is True if the
204 -- current value is the default one for the variable
206 Nil_Variable_Value : constant Variable_Value;
207 -- Value of a non existing variable or array element
209 type Variable_Id is new Nat;
210 No_Variable : constant Variable_Id := 0;
211 type Variable is record
212 Next : Variable_Id := No_Variable;
214 Value : Variable_Value;
216 -- To hold the list of variables in a project file and in packages
218 package Variable_Element_Table is new GNAT.Dynamic_Tables
219 (Table_Component_Type => Variable,
220 Table_Index_Type => Variable_Id,
221 Table_Low_Bound => 1,
222 Table_Initial => 200,
223 Table_Increment => 100);
224 -- The table of variable in list of variables
226 type Array_Element_Id is new Nat;
227 No_Array_Element : constant Array_Element_Id := 0;
228 type Array_Element is record
230 Src_Index : Int := 0;
231 Index_Case_Sensitive : Boolean := True;
232 Value : Variable_Value;
233 Next : Array_Element_Id := No_Array_Element;
235 -- Each Array_Element represents an array element and is linked (Next)
236 -- to the next array element, if any, in the array.
238 package Array_Element_Table is new GNAT.Dynamic_Tables
239 (Table_Component_Type => Array_Element,
240 Table_Index_Type => Array_Element_Id,
241 Table_Low_Bound => 1,
242 Table_Initial => 200,
243 Table_Increment => 100);
244 -- The table that contains all array elements
246 type Array_Id is new Nat;
247 No_Array : constant Array_Id := 0;
248 type Array_Data is record
249 Name : Name_Id := No_Name;
250 Location : Source_Ptr := No_Location;
251 Value : Array_Element_Id := No_Array_Element;
252 Next : Array_Id := No_Array;
254 -- Each Array_Data value represents an array.
255 -- Value is the id of the first element.
256 -- Next is the id of the next array in the project file or package.
258 package Array_Table is new GNAT.Dynamic_Tables
259 (Table_Component_Type => Array_Data,
260 Table_Index_Type => Array_Id,
261 Table_Low_Bound => 1,
262 Table_Initial => 200,
263 Table_Increment => 100);
264 -- The table that contains all arrays
266 type Package_Id is new Nat;
267 No_Package : constant Package_Id := 0;
268 type Declarations is record
269 Variables : Variable_Id := No_Variable;
270 Attributes : Variable_Id := No_Variable;
271 Arrays : Array_Id := No_Array;
272 Packages : Package_Id := No_Package;
274 -- Contains the declarations (variables, single and array attributes,
275 -- packages) for a project or a package in a project.
277 No_Declarations : constant Declarations :=
278 (Variables => No_Variable,
279 Attributes => No_Variable,
281 Packages => No_Package);
282 -- Default value of Declarations: indicates that there is no declarations
284 type Package_Element is record
285 Name : Name_Id := No_Name;
286 Decl : Declarations := No_Declarations;
287 Parent : Package_Id := No_Package;
288 Next : Package_Id := No_Package;
290 -- A package (includes declarations that may include other packages)
292 package Package_Table is new GNAT.Dynamic_Tables
293 (Table_Component_Type => Package_Element,
294 Table_Index_Type => Package_Id,
295 Table_Low_Bound => 1,
296 Table_Initial => 100,
297 Table_Increment => 100);
298 -- The table that contains all packages
301 type Language_Ptr is access all Language_Data;
302 -- Index of language data
304 No_Language_Index : constant Language_Ptr := null;
305 -- Constant indicating that there is no language data
307 function Get_Language_From_Name
308 (Project : Project_Id;
309 Name : String) return Language_Ptr;
310 -- Get a language from a project. This might return null if no such
311 -- language exists in the project
313 Max_Header_Num : constant := 6150;
314 type Header_Num is range 0 .. Max_Header_Num;
315 -- Size for hash table below. The upper bound is an arbitrary value, the
316 -- value here was chosen after testing to determine a good compromise
317 -- between speed of access and memory usage.
319 function Hash (Name : Name_Id) return Header_Num;
320 function Hash (Name : File_Name_Type) return Header_Num;
321 function Hash (Name : Path_Name_Type) return Header_Num;
322 function Hash (Project : Project_Id) return Header_Num;
323 -- Used for computing hash values for names put into above hash table
325 type Language_Kind is (File_Based, Unit_Based);
326 -- Type for the kind of language. All languages are file based, except Ada
327 -- which is unit based.
329 type Dependency_File_Kind is (None, Makefile, ALI_File);
330 -- Type of dependency to be checked: no dependency file, Makefile fragment
331 -- or ALI file (for Ada).
333 Makefile_Dependency_Suffix : constant String := ".d";
334 ALI_Dependency_Suffix : constant String := ".ali";
336 Switches_Dependency_Suffix : constant String := ".cswi";
338 Binder_Exchange_Suffix : constant String := ".bexch";
339 -- Suffix for binder exchange files
341 Library_Exchange_Suffix : constant String := ".lexch";
342 -- Suffix for library exchange files
344 type Name_List_Index is new Nat;
345 No_Name_List : constant Name_List_Index := 0;
347 type Name_Node is record
348 Name : Name_Id := No_Name;
349 Next : Name_List_Index := No_Name_List;
352 package Name_List_Table is new GNAT.Dynamic_Tables
353 (Table_Component_Type => Name_Node,
354 Table_Index_Type => Name_List_Index,
355 Table_Low_Bound => 1,
357 Table_Increment => 100);
358 -- The table for lists of names used in package Language_Processing
360 package Mapping_Files_Htable is new Simple_HTable
361 (Header_Num => Header_Num,
362 Element => Path_Name_Type,
363 No_Element => No_Path,
364 Key => Path_Name_Type,
367 -- A hash table to store the mapping files that are not used
369 type Lang_Naming_Data is record
370 Dot_Replacement : File_Name_Type := No_File;
371 -- The string to replace '.' in the source file name (for Ada)
373 Casing : Casing_Type := All_Lower_Case;
374 -- The casing of the source file name (for Ada)
376 Separate_Suffix : File_Name_Type := No_File;
377 -- String to append to unit name for source file name of an Ada subunit
379 Spec_Suffix : File_Name_Type := No_File;
380 -- The string to append to the unit name for the
381 -- source file name of a spec.
383 Body_Suffix : File_Name_Type := No_File;
384 -- The string to append to the unit name for the
385 -- source file name of a body.
388 No_Lang_Naming_Data : constant Lang_Naming_Data :=
389 (Dot_Replacement => No_File,
390 Casing => All_Lower_Case,
391 Separate_Suffix => No_File,
392 Spec_Suffix => No_File,
393 Body_Suffix => No_File);
396 type Source_Id is access all Source_Data;
398 function Is_Compilable (Source : Source_Id) return Boolean;
399 pragma Inline (Is_Compilable);
400 -- Return True if we know how to compile Source (i.e. if a compiler is
401 -- defined). This doesn't indicate whether the source should be compiled.
403 function Object_To_Global_Archive (Source : Source_Id) return Boolean;
404 pragma Inline (Object_To_Global_Archive);
405 -- Return True if the object file should be put in the global archive.
406 -- This is for Ada, when only the closure of a main needs to be
409 function Other_Part (Source : Source_Id) return Source_Id;
410 pragma Inline (Other_Part);
411 -- Source ID for the other part, if any: for a spec, indicates its body;
412 -- for a body, indicates its spec.
414 No_Source : constant Source_Id := null;
416 type Path_Syntax_Kind is
421 -- Host specific syntax, for example on VMS (the default)
423 type Language_Config is record
424 Kind : Language_Kind := File_Based;
425 -- Kind of language. All languages are file based, except Ada which is
428 Naming_Data : Lang_Naming_Data;
429 -- The naming data for the languages (prefixes, etc.)
431 Include_Compatible_Languages : Name_List_Index := No_Name_List;
432 -- The list of languages that are "include compatible" with this
433 -- language. A language B (for example "C") is "include compatible" with
434 -- a language A (for example "C++") if it is expected that sources of
435 -- language A may "include" header files from language B.
437 Compiler_Driver : File_Name_Type := No_File;
438 -- The name of the executable for the compiler of the language
440 Compiler_Driver_Path : String_Access := null;
441 -- The path name of the executable for the compiler of the language
443 Compiler_Leading_Required_Switches : Name_List_Index := No_Name_List;
444 -- The list of initial switches that are required as a minimum to invoke
445 -- the compiler driver.
447 Compiler_Trailing_Required_Switches : Name_List_Index := No_Name_List;
448 -- The list of final switches that are required as a minimum to invoke
449 -- the compiler driver.
451 Path_Syntax : Path_Syntax_Kind := Host;
452 -- Value may be Canonical (Unix style) or Host (host syntax, for example
453 -- on VMS for DEC C).
455 Object_File_Suffix : Name_Id := No_Name;
456 -- Optional alternate object file suffix
458 Object_File_Switches : Name_List_Index := No_Name_List;
459 -- Optional object file switches. When this is defined, the switches
460 -- are used to specify the object file. The object file name is appended
461 -- to the last switch in the list. Example: ("-o", "").
463 Compilation_PIC_Option : Name_List_Index := No_Name_List;
464 -- The option(s) to compile a source in Position Independent Code for
465 -- shared libraries. Specified in the configuration. When not specified,
466 -- there is no need for such switch.
468 Object_Generated : Boolean := True;
469 -- False in no object file is generated
471 Objects_Linked : Boolean := True;
472 -- False if object files are not use to link executables and build
475 Runtime_Library_Dir : Name_Id := No_Name;
476 -- Path name of the runtime library directory, if any
478 Runtime_Source_Dir : Name_Id := No_Name;
479 -- Path name of the runtime source directory, if any
481 Mapping_File_Switches : Name_List_Index := No_Name_List;
482 -- The option(s) to provide a mapping file to the compiler. Specified in
483 -- the configuration. When value is No_Name_List, there is no mapping
486 Mapping_Spec_Suffix : File_Name_Type := No_File;
487 -- Placeholder representing the spec suffix in a mapping file
489 Mapping_Body_Suffix : File_Name_Type := No_File;
490 -- Placeholder representing the body suffix in a mapping file
492 Config_File_Switches : Name_List_Index := No_Name_List;
493 -- The option(s) to provide a config file to the compiler. Specified in
494 -- the configuration. When value is No_Name_List, there is no config
497 Dependency_Kind : Dependency_File_Kind := None;
498 -- The kind of dependency to be checked: none, Makefile fragment or
499 -- ALI file (for Ada).
501 Dependency_Option : Name_List_Index := No_Name_List;
502 -- The option(s) to be used to create the dependency file. When value is
503 -- No_Name_List, there is not such option(s).
505 Compute_Dependency : Name_List_Index := No_Name_List;
506 -- Hold the value of attribute Dependency_Driver, if declared for the
509 Include_Option : Name_List_Index := No_Name_List;
510 -- Hold the value of attribute Include_Switches, if declared for the
513 Include_Path : Name_Id := No_Name;
514 -- Name of environment variable declared by attribute Include_Path for
517 Include_Path_File : Name_Id := No_Name;
518 -- Name of environment variable declared by attribute Include_Path_File
521 Objects_Path : Name_Id := No_Name;
522 -- Name of environment variable declared by attribute Objects_Path for
525 Objects_Path_File : Name_Id := No_Name;
526 -- Name of environment variable declared by attribute Objects_Path_File
529 Config_Body : Name_Id := No_Name;
530 -- The template for a pragma Source_File_Name(_Project) for a specific
531 -- file name of a body.
533 Config_Spec : Name_Id := No_Name;
534 -- The template for a pragma Source_File_Name(_Project) for a specific
535 -- file name of a spec.
537 Config_Body_Pattern : Name_Id := No_Name;
538 -- The template for a pragma Source_File_Name(_Project) for a naming
541 Config_Spec_Pattern : Name_Id := No_Name;
542 -- The template for a pragma Source_File_Name(_Project) for a naming
545 Config_File_Unique : Boolean := False;
546 -- Indicate if the config file specified to the compiler needs to be
547 -- unique. If it is unique, then all config files are concatenated into
548 -- a temp config file.
550 Binder_Driver : File_Name_Type := No_File;
551 -- The name of the binder driver for the language, if any
553 Binder_Driver_Path : Path_Name_Type := No_Path;
554 -- The path name of the binder driver
556 Binder_Required_Switches : Name_List_Index := No_Name_List;
557 -- Hold the value of attribute Binder'Required_Switches for the language
559 Binder_Prefix : Name_Id := No_Name;
560 -- Hold the value of attribute Binder'Prefix for the language
562 Toolchain_Version : Name_Id := No_Name;
563 -- Hold the value of attribute Toolchain_Version for the language
565 Toolchain_Description : Name_Id := No_Name;
566 -- Hold the value of attribute Toolchain_Description for the language
569 -- Record describing the configuration of a language
571 No_Language_Config : constant Language_Config :=
573 Naming_Data => No_Lang_Naming_Data,
574 Include_Compatible_Languages => No_Name_List,
575 Compiler_Driver => No_File,
576 Compiler_Driver_Path => null,
577 Compiler_Leading_Required_Switches => No_Name_List,
578 Compiler_Trailing_Required_Switches => No_Name_List,
579 Path_Syntax => Canonical,
580 Object_File_Suffix => No_Name,
581 Object_File_Switches => No_Name_List,
582 Compilation_PIC_Option => No_Name_List,
583 Object_Generated => True,
584 Objects_Linked => True,
585 Runtime_Library_Dir => No_Name,
586 Runtime_Source_Dir => No_Name,
587 Mapping_File_Switches => No_Name_List,
588 Mapping_Spec_Suffix => No_File,
589 Mapping_Body_Suffix => No_File,
590 Config_File_Switches => No_Name_List,
591 Dependency_Kind => None,
592 Dependency_Option => No_Name_List,
593 Compute_Dependency => No_Name_List,
594 Include_Option => No_Name_List,
595 Include_Path => No_Name,
596 Include_Path_File => No_Name,
597 Objects_Path => No_Name,
598 Objects_Path_File => No_Name,
599 Config_Body => No_Name,
600 Config_Spec => No_Name,
601 Config_Body_Pattern => No_Name,
602 Config_Spec_Pattern => No_Name,
603 Config_File_Unique => False,
604 Binder_Driver => No_File,
605 Binder_Driver_Path => No_Path,
606 Binder_Required_Switches => No_Name_List,
607 Binder_Prefix => No_Name,
608 Toolchain_Version => No_Name,
609 Toolchain_Description => No_Name);
611 type Language_Data is record
612 Name : Name_Id := No_Name;
613 Display_Name : Name_Id := No_Name;
614 Config : Language_Config := No_Language_Config;
615 First_Source : Source_Id := No_Source;
616 Mapping_Files : Mapping_Files_Htable.Instance :=
617 Mapping_Files_Htable.Nil;
618 Next : Language_Ptr := No_Language_Index;
621 No_Language_Data : constant Language_Data :=
623 Display_Name => No_Name,
624 Config => No_Language_Config,
625 First_Source => No_Source,
626 Mapping_Files => Mapping_Files_Htable.Nil,
627 Next => No_Language_Index);
629 type Language_List_Element;
630 type Language_List is access all Language_List_Element;
631 type Language_List_Element is record
632 Language : Language_Ptr := No_Language_Index;
633 Next : Language_List;
636 type Source_Kind is (Spec, Impl, Sep);
637 subtype Spec_Or_Body is Source_Kind range Spec .. Impl;
639 type File_Names_Data is array (Spec_Or_Body) of Source_Id;
640 type Unit_Data is record
641 Name : Name_Id := No_Name;
642 File_Names : File_Names_Data;
644 type Unit_Index is access all Unit_Data;
645 No_Unit_Index : constant Unit_Index := null;
646 -- Name and File and Path names of a unit, with a reference to its
647 -- GNAT Project File(s).
649 type Source_Data is record
650 Project : Project_Id := No_Project;
651 -- Project of the source
653 Language : Language_Ptr := No_Language_Index;
654 -- Index of the language. This is an index into
655 -- Project_Tree.Languages_Data.
657 In_Interfaces : Boolean := True;
658 -- False when the source is not included in interfaces, when attribute
659 -- Interfaces is declared.
661 Declared_In_Interfaces : Boolean := False;
662 -- True when source is declared in attribute Interfaces
664 Alternate_Languages : Language_List;
665 -- List of languages a header file may also be, in addition of language
668 Kind : Source_Kind := Spec;
669 -- Kind of the source: spec, body or subunit
671 Unit : Unit_Index := No_Unit_Index;
672 -- Name of the unit, if language is unit based. This is only set for
673 -- those files that are part of the compilation set (for instance a
674 -- file in an extended project that is overridden will not have this
678 -- Index of the source in a multi unit source file (the same Source_Data
679 -- is duplicated several times when there are several units in the same
680 -- file). Index is 0 if there is either no unit or a single one, and
681 -- starts at 1 when there are multiple units
683 Locally_Removed : Boolean := False;
684 -- True if the source has been "excluded"
686 Replaced_By : Source_Id := No_Source;
688 File : File_Name_Type := No_File;
689 -- Canonical file name of the source
691 Display_File : File_Name_Type := No_File;
692 -- File name of the source, for display purposes
694 Path : Path_Information := No_Path_Information;
695 -- Path name of the source
697 Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
698 -- Time stamp of the source file
700 Object_Project : Project_Id := No_Project;
701 -- Project where the object file is. This might be different from
702 -- Project when using extending project files.
704 Object : File_Name_Type := No_File;
705 -- File name of the object file
707 Current_Object_Path : Path_Name_Type := No_Path;
708 -- Object path of an existing object file
710 Object_Path : Path_Name_Type := No_Path;
711 -- Object path of the real object file
713 Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
714 -- Object file time stamp
716 Dep_Name : File_Name_Type := No_File;
717 -- Dependency file simple name
719 Current_Dep_Path : Path_Name_Type := No_Path;
720 -- Path name of an existing dependency file
722 Dep_Path : Path_Name_Type := No_Path;
723 -- Path name of the real dependency file
725 Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
726 -- Dependency file time stamp
728 Switches : File_Name_Type := No_File;
729 -- File name of the switches file. For all languages, this is a file
730 -- that ends with the .cswi extension.
732 Switches_Path : Path_Name_Type := No_Path;
733 -- Path name of the switches file
735 Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
736 -- Switches file time stamp
738 Naming_Exception : Boolean := False;
739 -- True if the source has an exceptional name
741 Next_In_Lang : Source_Id := No_Source;
742 -- Link to another source of the same language in the same project
745 No_Source_Data : constant Source_Data :=
746 (Project => No_Project,
747 Language => No_Language_Index,
748 In_Interfaces => True,
749 Declared_In_Interfaces => False,
750 Alternate_Languages => null,
752 Unit => No_Unit_Index,
754 Locally_Removed => False,
755 Replaced_By => No_Source,
757 Display_File => No_File,
758 Path => No_Path_Information,
759 Source_TS => Empty_Time_Stamp,
760 Object_Project => No_Project,
762 Current_Object_Path => No_Path,
763 Object_Path => No_Path,
764 Object_TS => Empty_Time_Stamp,
766 Current_Dep_Path => No_Path,
768 Dep_TS => Empty_Time_Stamp,
770 Switches_Path => No_Path,
771 Switches_TS => Empty_Time_Stamp,
772 Naming_Exception => False,
773 Next_In_Lang => No_Source);
775 package Source_Paths_Htable is new Simple_HTable
776 (Header_Num => Header_Num,
777 Element => Source_Id,
778 No_Element => No_Source,
779 Key => Path_Name_Type,
782 -- Mapping of source paths to source ids
784 package Unit_Sources_Htable is new Simple_HTable
785 (Header_Num => Header_Num,
786 Element => Source_Id,
787 No_Element => No_Source,
792 type Verbosity is (Default, Medium, High);
793 -- Verbosity when parsing GNAT Project Files
794 -- Default is default (very quiet, if no errors).
795 -- Medium is more verbose.
796 -- High is extremely verbose.
798 Current_Verbosity : Verbosity := Default;
799 -- The current value of the verbosity the project files are parsed with
801 type Lib_Kind is (Static, Dynamic, Relocatable);
803 type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
804 -- Type to specify the symbol policy, when symbol control is supported.
805 -- See full explanation about this type in package Symbols.
806 -- Autonomous: Create a symbol file without considering any reference
807 -- Compliant: Try to be as compatible as possible with an existing ref
808 -- Controlled: Fail if symbols are not the same as those in the reference
809 -- Restricted: Restrict the symbols to those in the symbol file
810 -- Direct: The symbol file is used as is
812 type Symbol_Record is record
813 Symbol_File : Path_Name_Type := No_Path;
814 Reference : Path_Name_Type := No_Path;
815 Symbol_Policy : Policy := Autonomous;
817 -- Type to keep the symbol data to be used when building a shared library
819 No_Symbols : constant Symbol_Record :=
820 (Symbol_File => No_Path,
821 Reference => No_Path,
822 Symbol_Policy => Autonomous);
823 -- The default value of the symbol data
825 function Image (Casing : Casing_Type) return String;
826 -- Similar to 'Image (but avoid use of this attribute in compiler)
828 function Value (Image : String) return Casing_Type;
829 -- Similar to 'Value (but avoid use of this attribute in compiler)
830 -- Raises Constraint_Error if not a Casing_Type image.
832 -- The following record contains data for a naming scheme
834 function Get_Object_Directory
835 (Project : Project_Id;
836 Including_Libraries : Boolean;
837 Only_If_Ada : Boolean := False) return Path_Name_Type;
838 -- Return the object directory to use for the project. This depends on
839 -- whether we have a library project or a standard project. This function
840 -- might return No_Name when no directory applies.
841 -- If we have a a library project file and Including_Libraries is True then
842 -- the library dir is returned instead of the object dir.
843 -- If Only_If_Ada is True, then No_Name will be returned when the project
844 -- doesn't Ada sources.
846 procedure Compute_All_Imported_Projects (Project : Project_Id);
847 -- Compute, the list of the projects imported directly or indirectly by
848 -- project Project. The result is stored in Project.All_Imported_Projects
850 function Ultimate_Extending_Project_Of
851 (Proj : Project_Id) return Project_Id;
852 -- Returns the ultimate extending project of project Proj. If project Proj
853 -- is not extended, returns Proj.
855 type Project_List_Element;
856 type Project_List is access all Project_List_Element;
857 type Project_List_Element is record
858 Project : Project_Id := No_Project;
859 Next : Project_List := null;
861 -- A list of projects
864 (List : in out Project_List;
865 Free_Project : Boolean);
866 -- Free the list of projects, if Free_Project, each project is also freed
868 type Response_File_Format is
873 -- The format of the different response files
875 type Project_Configuration is record
876 Target : Name_Id := No_Name;
877 -- The target of the configuration, when specified
879 Run_Path_Option : Name_List_Index := No_Name_List;
880 -- The option to use when linking to specify the path where to look for
883 Separate_Run_Path_Options : Boolean := False;
884 -- True if each directory needs to be specified in a separate run path
887 Executable_Suffix : Name_Id := No_Name;
888 -- The suffix of executables, when specified in the configuration or in
889 -- package Builder of the main project. When this is not specified, the
890 -- executable suffix is the default for the platform.
894 Linker : Path_Name_Type := No_Path;
895 -- Path name of the linker driver. Specified in the configuration or in
896 -- the package Builder of the main project.
898 Map_File_Option : Name_Id := No_Name;
899 -- Option to use when invoking the linker to build a map file
901 Minimum_Linker_Options : Name_List_Index := No_Name_List;
902 -- The minimum options for the linker driver. Specified in the
905 Linker_Executable_Option : Name_List_Index := No_Name_List;
906 -- The option(s) to indicate the name of the executable in the linker
907 -- command. Specified in the configuration. When not specified, default
908 -- to -o <executable name>.
910 Linker_Lib_Dir_Option : Name_Id := No_Name;
911 -- The option to specify where to find a library for linking. Specified
912 -- in the configuration. When not specified, defaults to "-L".
914 Linker_Lib_Name_Option : Name_Id := No_Name;
915 -- The option to specify the name of a library for linking. Specified in
916 -- the configuration. When not specified, defaults to "-l".
918 Max_Command_Line_Length : Natural := 0;
919 -- When positive and when Resp_File_Format (see below) is not None,
920 -- if the command line for the invocation of the linker would be greater
921 -- than this value, a response file is used to invoke the linker.
923 Resp_File_Format : Response_File_Format := None;
924 -- The format of a response file, when linking with a response file is
927 Resp_File_Options : Name_List_Index := No_Name_List;
928 -- The switches, if any, that precede the path name of the response
929 -- file in the invocation of the linker.
933 Library_Builder : Path_Name_Type := No_Path;
934 -- The executable to build library (specified in the configuration)
936 Lib_Support : Library_Support := None;
937 -- The level of library support. Specified in the configuration. Support
938 -- is none, static libraries only or both static and shared libraries.
940 Archive_Builder : Name_List_Index := No_Name_List;
941 -- The name of the executable to build archives, with the minimum
942 -- switches. Specified in the configuration.
944 Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
945 -- The options to append object files to an archive
947 Archive_Indexer : Name_List_Index := No_Name_List;
948 -- The name of the executable to index archives, with the minimum
949 -- switches. Specified in the configuration.
951 Archive_Suffix : File_Name_Type := No_File;
952 -- The suffix of archives. Specified in the configuration. When not
953 -- specified, defaults to ".a".
955 Lib_Partial_Linker : Name_List_Index := No_Name_List;
959 Shared_Lib_Driver : File_Name_Type := No_File;
960 -- The driver to link shared libraries. Set with attribute Library_GCC.
963 Shared_Lib_Prefix : File_Name_Type := No_File;
964 -- Part of a shared library file name that precedes the name of the
965 -- library. Specified in the configuration. When not specified, defaults
968 Shared_Lib_Suffix : File_Name_Type := No_File;
969 -- Suffix of shared libraries, after the library name in the shared
970 -- library name. Specified in the configuration. When not specified,
973 Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
974 -- The minimum options to use when building a shared library
976 Lib_Version_Options : Name_List_Index := No_Name_List;
977 -- The options to use to specify a library version
979 Symbolic_Link_Supported : Boolean := False;
980 -- True if the platform supports symbolic link files
982 Lib_Maj_Min_Id_Supported : Boolean := False;
983 -- True if platform supports library major and minor options, such as
984 -- libname.so -> libname.so.2 -> libname.so.2.4
986 Auto_Init_Supported : Boolean := False;
987 -- True if automatic initialisation is supported for shared stand-alone
991 Default_Project_Config : constant Project_Configuration :=
993 Run_Path_Option => No_Name_List,
994 Separate_Run_Path_Options => False,
995 Executable_Suffix => No_Name,
997 Map_File_Option => No_Name,
998 Minimum_Linker_Options => No_Name_List,
999 Linker_Executable_Option => No_Name_List,
1000 Linker_Lib_Dir_Option => No_Name,
1001 Linker_Lib_Name_Option => No_Name,
1002 Library_Builder => No_Path,
1003 Max_Command_Line_Length => 0,
1004 Resp_File_Format => None,
1005 Resp_File_Options => No_Name_List,
1006 Lib_Support => None,
1007 Archive_Builder => No_Name_List,
1008 Archive_Builder_Append_Option => No_Name_List,
1009 Archive_Indexer => No_Name_List,
1010 Archive_Suffix => No_File,
1011 Lib_Partial_Linker => No_Name_List,
1012 Shared_Lib_Driver => No_File,
1013 Shared_Lib_Prefix => No_File,
1014 Shared_Lib_Suffix => No_File,
1015 Shared_Lib_Min_Options => No_Name_List,
1016 Lib_Version_Options => No_Name_List,
1017 Symbolic_Link_Supported => False,
1018 Lib_Maj_Min_Id_Supported => False,
1019 Auto_Init_Supported => False);
1021 -- The following record describes a project file representation
1023 -- Note that it is not specified if the path names of directories (source,
1024 -- object, library or exec directories) end with or without a directory
1027 type Project_Data is record
1033 Name : Name_Id := No_Name;
1034 -- The name of the project
1036 Display_Name : Name_Id := No_Name;
1037 -- The name of the project with the spelling of its declaration
1039 Qualifier : Project_Qualifier := Unspecified;
1040 -- The eventual qualifier for this project
1042 Externally_Built : Boolean := False;
1043 -- True if the project is externally built. In such case, the Project
1044 -- Manager will not modify anything in this project.
1046 Config : Project_Configuration;
1048 Path : Path_Information := No_Path_Information;
1049 -- The path name of the project file. This include base name of the
1052 Virtual : Boolean := False;
1053 -- True for virtual extending projects
1055 Location : Source_Ptr := No_Location;
1056 -- The location in the project file source of the reserved word project
1062 Languages : Language_Ptr := No_Language_Index;
1063 -- First index of the language data in the project.
1064 -- This is an index into the project_tree_data.languages_data.
1065 -- Traversing the list gives access to all the languages supported by
1072 Mains : String_List_Id := Nil_String;
1073 -- List of mains specified by attribute Main
1075 Extends : Project_Id := No_Project;
1076 -- The reference of the project file, if any, that this project file
1079 Extended_By : Project_Id := No_Project;
1080 -- The reference of the project file, if any, that extends this project
1083 Decl : Declarations := No_Declarations;
1084 -- The declarations (variables, attributes and packages) of this project
1087 Imported_Projects : Project_List;
1088 -- The list of all directly imported projects, if any
1090 All_Imported_Projects : Project_List;
1091 -- The list of all projects imported directly or indirectly, if any
1097 Directory : Path_Information := No_Path_Information;
1098 -- Path name of the directory where the project file resides
1100 Object_Directory : Path_Information := No_Path_Information;
1101 -- The path name of the object directory of this project file
1103 Exec_Directory : Path_Information := No_Path_Information;
1104 -- The path name of the exec directory of this project file. Default is
1105 -- equal to Object_Directory.
1111 Library : Boolean := False;
1112 -- True if this is a library project
1114 Library_Name : Name_Id := No_Name;
1115 -- If a library project, name of the library
1117 Library_Kind : Lib_Kind := Static;
1118 -- If a library project, kind of library
1120 Library_Dir : Path_Information := No_Path_Information;
1121 -- If a library project, path name of the directory where the library
1124 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
1125 -- The timestamp of a library file in a library project
1127 Library_Src_Dir : Path_Information := No_Path_Information;
1128 -- If a Stand-Alone Library project, path name of the directory where
1129 -- the sources of the interfaces of the library are copied. By default,
1130 -- if attribute Library_Src_Dir is not specified, sources of the
1131 -- interfaces are not copied anywhere.
1133 Library_ALI_Dir : Path_Information := No_Path_Information;
1134 -- In a library project, path name of the directory where the ALI files
1135 -- are copied. If attribute Library_ALI_Dir is not specified, ALI files
1136 -- are copied in the Library_Dir.
1138 Lib_Internal_Name : Name_Id := No_Name;
1139 -- If a library project, internal name store inside the library
1141 Standalone_Library : Boolean := False;
1142 -- Indicate that this is a Standalone Library Project File
1144 Lib_Interface_ALIs : String_List_Id := Nil_String;
1145 -- For Standalone Library Project Files, indicate the list of Interface
1148 Lib_Auto_Init : Boolean := False;
1149 -- For non static Stand-Alone Library Project Files, indicate if
1150 -- the library initialisation should be automatic.
1152 Symbol_Data : Symbol_Record := No_Symbols;
1153 -- Symbol file name, reference symbol file name, symbol policy
1155 Need_To_Build_Lib : Boolean := False;
1156 -- Indicates that the library of a Library Project needs to be built or
1162 -- The sources for all languages including Ada are accessible through
1163 -- the Source_Iterator type
1165 Interfaces_Defined : Boolean := False;
1166 -- True if attribute Interfaces is declared for the project or any
1167 -- project it extends.
1169 Include_Path : String_Access := null;
1170 -- The search source path for the project. Used as the value for an
1171 -- environment variable, specified by attribute Include_Path
1172 -- (<language>). The names of the environment variables are in component
1173 -- Include_Path of the records Language_Config.
1175 Include_Path_File : Path_Name_Type := No_Path;
1176 -- The path name of the of the source search directory file
1178 Include_Data_Set : Boolean := False;
1179 -- Set True when Imported_Directories_Switches or Include_Path are set
1181 Source_Dirs : String_List_Id := Nil_String;
1182 -- The list of all the source directories
1184 Known_Order_Of_Source_Dirs : Boolean := True;
1185 -- False, if there is any /** in the Source_Dirs, because in this case
1186 -- the ordering of the source subdirs depend on the OS. If True,
1187 -- duplicate file names in the same project file are allowed.
1189 Ada_Include_Path : String_Access := null;
1190 -- The cached value of source search path for this project file. Set by
1191 -- the first call to Prj.Env.Ada_Include_Path for the project. Do not
1192 -- use this field directly outside of the project manager, use
1193 -- Prj.Env.Ada_Include_Path instead.
1199 Ada_Objects_Path : String_Access := null;
1200 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
1201 -- use this field directly outside of the compiler, use
1202 -- Prj.Env.Ada_Objects_Path instead.
1204 Libgnarl_Needed : Yes_No_Unknown := Unknown;
1205 -- Set to True when libgnarl is needed to link
1207 Objects_Path : String_Access := null;
1208 -- The cached value of the object dir path, used during the binding
1209 -- phase of gprbuild.
1211 Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
1212 -- The cached value of the object path temp file (including library
1213 -- dirs) for this project file.
1215 Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
1216 -- The cached value of the object path temp file (excluding library
1217 -- dirs) for this project file.
1219 Config_File_Name : Path_Name_Type := No_Path;
1220 -- The path name of the configuration pragmas file, if any
1222 Config_File_Temp : Boolean := False;
1223 -- An indication that the configuration pragmas file is a temporary file
1224 -- that must be deleted at the end.
1226 Config_Checked : Boolean := False;
1227 -- A flag to avoid checking repetitively the configuration pragmas file
1229 Depth : Natural := 0;
1230 -- The maximum depth of a project in the project graph. Depth of main
1233 Unkept_Comments : Boolean := False;
1234 -- True if there are comments in the project sources that cannot be kept
1235 -- in the project tree.
1239 function Empty_Project return Project_Data;
1240 -- Return the representation of an empty project
1242 function Is_Extending
1243 (Extending : Project_Id;
1244 Extended : Project_Id) return Boolean;
1245 -- Return True if Extending is extending the Extended project
1247 function Is_A_Language
1248 (Project : Project_Id;
1249 Language_Name : Name_Id) return Boolean;
1250 -- Return True when Language_Name (which must be lower case) is one of the
1251 -- languages used for the project.
1253 function Has_Ada_Sources (Data : Project_Id) return Boolean;
1254 -- Return True if the project has Ada sources
1256 function Has_Foreign_Sources (Data : Project_Id) return Boolean;
1257 -- Return True if the project has foreign sources
1259 Project_Error : exception;
1260 -- Raised by some subprograms in Prj.Attr
1262 package Units_Htable is new Simple_HTable
1263 (Header_Num => Header_Num,
1264 Element => Unit_Index,
1265 No_Element => No_Unit_Index,
1269 -- Mapping of unit names to indexes in the Units table
1271 ---------------------
1272 -- Source_Iterator --
1273 ---------------------
1275 type Source_Iterator is private;
1277 function For_Each_Source
1278 (In_Tree : Project_Tree_Ref;
1279 Project : Project_Id := No_Project;
1280 Language : Name_Id := No_Name) return Source_Iterator;
1281 -- Returns an iterator for all the sources of a project tree, or a specific
1282 -- project, or a specific language.
1284 function Element (Iter : Source_Iterator) return Source_Id;
1285 -- Return the current source (or No_Source if there are no more sources)
1287 procedure Next (Iter : in out Source_Iterator);
1288 -- Move on to the next source
1290 function Find_Source
1291 (In_Tree : Project_Tree_Ref;
1292 Project : Project_Id;
1293 In_Imported_Only : Boolean := False;
1294 In_Extended_Only : Boolean := False;
1295 Base_Name : File_Name_Type) return Source_Id;
1296 -- Find the first source file with the given name either in the whole tree
1297 -- (if In_Imported_Only is False) or in the projects imported or extended
1298 -- by Project otherwise. In_Extended_Only implies In_Imported_Only, and
1299 -- will only look in Project and the projects it extends
1301 -----------------------
1302 -- Project_Tree_Data --
1303 -----------------------
1305 type Private_Project_Tree_Data is private;
1306 -- Data for a project tree that is used only by the Project Manager
1308 type Project_Tree_Data is
1310 Name_Lists : Name_List_Table.Instance;
1311 String_Elements : String_Element_Table.Instance;
1312 Variable_Elements : Variable_Element_Table.Instance;
1313 Array_Elements : Array_Element_Table.Instance;
1314 Arrays : Array_Table.Instance;
1315 Packages : Package_Table.Instance;
1316 Projects : Project_List;
1317 Units_HT : Units_Htable.Instance;
1318 Source_Paths_HT : Source_Paths_Htable.Instance;
1319 Unit_Sources_HT : Unit_Sources_Htable.Instance;
1323 Private_Part : Private_Project_Tree_Data;
1325 -- Data for a project tree
1327 type Put_Line_Access is access procedure
1329 Project : Project_Id;
1330 In_Tree : Project_Tree_Ref);
1331 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
1333 procedure Expect (The_Token : Token_Type; Token_Image : String);
1334 -- Check that the current token is The_Token. If it is not, then output
1335 -- an error message.
1337 procedure Initialize (Tree : Project_Tree_Ref);
1338 -- This procedure must be called before using any services from the Prj
1339 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
1341 procedure Reset (Tree : Project_Tree_Ref);
1342 -- This procedure resets all the tables that are used when processing a
1343 -- project file tree. Initialize must be called before the call to Reset.
1345 type Processing_Flags is private;
1346 -- Flags used while parsing and processing a project tree to configure the
1347 -- behavior of the parser, and indicate how to report error messages. This
1348 -- structure does not allocate memory and never needs to be freed
1350 function Create_Flags
1351 (Report_Error : Put_Line_Access;
1352 When_No_Sources : Error_Warning;
1353 Require_Sources_Other_Lang : Boolean := True;
1354 Allow_Duplicate_Basenames : Boolean := True;
1355 Compiler_Driver_Mandatory : Boolean := False;
1356 Error_On_Unknown_Language : Boolean := True) return Processing_Flags;
1357 -- Function used to create Processing_Flags structure
1359 -- If Allow_Duplicate_Basenames, then files with the same base names are
1360 -- authorized within a project for source-based languages (never for unit
1361 -- based languages).
1363 -- If Compiler_Driver_Mandatory is true, then a Compiler.Driver attribute
1364 -- for each language must be defined, or we will not look for its source
1367 -- When_No_Sources indicates what should be done when no sources of a
1368 -- language are found in a project where this language is declared.
1369 -- If Require_Sources_Other_Lang is true, then all languages must have at
1370 -- least one source file, or an error is reported via When_No_Sources. If
1371 -- it is false, this is only required for Ada (and only if it is a language
1374 -- If Report_Error is null, use the standard error reporting mechanism
1375 -- (Errout). Otherwise, report errors using Report_Error.
1377 -- If Error_On_Unknown_Language is true, an error is displayed if some of
1378 -- the source files listed in the project do not match any naming scheme
1380 Gprbuild_Flags : constant Processing_Flags;
1381 Gnatmake_Flags : constant Processing_Flags;
1382 -- Flags used by the various tools. They all display the error messages
1385 package Project_Boolean_Htable is new Simple_HTable
1386 (Header_Num => Header_Num,
1388 No_Element => False,
1392 -- A table that associates a project to a boolean. This is used to detect
1393 -- whether a project was already processed for instance.
1396 type State is limited private;
1397 with procedure Action
1398 (Project : Project_Id;
1399 With_State : in out State);
1400 procedure For_Every_Project_Imported
1402 With_State : in out State;
1403 Imported_First : Boolean := False);
1404 -- Call Action for each project imported directly or indirectly by project
1405 -- By, as well as extended projects.
1406 -- The order of processing depends on Imported_First:
1407 -- If False, Action is called according to the order of importation: if A
1408 -- imports B, directly or indirectly, Action will be called for A before
1409 -- it is called for B. If two projects import each other directly or
1410 -- indirectly (using at least one "limited with"), it is not specified
1411 -- for which of these two projects Action will be called first.
1412 -- The order is reversed if Imported_First is True.
1413 -- With_State may be used by Action to choose a behavior or to report some
1416 function Extend_Name
1417 (File : File_Name_Type;
1418 With_Suffix : String) return File_Name_Type;
1419 -- Replace the extension of File with With_Suffix
1421 function Object_Name
1422 (Source_File_Name : File_Name_Type;
1423 Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
1424 -- Returns the object file name corresponding to a source file name
1426 function Dependency_Name
1427 (Source_File_Name : File_Name_Type;
1428 Dependency : Dependency_File_Kind) return File_Name_Type;
1429 -- Returns the dependency file name corresponding to a source file name
1431 function Switches_Name
1432 (Source_File_Name : File_Name_Type) return File_Name_Type;
1433 -- Returns the switches file name corresponding to a source file name
1439 procedure Record_Temp_File (Path : Path_Name_Type);
1440 -- Record the path of a newly created temporary file, so that it can be
1443 procedure Delete_All_Temp_Files;
1444 -- Delete all recorded temporary files
1448 All_Packages : constant String_List_Access := null;
1450 No_Project_Tree : constant Project_Tree_Ref := null;
1452 Ignored : constant Variable_Kind := Single;
1454 Nil_Variable_Value : constant Variable_Value :=
1455 (Project => No_Project,
1457 Location => No_Location,
1460 Virtual_Prefix : constant String := "v$";
1461 -- The prefix for virtual extending projects. Because of the '$', which is
1462 -- normally forbidden for project names, there cannot be any name clash.
1464 Empty_Name : Name_Id;
1465 -- Name_Id for an empty name (no characters). Initialized in procedure
1468 Empty_File_Name : File_Name_Type;
1469 -- Empty File_Name_Type (no characters). Initialized in procedure
1472 type Source_Iterator is record
1473 In_Tree : Project_Tree_Ref;
1475 Project : Project_List;
1476 All_Projects : Boolean;
1477 -- Current project and whether we should move on to the next
1479 Language : Language_Ptr;
1480 -- Current language processed
1482 Language_Name : Name_Id;
1483 -- Only sources of this language will be returned (or all if No_Name)
1485 Current : Source_Id;
1488 procedure Add_To_Buffer
1490 To : in out String_Access;
1491 Last : in out Natural);
1492 -- Append a String to the Buffer
1494 package Path_File_Table is new GNAT.Dynamic_Tables
1495 (Table_Component_Type => Path_Name_Type,
1496 Table_Index_Type => Natural,
1497 Table_Low_Bound => 1,
1498 Table_Initial => 50,
1499 Table_Increment => 100);
1500 -- Table storing all the temp path file names.
1501 -- Used by Delete_All_Path_Files.
1503 package Source_Path_Table is new GNAT.Dynamic_Tables
1504 (Table_Component_Type => Name_Id,
1505 Table_Index_Type => Natural,
1506 Table_Low_Bound => 1,
1507 Table_Initial => 50,
1508 Table_Increment => 100);
1509 -- A table to store the source dirs before creating the source path file
1511 package Object_Path_Table is new GNAT.Dynamic_Tables
1512 (Table_Component_Type => Path_Name_Type,
1513 Table_Index_Type => Natural,
1514 Table_Low_Bound => 1,
1515 Table_Initial => 50,
1516 Table_Increment => 100);
1517 -- A table to store the object dirs, before creating the object path file
1519 type Private_Project_Tree_Data is record
1520 Path_Files : Path_File_Table.Instance;
1521 Source_Paths : Source_Path_Table.Instance;
1522 Object_Paths : Object_Path_Table.Instance;
1524 Current_Source_Path_File : Path_Name_Type := No_Path;
1525 -- Current value of project source path file env var. Used to avoid
1526 -- setting the env var to the same value.
1529 Current_Object_Path_File : Path_Name_Type := No_Path;
1530 -- Current value of project object path file env var. Used to avoid
1531 -- setting the env var to the same value.
1534 Ada_Path_Buffer : String_Access := new String (1 .. 1024);
1535 -- A buffer where values for ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are
1539 Ada_Path_Length : Natural := 0;
1540 -- Index of the last valid character in Ada_Path_Buffer
1543 Ada_Prj_Include_File_Set : Boolean := False;
1544 Ada_Prj_Objects_File_Set : Boolean := False;
1545 -- These flags are set to True when the corresponding environment
1546 -- variables are set and are used to give these environment variables an
1547 -- empty string value at the end of the program. This has no practical
1548 -- effect on most platforms, except on VMS where the logical names are
1549 -- deassigned, thus avoiding the pollution of the environment of the
1553 Fill_Mapping_File : Boolean := True;
1557 -- Type to represent the part of a project tree which is private to the
1560 type Processing_Flags is record
1561 Require_Sources_Other_Lang : Boolean;
1562 Report_Error : Put_Line_Access;
1563 When_No_Sources : Error_Warning;
1564 Allow_Duplicate_Basenames : Boolean;
1565 Compiler_Driver_Mandatory : Boolean;
1566 Error_On_Unknown_Language : Boolean;
1569 Gprbuild_Flags : constant Processing_Flags :=
1570 (Report_Error => null,
1571 When_No_Sources => Warning,
1572 Require_Sources_Other_Lang => True,
1573 Allow_Duplicate_Basenames => False,
1574 Compiler_Driver_Mandatory => True,
1575 Error_On_Unknown_Language => True);
1577 Gnatmake_Flags : constant Processing_Flags :=
1578 (Report_Error => null,
1579 When_No_Sources => Error,
1580 Require_Sources_Other_Lang => False,
1581 Allow_Duplicate_Basenames => False,
1582 Compiler_Driver_Mandatory => False,
1583 Error_On_Unknown_Language => False);