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 Project_Qualifier is
70 -- Qualifiers that can prefix the reserved word "project" in a project
72 -- Standard: standard project ...
73 -- Library: library project is ...
74 -- Dry: abstract project is
75 -- Aggregate: aggregate project is
76 -- Aggregate_Library: aggregate library project is ...
77 -- Configuration: configuration project is ...
79 All_Packages : constant String_List_Access;
80 -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
81 -- Prj.Part, indicating that all packages should be checked.
83 type Project_Tree_Data;
84 type Project_Tree_Ref is access all Project_Tree_Data;
85 -- Reference to a project tree. Several project trees may exist in memory
88 No_Project_Tree : constant Project_Tree_Ref;
90 procedure Free (Tree : in out Project_Tree_Ref);
91 -- Free memory associated with the tree
93 Config_Project_File_Extension : String := ".cgpr";
94 Project_File_Extension : String := ".gpr";
95 -- The standard config and user project file name extensions. They are not
96 -- constants, because Canonical_Case_File_Name is called on these variables
97 -- in the body of Prj.
99 function Empty_File return File_Name_Type;
100 function Empty_String return Name_Id;
101 -- Return the id for an empty string ""
103 type Path_Information is record
104 Name : Path_Name_Type := No_Path;
105 Display_Name : Path_Name_Type := No_Path;
107 -- Directory names always end with a directory separator
109 No_Path_Information : constant Path_Information := (No_Path, No_Path);
112 type Project_Id is access all Project_Data;
113 No_Project : constant Project_Id := null;
114 -- Id of a Project File
116 type String_List_Id is new Nat;
117 Nil_String : constant String_List_Id := 0;
118 type String_Element is record
119 Value : Name_Id := No_Name;
121 Display_Value : Name_Id := No_Name;
122 Location : Source_Ptr := No_Location;
123 Flag : Boolean := False;
124 Next : String_List_Id := Nil_String;
126 -- To hold values for string list variables and array elements.
127 -- Component Flag may be used for various purposes. For source
128 -- directories, it indicates if the directory contains Ada source(s).
130 package String_Element_Table is new GNAT.Dynamic_Tables
131 (Table_Component_Type => String_Element,
132 Table_Index_Type => String_List_Id,
133 Table_Low_Bound => 1,
134 Table_Initial => 200,
135 Table_Increment => 100);
136 -- The table for string elements in string lists
138 type Variable_Kind is (Undefined, List, Single);
139 -- Different kinds of variables
141 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
142 -- The defined kinds of variables
144 Ignored : constant Variable_Kind;
145 -- Used to indicate that a package declaration must be ignored
146 -- while processing the project tree (unknown package name).
148 type Variable_Value (Kind : Variable_Kind := Undefined) is record
149 Project : Project_Id := No_Project;
150 Location : Source_Ptr := No_Location;
151 Default : Boolean := False;
156 Values : String_List_Id := Nil_String;
158 Value : Name_Id := No_Name;
162 -- Values for variables and array elements. Default is True if the
163 -- current value is the default one for the variable.
165 Nil_Variable_Value : constant Variable_Value;
166 -- Value of a non existing variable or array element
168 type Variable_Id is new Nat;
169 No_Variable : constant Variable_Id := 0;
170 type Variable is record
171 Next : Variable_Id := No_Variable;
173 Value : Variable_Value;
175 -- To hold the list of variables in a project file and in packages
177 package Variable_Element_Table is new GNAT.Dynamic_Tables
178 (Table_Component_Type => Variable,
179 Table_Index_Type => Variable_Id,
180 Table_Low_Bound => 1,
181 Table_Initial => 200,
182 Table_Increment => 100);
183 -- The table of variable in list of variables
185 type Array_Element_Id is new Nat;
186 No_Array_Element : constant Array_Element_Id := 0;
187 type Array_Element is record
189 Src_Index : Int := 0;
190 Index_Case_Sensitive : Boolean := True;
191 Value : Variable_Value;
192 Next : Array_Element_Id := No_Array_Element;
194 -- Each Array_Element represents an array element and is linked (Next)
195 -- to the next array element, if any, in the array.
197 package Array_Element_Table is new GNAT.Dynamic_Tables
198 (Table_Component_Type => Array_Element,
199 Table_Index_Type => Array_Element_Id,
200 Table_Low_Bound => 1,
201 Table_Initial => 200,
202 Table_Increment => 100);
203 -- The table that contains all array elements
205 type Array_Id is new Nat;
206 No_Array : constant Array_Id := 0;
207 type Array_Data is record
208 Name : Name_Id := No_Name;
209 Location : Source_Ptr := No_Location;
210 Value : Array_Element_Id := No_Array_Element;
211 Next : Array_Id := No_Array;
213 -- Each Array_Data value represents an array.
214 -- Value is the id of the first element.
215 -- Next is the id of the next array in the project file or package.
217 package Array_Table is new GNAT.Dynamic_Tables
218 (Table_Component_Type => Array_Data,
219 Table_Index_Type => Array_Id,
220 Table_Low_Bound => 1,
221 Table_Initial => 200,
222 Table_Increment => 100);
223 -- The table that contains all arrays
225 type Package_Id is new Nat;
226 No_Package : constant Package_Id := 0;
227 type Declarations is record
228 Variables : Variable_Id := No_Variable;
229 Attributes : Variable_Id := No_Variable;
230 Arrays : Array_Id := No_Array;
231 Packages : Package_Id := No_Package;
233 -- Contains the declarations (variables, single and array attributes,
234 -- packages) for a project or a package in a project.
236 No_Declarations : constant Declarations :=
237 (Variables => No_Variable,
238 Attributes => No_Variable,
240 Packages => No_Package);
241 -- Default value of Declarations: indicates that there is no declarations
243 type Package_Element is record
244 Name : Name_Id := No_Name;
245 Decl : Declarations := No_Declarations;
246 Parent : Package_Id := No_Package;
247 Next : Package_Id := No_Package;
249 -- A package (includes declarations that may include other packages)
251 package Package_Table is new GNAT.Dynamic_Tables
252 (Table_Component_Type => Package_Element,
253 Table_Index_Type => Package_Id,
254 Table_Low_Bound => 1,
255 Table_Initial => 100,
256 Table_Increment => 100);
257 -- The table that contains all packages
260 type Language_Ptr is access all Language_Data;
261 -- Index of language data
263 No_Language_Index : constant Language_Ptr := null;
264 -- Constant indicating that there is no language data
266 function Get_Language_From_Name
267 (Project : Project_Id;
268 Name : String) return Language_Ptr;
269 -- Get a language from a project. This might return null if no such
270 -- language exists in the project
272 Max_Header_Num : constant := 6150;
273 type Header_Num is range 0 .. Max_Header_Num;
274 -- Size for hash table below. The upper bound is an arbitrary value, the
275 -- value here was chosen after testing to determine a good compromise
276 -- between speed of access and memory usage.
278 function Hash (Name : Name_Id) return Header_Num;
279 function Hash (Name : File_Name_Type) return Header_Num;
280 function Hash (Name : Path_Name_Type) return Header_Num;
281 function Hash (Project : Project_Id) return Header_Num;
282 -- Used for computing hash values for names put into hash tables
284 type Language_Kind is (File_Based, Unit_Based);
285 -- Type for the kind of language. All languages are file based, except Ada
286 -- which is unit based.
288 type Dependency_File_Kind is (None, Makefile, ALI_File);
289 -- Type of dependency to be checked: no dependency file, Makefile fragment
290 -- or ALI file (for Ada).
292 Makefile_Dependency_Suffix : constant String := ".d";
293 ALI_Dependency_Suffix : constant String := ".ali";
295 Switches_Dependency_Suffix : constant String := ".cswi";
297 Binder_Exchange_Suffix : constant String := ".bexch";
298 -- Suffix for binder exchange files
300 Library_Exchange_Suffix : constant String := ".lexch";
301 -- Suffix for library exchange files
303 type Name_List_Index is new Nat;
304 No_Name_List : constant Name_List_Index := 0;
306 type Name_Node is record
307 Name : Name_Id := No_Name;
308 Next : Name_List_Index := No_Name_List;
311 package Name_List_Table is new GNAT.Dynamic_Tables
312 (Table_Component_Type => Name_Node,
313 Table_Index_Type => Name_List_Index,
314 Table_Low_Bound => 1,
316 Table_Increment => 100);
317 -- The table for lists of names
320 (Table : Name_List_Table.Instance;
321 List : Name_List_Index) return Natural;
322 -- Return the number of elements in specified list
324 type Number_List_Index is new Nat;
325 No_Number_List : constant Number_List_Index := 0;
327 type Number_Node is record
328 Number : Natural := 0;
329 Next : Number_List_Index := No_Number_List;
332 package Number_List_Table is new GNAT.Dynamic_Tables
333 (Table_Component_Type => Number_Node,
334 Table_Index_Type => Number_List_Index,
335 Table_Low_Bound => 1,
337 Table_Increment => 100);
338 -- The table for lists of numbers
340 package Mapping_Files_Htable is new Simple_HTable
341 (Header_Num => Header_Num,
342 Element => Path_Name_Type,
343 No_Element => No_Path,
344 Key => Path_Name_Type,
347 -- A hash table to store the mapping files that are not used
349 type Lang_Naming_Data is record
350 Dot_Replacement : File_Name_Type := No_File;
351 -- The string to replace '.' in the source file name (for Ada)
353 Casing : Casing_Type := All_Lower_Case;
354 -- The casing of the source file name (for Ada)
356 Separate_Suffix : File_Name_Type := No_File;
357 -- String to append to unit name for source file name of an Ada subunit
359 Spec_Suffix : File_Name_Type := No_File;
360 -- The string to append to the unit name for the
361 -- source file name of a spec.
363 Body_Suffix : File_Name_Type := No_File;
364 -- The string to append to the unit name for the
365 -- source file name of a body.
368 No_Lang_Naming_Data : constant Lang_Naming_Data :=
369 (Dot_Replacement => No_File,
370 Casing => All_Lower_Case,
371 Separate_Suffix => No_File,
372 Spec_Suffix => No_File,
373 Body_Suffix => No_File);
375 function Is_Standard_GNAT_Naming (Naming : Lang_Naming_Data) return Boolean;
376 -- True if the naming scheme is GNAT's default naming scheme. This
377 -- is to take into account shortened names like "Ada." (a-), "System." (s-)
381 type Source_Id is access all Source_Data;
383 function Is_Compilable (Source : Source_Id) return Boolean;
384 pragma Inline (Is_Compilable);
385 -- Return True if we know how to compile Source (i.e. if a compiler is
386 -- defined). This doesn't indicate whether the source should be compiled.
388 function Object_To_Global_Archive (Source : Source_Id) return Boolean;
389 pragma Inline (Object_To_Global_Archive);
390 -- Return True if the object file should be put in the global archive.
391 -- This is for Ada, when only the closure of a main needs to be
394 function Other_Part (Source : Source_Id) return Source_Id;
395 pragma Inline (Other_Part);
396 -- Source ID for the other part, if any: for a spec, indicates its body;
397 -- for a body, indicates its spec.
399 No_Source : constant Source_Id := null;
401 type Path_Syntax_Kind is
406 -- Host specific syntax, for example on VMS (the default)
408 type Language_Config is record
409 Kind : Language_Kind := File_Based;
410 -- Kind of language. All languages are file based, except Ada which is
413 Naming_Data : Lang_Naming_Data;
414 -- The naming data for the languages (prefixes, etc.)
416 Include_Compatible_Languages : Name_List_Index := No_Name_List;
417 -- The list of languages that are "include compatible" with this
418 -- language. A language B (for example "C") is "include compatible" with
419 -- a language A (for example "C++") if it is expected that sources of
420 -- language A may "include" header files from language B.
422 Compiler_Driver : File_Name_Type := No_File;
423 -- The name of the executable for the compiler of the language
425 Compiler_Driver_Path : String_Access := null;
426 -- The path name of the executable for the compiler of the language
428 Compiler_Leading_Required_Switches : Name_List_Index := No_Name_List;
429 -- The list of initial switches that are required as a minimum to invoke
430 -- the compiler driver.
432 Compiler_Trailing_Required_Switches : Name_List_Index := No_Name_List;
433 -- The list of final switches that are required as a minimum to invoke
434 -- the compiler driver.
436 Multi_Unit_Switches : Name_List_Index := No_Name_List;
437 -- The switch(es) to indicate the index of a unit in a multi-source
440 Multi_Unit_Object_Separator : Character := ' ';
441 -- The string separating the base name of a source from the index of
442 -- the unit in a multi-source file, in the object file name.
444 Path_Syntax : Path_Syntax_Kind := Host;
445 -- Value may be Canonical (Unix style) or Host (host syntax, for example
446 -- on VMS for DEC C).
448 Object_File_Suffix : Name_Id := No_Name;
449 -- Optional alternate object file suffix
451 Object_File_Switches : Name_List_Index := No_Name_List;
452 -- Optional object file switches. When this is defined, the switches
453 -- are used to specify the object file. The object file name is appended
454 -- to the last switch in the list. Example: ("-o", "").
456 Compilation_PIC_Option : Name_List_Index := No_Name_List;
457 -- The option(s) to compile a source in Position Independent Code for
458 -- shared libraries. Specified in the configuration. When not specified,
459 -- there is no need for such switch.
461 Object_Generated : Boolean := True;
462 -- False in no object file is generated
464 Objects_Linked : Boolean := True;
465 -- False if object files are not use to link executables and build
468 Runtime_Library_Dir : Name_Id := No_Name;
469 -- Path name of the runtime library directory, if any
471 Runtime_Source_Dir : Name_Id := No_Name;
472 -- Path name of the runtime source directory, if any
474 Mapping_File_Switches : Name_List_Index := No_Name_List;
475 -- The option(s) to provide a mapping file to the compiler. Specified in
476 -- the configuration. When value is No_Name_List, there is no mapping
479 Mapping_Spec_Suffix : File_Name_Type := No_File;
480 -- Placeholder representing the spec suffix in a mapping file
482 Mapping_Body_Suffix : File_Name_Type := No_File;
483 -- Placeholder representing the body suffix in a mapping file
485 Config_File_Switches : Name_List_Index := No_Name_List;
486 -- The option(s) to provide a config file to the compiler. Specified in
487 -- the configuration. When value is No_Name_List, there is no config
490 Dependency_Kind : Dependency_File_Kind := None;
491 -- The kind of dependency to be checked: none, Makefile fragment or
492 -- ALI file (for Ada).
494 Dependency_Option : Name_List_Index := No_Name_List;
495 -- The option(s) to be used to create the dependency file. When value is
496 -- No_Name_List, there is not such option(s).
498 Compute_Dependency : Name_List_Index := No_Name_List;
499 -- Hold the value of attribute Dependency_Driver, if declared for the
502 Include_Option : Name_List_Index := No_Name_List;
503 -- Hold the value of attribute Include_Switches, if declared for the
506 Include_Path : Name_Id := No_Name;
507 -- Name of environment variable declared by attribute Include_Path for
510 Include_Path_File : Name_Id := No_Name;
511 -- Name of environment variable declared by attribute Include_Path_File
514 Objects_Path : Name_Id := No_Name;
515 -- Name of environment variable declared by attribute Objects_Path for
518 Objects_Path_File : Name_Id := No_Name;
519 -- Name of environment variable declared by attribute Objects_Path_File
522 Config_Body : Name_Id := No_Name;
523 -- The template for a pragma Source_File_Name(_Project) for a specific
524 -- file name of a body.
526 Config_Body_Index : Name_Id := No_Name;
527 -- The template for a pragma Source_File_Name(_Project) for a specific
528 -- file name of a body in a multi-source file.
530 Config_Body_Pattern : Name_Id := No_Name;
531 -- The template for a pragma Source_File_Name(_Project) for a naming
534 Config_Spec : Name_Id := No_Name;
535 -- The template for a pragma Source_File_Name(_Project) for a specific
536 -- file name of a spec.
538 Config_Spec_Index : Name_Id := No_Name;
539 -- The template for a pragma Source_File_Name(_Project) for a specific
540 -- file name of a spec in a multi-source file.
542 Config_Spec_Pattern : Name_Id := No_Name;
543 -- The template for a pragma Source_File_Name(_Project) for a naming
546 Config_File_Unique : Boolean := False;
547 -- Indicate if the config file specified to the compiler needs to be
548 -- unique. If it is unique, then all config files are concatenated into
549 -- a temp config file.
551 Binder_Driver : File_Name_Type := No_File;
552 -- The name of the binder driver for the language, if any
554 Binder_Driver_Path : Path_Name_Type := No_Path;
555 -- The path name of the binder driver
557 Binder_Required_Switches : Name_List_Index := No_Name_List;
558 -- Hold the value of attribute Binder'Required_Switches for the language
560 Binder_Prefix : Name_Id := No_Name;
561 -- Hold the value of attribute Binder'Prefix for the language
563 Toolchain_Version : Name_Id := No_Name;
564 -- Hold the value of attribute Toolchain_Version for the language
566 Toolchain_Description : Name_Id := No_Name;
567 -- Hold the value of attribute Toolchain_Description for the language
570 -- Record describing the configuration of a language
572 No_Language_Config : constant Language_Config :=
574 Naming_Data => No_Lang_Naming_Data,
575 Include_Compatible_Languages => No_Name_List,
576 Compiler_Driver => No_File,
577 Compiler_Driver_Path => null,
578 Compiler_Leading_Required_Switches => No_Name_List,
579 Compiler_Trailing_Required_Switches => No_Name_List,
580 Multi_Unit_Switches => No_Name_List,
581 Multi_Unit_Object_Separator => ' ',
582 Path_Syntax => Canonical,
583 Object_File_Suffix => No_Name,
584 Object_File_Switches => No_Name_List,
585 Compilation_PIC_Option => No_Name_List,
586 Object_Generated => True,
587 Objects_Linked => True,
588 Runtime_Library_Dir => No_Name,
589 Runtime_Source_Dir => No_Name,
590 Mapping_File_Switches => No_Name_List,
591 Mapping_Spec_Suffix => No_File,
592 Mapping_Body_Suffix => No_File,
593 Config_File_Switches => No_Name_List,
594 Dependency_Kind => None,
595 Dependency_Option => No_Name_List,
596 Compute_Dependency => No_Name_List,
597 Include_Option => No_Name_List,
598 Include_Path => No_Name,
599 Include_Path_File => No_Name,
600 Objects_Path => No_Name,
601 Objects_Path_File => No_Name,
602 Config_Body => No_Name,
603 Config_Body_Index => No_Name,
604 Config_Body_Pattern => No_Name,
605 Config_Spec => No_Name,
606 Config_Spec_Index => No_Name,
607 Config_Spec_Pattern => No_Name,
608 Config_File_Unique => False,
609 Binder_Driver => No_File,
610 Binder_Driver_Path => No_Path,
611 Binder_Required_Switches => No_Name_List,
612 Binder_Prefix => No_Name,
613 Toolchain_Version => No_Name,
614 Toolchain_Description => No_Name);
616 type Language_Data is record
617 Name : Name_Id := No_Name;
618 Display_Name : Name_Id := No_Name;
619 Config : Language_Config := No_Language_Config;
620 First_Source : Source_Id := No_Source;
621 Mapping_Files : Mapping_Files_Htable.Instance :=
622 Mapping_Files_Htable.Nil;
623 Next : Language_Ptr := No_Language_Index;
626 No_Language_Data : constant Language_Data :=
628 Display_Name => No_Name,
629 Config => No_Language_Config,
630 First_Source => No_Source,
631 Mapping_Files => Mapping_Files_Htable.Nil,
632 Next => No_Language_Index);
634 type Language_List_Element;
635 type Language_List is access all Language_List_Element;
636 type Language_List_Element is record
637 Language : Language_Ptr := No_Language_Index;
638 Next : Language_List;
641 type Source_Kind is (Spec, Impl, Sep);
642 subtype Spec_Or_Body is Source_Kind range Spec .. Impl;
644 -- The following declarations declare a structure used to store the Name
645 -- and File and Path names of a unit, with a reference to its GNAT Project
646 -- File(s). Some units might have neither Spec nor Impl when they were
647 -- created for a "separate".
649 type File_Names_Data is array (Spec_Or_Body) of Source_Id;
651 type Unit_Data is record
652 Name : Name_Id := No_Name;
653 File_Names : File_Names_Data;
656 type Unit_Index is access all Unit_Data;
658 No_Unit_Index : constant Unit_Index := null;
659 -- Used to indicate a null entry for no unit
661 -- Structure to define source data
663 type Source_Data is record
664 Project : Project_Id := No_Project;
665 -- Project of the source
667 Source_Dir_Rank : Natural := 0;
668 -- The rank of the source directory in list declared with attribute
669 -- Source_Dirs. Two source files with the same name cannot appears in
670 -- different directory with the same rank. That can happen when the
671 -- recursive notation <dir>/** is used in attribute Source_Dirs.
673 Language : Language_Ptr := No_Language_Index;
674 -- Index of the language. This is an index into
675 -- Project_Tree.Languages_Data.
677 In_Interfaces : Boolean := True;
678 -- False when the source is not included in interfaces, when attribute
679 -- Interfaces is declared.
681 Declared_In_Interfaces : Boolean := False;
682 -- True when source is declared in attribute Interfaces
684 Alternate_Languages : Language_List := null;
685 -- List of languages a header file may also be, in addition of language
688 Kind : Source_Kind := Spec;
689 -- Kind of the source: spec, body or subunit
691 Unit : Unit_Index := No_Unit_Index;
692 -- Name of the unit, if language is unit based. This is only set for
693 -- those files that are part of the compilation set (for instance a
694 -- file in an extended project that is overridden will not have this
698 -- Index of the source in a multi unit source file (the same Source_Data
699 -- is duplicated several times when there are several units in the same
700 -- file). Index is 0 if there is either no unit or a single one, and
701 -- starts at 1 when there are multiple units
703 Locally_Removed : Boolean := False;
704 -- True if the source has been "excluded"
706 Replaced_By : Source_Id := No_Source;
708 File : File_Name_Type := No_File;
709 -- Canonical file name of the source
711 Display_File : File_Name_Type := No_File;
712 -- File name of the source, for display purposes
714 Path : Path_Information := No_Path_Information;
715 -- Path name of the source
717 Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
718 -- Time stamp of the source file
720 Object_Project : Project_Id := No_Project;
721 -- Project where the object file is. This might be different from
722 -- Project when using extending project files.
724 Object : File_Name_Type := No_File;
725 -- File name of the object file
727 Current_Object_Path : Path_Name_Type := No_Path;
728 -- Object path of an existing object file
730 Object_Path : Path_Name_Type := No_Path;
731 -- Object path of the real object file
733 Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
734 -- Object file time stamp
736 Dep_Name : File_Name_Type := No_File;
737 -- Dependency file simple name
739 Current_Dep_Path : Path_Name_Type := No_Path;
740 -- Path name of an existing dependency file
742 Dep_Path : Path_Name_Type := No_Path;
743 -- Path name of the real dependency file
745 Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
746 -- Dependency file time stamp
748 Switches : File_Name_Type := No_File;
749 -- File name of the switches file. For all languages, this is a file
750 -- that ends with the .cswi extension.
752 Switches_Path : Path_Name_Type := No_Path;
753 -- Path name of the switches file
755 Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
756 -- Switches file time stamp
758 Naming_Exception : Boolean := False;
759 -- True if the source has an exceptional name
761 Next_In_Lang : Source_Id := No_Source;
762 -- Link to another source of the same language in the same project
765 No_Source_Data : constant Source_Data :=
766 (Project => No_Project,
767 Source_Dir_Rank => 0,
768 Language => No_Language_Index,
769 In_Interfaces => True,
770 Declared_In_Interfaces => False,
771 Alternate_Languages => null,
773 Unit => No_Unit_Index,
775 Locally_Removed => False,
776 Replaced_By => No_Source,
778 Display_File => No_File,
779 Path => No_Path_Information,
780 Source_TS => Empty_Time_Stamp,
781 Object_Project => No_Project,
783 Current_Object_Path => No_Path,
784 Object_Path => No_Path,
785 Object_TS => Empty_Time_Stamp,
787 Current_Dep_Path => No_Path,
789 Dep_TS => Empty_Time_Stamp,
791 Switches_Path => No_Path,
792 Switches_TS => Empty_Time_Stamp,
793 Naming_Exception => False,
794 Next_In_Lang => No_Source);
796 package Source_Paths_Htable is new Simple_HTable
797 (Header_Num => Header_Num,
798 Element => Source_Id,
799 No_Element => No_Source,
800 Key => Path_Name_Type,
803 -- Mapping of source paths to source ids
805 package Unit_Sources_Htable is new Simple_HTable
806 (Header_Num => Header_Num,
807 Element => Source_Id,
808 No_Element => No_Source,
813 type Verbosity is (Default, Medium, High);
814 -- Verbosity when parsing GNAT Project Files
815 -- Default is default (very quiet, if no errors).
816 -- Medium is more verbose.
817 -- High is extremely verbose.
819 Current_Verbosity : Verbosity := Default;
820 -- The current value of the verbosity the project files are parsed with
822 type Lib_Kind is (Static, Dynamic, Relocatable);
824 type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
825 -- Type to specify the symbol policy, when symbol control is supported.
826 -- See full explanation about this type in package Symbols.
827 -- Autonomous: Create a symbol file without considering any reference
828 -- Compliant: Try to be as compatible as possible with an existing ref
829 -- Controlled: Fail if symbols are not the same as those in the reference
830 -- Restricted: Restrict the symbols to those in the symbol file
831 -- Direct: The symbol file is used as is
833 type Symbol_Record is record
834 Symbol_File : Path_Name_Type := No_Path;
835 Reference : Path_Name_Type := No_Path;
836 Symbol_Policy : Policy := Autonomous;
838 -- Type to keep the symbol data to be used when building a shared library
840 No_Symbols : constant Symbol_Record :=
841 (Symbol_File => No_Path,
842 Reference => No_Path,
843 Symbol_Policy => Autonomous);
844 -- The default value of the symbol data
846 function Image (The_Casing : Casing_Type) return String;
847 -- Similar to 'Image (but avoid use of this attribute in compiler)
849 function Value (Image : String) return Casing_Type;
850 -- Similar to 'Value (but avoid use of this attribute in compiler)
851 -- Raises Constraint_Error if not a Casing_Type image.
853 -- The following record contains data for a naming scheme
855 function Get_Object_Directory
856 (Project : Project_Id;
857 Including_Libraries : Boolean;
858 Only_If_Ada : Boolean := False) return Path_Name_Type;
859 -- Return the object directory to use for the project. This depends on
860 -- whether we have a library project or a standard project. This function
861 -- might return No_Name when no directory applies.
862 -- If we have a a library project file and Including_Libraries is True then
863 -- the library dir is returned instead of the object dir.
864 -- If Only_If_Ada is True, then No_Name will be returned when the project
865 -- doesn't Ada sources.
867 procedure Compute_All_Imported_Projects (Tree : Project_Tree_Ref);
868 -- For all projects in the tree, compute the list of the projects imported
869 -- directly or indirectly by project Project. The result is stored in
870 -- Project.All_Imported_Projects for each project
872 function Ultimate_Extending_Project_Of
873 (Proj : Project_Id) return Project_Id;
874 -- Returns the ultimate extending project of project Proj. If project Proj
875 -- is not extended, returns Proj.
877 type Project_List_Element;
878 type Project_List is access all Project_List_Element;
879 type Project_List_Element is record
880 Project : Project_Id := No_Project;
881 Next : Project_List := null;
883 -- A list of projects
886 (List : in out Project_List;
887 Free_Project : Boolean);
888 -- Free the list of projects, if Free_Project, each project is also freed
890 type Response_File_Format is
895 -- The format of the different response files
897 type Project_Configuration is record
898 Target : Name_Id := No_Name;
899 -- The target of the configuration, when specified
901 Run_Path_Option : Name_List_Index := No_Name_List;
902 -- The option to use when linking to specify the path where to look for
905 Separate_Run_Path_Options : Boolean := False;
906 -- True if each directory needs to be specified in a separate run path
909 Executable_Suffix : Name_Id := No_Name;
910 -- The suffix of executables, when specified in the configuration or in
911 -- package Builder of the main project. When this is not specified, the
912 -- executable suffix is the default for the platform.
916 Linker : Path_Name_Type := No_Path;
917 -- Path name of the linker driver. Specified in the configuration or in
918 -- the package Builder of the main project.
920 Map_File_Option : Name_Id := No_Name;
921 -- Option to use when invoking the linker to build a map file
923 Minimum_Linker_Options : Name_List_Index := No_Name_List;
924 -- The minimum options for the linker driver. Specified in the
927 Linker_Executable_Option : Name_List_Index := No_Name_List;
928 -- The option(s) to indicate the name of the executable in the linker
929 -- command. Specified in the configuration. When not specified, default
930 -- to -o <executable name>.
932 Linker_Lib_Dir_Option : Name_Id := No_Name;
933 -- The option to specify where to find a library for linking. Specified
934 -- in the configuration. When not specified, defaults to "-L".
936 Linker_Lib_Name_Option : Name_Id := No_Name;
937 -- The option to specify the name of a library for linking. Specified in
938 -- the configuration. When not specified, defaults to "-l".
940 Max_Command_Line_Length : Natural := 0;
941 -- When positive and when Resp_File_Format (see below) is not None,
942 -- if the command line for the invocation of the linker would be greater
943 -- than this value, a response file is used to invoke the linker.
945 Resp_File_Format : Response_File_Format := None;
946 -- The format of a response file, when linking with a response file is
949 Resp_File_Options : Name_List_Index := No_Name_List;
950 -- The switches, if any, that precede the path name of the response
951 -- file in the invocation of the linker.
955 Library_Builder : Path_Name_Type := No_Path;
956 -- The executable to build library (specified in the configuration)
958 Lib_Support : Library_Support := None;
959 -- The level of library support. Specified in the configuration. Support
960 -- is none, static libraries only or both static and shared libraries.
962 Archive_Builder : Name_List_Index := No_Name_List;
963 -- The name of the executable to build archives, with the minimum
964 -- switches. Specified in the configuration.
966 Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
967 -- The options to append object files to an archive
969 Archive_Indexer : Name_List_Index := No_Name_List;
970 -- The name of the executable to index archives, with the minimum
971 -- switches. Specified in the configuration.
973 Archive_Suffix : File_Name_Type := No_File;
974 -- The suffix of archives. Specified in the configuration. When not
975 -- specified, defaults to ".a".
977 Lib_Partial_Linker : Name_List_Index := No_Name_List;
981 Shared_Lib_Driver : File_Name_Type := No_File;
982 -- The driver to link shared libraries. Set with attribute Library_GCC.
985 Shared_Lib_Prefix : File_Name_Type := No_File;
986 -- Part of a shared library file name that precedes the name of the
987 -- library. Specified in the configuration. When not specified, defaults
990 Shared_Lib_Suffix : File_Name_Type := No_File;
991 -- Suffix of shared libraries, after the library name in the shared
992 -- library name. Specified in the configuration. When not specified,
995 Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
996 -- The minimum options to use when building a shared library
998 Lib_Version_Options : Name_List_Index := No_Name_List;
999 -- The options to use to specify a library version
1001 Symbolic_Link_Supported : Boolean := False;
1002 -- True if the platform supports symbolic link files
1004 Lib_Maj_Min_Id_Supported : Boolean := False;
1005 -- True if platform supports library major and minor options, such as
1006 -- libname.so -> libname.so.2 -> libname.so.2.4
1008 Auto_Init_Supported : Boolean := False;
1009 -- True if automatic initialisation is supported for shared stand-alone
1013 Default_Project_Config : constant Project_Configuration :=
1015 Run_Path_Option => No_Name_List,
1016 Separate_Run_Path_Options => False,
1017 Executable_Suffix => No_Name,
1019 Map_File_Option => No_Name,
1020 Minimum_Linker_Options => No_Name_List,
1021 Linker_Executable_Option => No_Name_List,
1022 Linker_Lib_Dir_Option => No_Name,
1023 Linker_Lib_Name_Option => No_Name,
1024 Library_Builder => No_Path,
1025 Max_Command_Line_Length => 0,
1026 Resp_File_Format => None,
1027 Resp_File_Options => No_Name_List,
1028 Lib_Support => None,
1029 Archive_Builder => No_Name_List,
1030 Archive_Builder_Append_Option => No_Name_List,
1031 Archive_Indexer => No_Name_List,
1032 Archive_Suffix => No_File,
1033 Lib_Partial_Linker => No_Name_List,
1034 Shared_Lib_Driver => No_File,
1035 Shared_Lib_Prefix => No_File,
1036 Shared_Lib_Suffix => No_File,
1037 Shared_Lib_Min_Options => No_Name_List,
1038 Lib_Version_Options => No_Name_List,
1039 Symbolic_Link_Supported => False,
1040 Lib_Maj_Min_Id_Supported => False,
1041 Auto_Init_Supported => False);
1043 -- The following record describes a project file representation
1045 -- Note that it is not specified if the path names of directories (source,
1046 -- object, library or exec directories) end with or without a directory
1049 type Project_Data is record
1055 Name : Name_Id := No_Name;
1056 -- The name of the project
1058 Display_Name : Name_Id := No_Name;
1059 -- The name of the project with the spelling of its declaration
1061 Qualifier : Project_Qualifier := Unspecified;
1062 -- The eventual qualifier for this project
1064 Externally_Built : Boolean := False;
1065 -- True if the project is externally built. In such case, the Project
1066 -- Manager will not modify anything in this project.
1068 Config : Project_Configuration;
1070 Path : Path_Information := No_Path_Information;
1071 -- The path name of the project file. This include base name of the
1074 Virtual : Boolean := False;
1075 -- True for virtual extending projects
1077 Location : Source_Ptr := No_Location;
1078 -- The location in the project file source of the reserved word project
1084 Languages : Language_Ptr := No_Language_Index;
1085 -- First index of the language data in the project.
1086 -- This is an index into the project_tree_data.languages_data.
1087 -- Traversing the list gives access to all the languages supported by
1094 Mains : String_List_Id := Nil_String;
1095 -- List of mains specified by attribute Main
1097 Extends : Project_Id := No_Project;
1098 -- The reference of the project file, if any, that this project file
1101 Extended_By : Project_Id := No_Project;
1102 -- The reference of the project file, if any, that extends this project
1105 Decl : Declarations := No_Declarations;
1106 -- The declarations (variables, attributes and packages) of this project
1109 Imported_Projects : Project_List;
1110 -- The list of all directly imported projects, if any
1112 All_Imported_Projects : Project_List;
1113 -- The list of all projects imported directly or indirectly, if any.
1114 -- This does not include the project itself.
1120 Directory : Path_Information := No_Path_Information;
1121 -- Path name of the directory where the project file resides
1123 Object_Directory : Path_Information := No_Path_Information;
1124 -- The path name of the object directory of this project file
1126 Exec_Directory : Path_Information := No_Path_Information;
1127 -- The path name of the exec directory of this project file. Default is
1128 -- equal to Object_Directory.
1134 Library : Boolean := False;
1135 -- True if this is a library project
1137 Library_Name : Name_Id := No_Name;
1138 -- If a library project, name of the library
1140 Library_Kind : Lib_Kind := Static;
1141 -- If a library project, kind of library
1143 Library_Dir : Path_Information := No_Path_Information;
1144 -- If a library project, path name of the directory where the library
1147 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
1148 -- The timestamp of a library file in a library project
1150 Library_Src_Dir : Path_Information := No_Path_Information;
1151 -- If a Stand-Alone Library project, path name of the directory where
1152 -- the sources of the interfaces of the library are copied. By default,
1153 -- if attribute Library_Src_Dir is not specified, sources of the
1154 -- interfaces are not copied anywhere.
1156 Library_ALI_Dir : Path_Information := No_Path_Information;
1157 -- In a library project, path name of the directory where the ALI files
1158 -- are copied. If attribute Library_ALI_Dir is not specified, ALI files
1159 -- are copied in the Library_Dir.
1161 Lib_Internal_Name : Name_Id := No_Name;
1162 -- If a library project, internal name store inside the library
1164 Standalone_Library : Boolean := False;
1165 -- Indicate that this is a Standalone Library Project File
1167 Lib_Interface_ALIs : String_List_Id := Nil_String;
1168 -- For Standalone Library Project Files, indicate the list of Interface
1171 Lib_Auto_Init : Boolean := False;
1172 -- For non static Stand-Alone Library Project Files, indicate if
1173 -- the library initialisation should be automatic.
1175 Symbol_Data : Symbol_Record := No_Symbols;
1176 -- Symbol file name, reference symbol file name, symbol policy
1178 Need_To_Build_Lib : Boolean := False;
1179 -- Indicates that the library of a Library Project needs to be built or
1185 -- The sources for all languages including Ada are accessible through
1186 -- the Source_Iterator type
1188 Interfaces_Defined : Boolean := False;
1189 -- True if attribute Interfaces is declared for the project or any
1190 -- project it extends.
1192 Include_Path_File : Path_Name_Type := No_Path;
1193 -- The path name of the of the source search directory file.
1194 -- This is only used by gnatmake
1196 Source_Dirs : String_List_Id := Nil_String;
1197 -- The list of all the source directories
1199 Source_Dir_Ranks : Number_List_Index := No_Number_List;
1201 Ada_Include_Path : String_Access := null;
1202 -- The cached value of source search path for this project file. Set by
1203 -- the first call to Prj.Env.Ada_Include_Path for the project. Do not
1204 -- use this field directly outside of the project manager, use
1205 -- Prj.Env.Ada_Include_Path instead.
1211 Ada_Objects_Path : String_Access := null;
1212 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
1213 -- use this field directly outside of the compiler, use
1214 -- Prj.Env.Ada_Objects_Path instead.
1216 Libgnarl_Needed : Yes_No_Unknown := Unknown;
1217 -- Set to True when libgnarl is needed to link
1219 Objects_Path : String_Access := null;
1220 -- The cached value of the object dir path, used during the binding
1221 -- phase of gprbuild.
1223 Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
1224 -- The cached value of the object path temp file (including library
1225 -- dirs) for this project file.
1227 Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
1228 -- The cached value of the object path temp file (excluding library
1229 -- dirs) for this project file.
1231 Config_File_Name : Path_Name_Type := No_Path;
1232 -- The path name of the configuration pragmas file, if any
1234 Config_File_Temp : Boolean := False;
1235 -- An indication that the configuration pragmas file is a temporary file
1236 -- that must be deleted at the end.
1238 Config_Checked : Boolean := False;
1239 -- A flag to avoid checking repetitively the configuration pragmas file
1241 Depth : Natural := 0;
1242 -- The maximum depth of a project in the project graph. Depth of main
1245 Unkept_Comments : Boolean := False;
1246 -- True if there are comments in the project sources that cannot be kept
1247 -- in the project tree.
1251 function Empty_Project return Project_Data;
1252 -- Return the representation of an empty project
1254 function Is_Extending
1255 (Extending : Project_Id;
1256 Extended : Project_Id) return Boolean;
1257 -- Return True if Extending is extending the Extended project
1259 function Has_Ada_Sources (Data : Project_Id) return Boolean;
1260 -- Return True if the project has Ada sources
1262 Project_Error : exception;
1263 -- Raised by some subprograms in Prj.Attr
1265 package Units_Htable is new Simple_HTable
1266 (Header_Num => Header_Num,
1267 Element => Unit_Index,
1268 No_Element => No_Unit_Index,
1272 -- Mapping of unit names to indexes in the Units table
1274 ---------------------
1275 -- Source_Iterator --
1276 ---------------------
1278 type Source_Iterator is private;
1280 function For_Each_Source
1281 (In_Tree : Project_Tree_Ref;
1282 Project : Project_Id := No_Project;
1283 Language : Name_Id := No_Name) return Source_Iterator;
1284 -- Returns an iterator for all the sources of a project tree, or a specific
1285 -- project, or a specific language.
1287 function Element (Iter : Source_Iterator) return Source_Id;
1288 -- Return the current source (or No_Source if there are no more sources)
1290 procedure Next (Iter : in out Source_Iterator);
1291 -- Move on to the next source
1293 function Find_Source
1294 (In_Tree : Project_Tree_Ref;
1295 Project : Project_Id;
1296 In_Imported_Only : Boolean := False;
1297 In_Extended_Only : Boolean := False;
1298 Base_Name : File_Name_Type) return Source_Id;
1299 -- Find the first source file with the given name either in the whole tree
1300 -- (if In_Imported_Only is False) or in the projects imported or extended
1301 -- by Project otherwise. In_Extended_Only implies In_Imported_Only, and
1302 -- will only look in Project and the projects it extends
1304 -----------------------
1305 -- Project_Tree_Data --
1306 -----------------------
1308 type Private_Project_Tree_Data is private;
1309 -- Data for a project tree that is used only by the Project Manager
1311 type Project_Tree_Data is
1313 Name_Lists : Name_List_Table.Instance;
1314 Number_Lists : Number_List_Table.Instance;
1315 String_Elements : String_Element_Table.Instance;
1316 Variable_Elements : Variable_Element_Table.Instance;
1317 Array_Elements : Array_Element_Table.Instance;
1318 Arrays : Array_Table.Instance;
1319 Packages : Package_Table.Instance;
1320 Projects : Project_List;
1322 Units_HT : Units_Htable.Instance;
1323 -- Unit name to Unit_Index (and from there so Source_Id)
1325 Source_Paths_HT : Source_Paths_Htable.Instance;
1326 -- Full path to Source_Id
1328 Private_Part : Private_Project_Tree_Data;
1330 -- Data for a project tree
1332 procedure Expect (The_Token : Token_Type; Token_Image : String);
1333 -- Check that the current token is The_Token. If it is not, then output
1334 -- an error message.
1336 procedure Initialize (Tree : Project_Tree_Ref);
1337 -- This procedure must be called before using any services from the Prj
1338 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
1340 procedure Reset (Tree : Project_Tree_Ref);
1341 -- This procedure resets all the tables that are used when processing a
1342 -- project file tree. Initialize must be called before the call to Reset.
1344 package Project_Boolean_Htable is new Simple_HTable
1345 (Header_Num => Header_Num,
1347 No_Element => False,
1351 -- A table that associates a project to a boolean. This is used to detect
1352 -- whether a project was already processed for instance.
1355 type State is limited private;
1356 with procedure Action
1357 (Project : Project_Id;
1358 With_State : in out State);
1359 procedure For_Every_Project_Imported
1361 With_State : in out State;
1362 Imported_First : Boolean := False);
1363 -- Call Action for each project imported directly or indirectly by project
1364 -- By, as well as extended projects.
1365 -- The order of processing depends on Imported_First:
1366 -- If False, Action is called according to the order of importation: if A
1367 -- imports B, directly or indirectly, Action will be called for A before
1368 -- it is called for B. If two projects import each other directly or
1369 -- indirectly (using at least one "limited with"), it is not specified
1370 -- for which of these two projects Action will be called first.
1371 -- The order is reversed if Imported_First is True.
1372 -- With_State may be used by Action to choose a behavior or to report some
1375 function Extend_Name
1376 (File : File_Name_Type;
1377 With_Suffix : String) return File_Name_Type;
1378 -- Replace the extension of File with With_Suffix
1380 function Object_Name
1381 (Source_File_Name : File_Name_Type;
1382 Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
1383 -- Returns the object file name corresponding to a source file name
1385 function Object_Name
1386 (Source_File_Name : File_Name_Type;
1388 Index_Separator : Character;
1389 Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
1390 -- Returns the object file name corresponding to a unit in a multi-source
1393 function Dependency_Name
1394 (Source_File_Name : File_Name_Type;
1395 Dependency : Dependency_File_Kind) return File_Name_Type;
1396 -- Returns the dependency file name corresponding to a source file name
1398 function Switches_Name
1399 (Source_File_Name : File_Name_Type) return File_Name_Type;
1400 -- Returns the switches file name corresponding to a source file name
1406 type Processing_Flags is private;
1407 -- Flags used while parsing and processing a project tree to configure the
1408 -- behavior of the parser, and indicate how to report error messages. This
1409 -- structure does not allocate memory and never needs to be freed
1411 type Error_Warning is (Silent, Warning, Error);
1412 -- Severity of some situations, such as: no Ada sources in a project where
1413 -- Ada is one of the language.
1415 -- When the situation occurs, the behaviour depends on the setting:
1417 -- - Silent: no action
1418 -- - Warning: issue a warning, does not cause the tool to fail
1419 -- - Error: issue an error, causes the tool to fail
1421 type Error_Handler is access procedure
1422 (Project : Project_Id;
1423 Is_Warning : Boolean);
1424 -- This warngs when an error was found when parsing a project. The error
1425 -- itself is handled through Prj.Err (and Prj.Err.Finalize should be called
1426 -- to actually print the error). This ensures that duplicate error messages
1427 -- are always correctly removed, that errors msgs are sorted, and that all
1428 -- tools will report the same error to the user.
1430 function Create_Flags
1431 (Report_Error : Error_Handler;
1432 When_No_Sources : Error_Warning;
1433 Require_Sources_Other_Lang : Boolean := True;
1434 Allow_Duplicate_Basenames : Boolean := True;
1435 Compiler_Driver_Mandatory : Boolean := False;
1436 Error_On_Unknown_Language : Boolean := True;
1437 Require_Obj_Dirs : Error_Warning := Error)
1438 return Processing_Flags;
1439 -- Function used to create Processing_Flags structure
1441 -- If Allow_Duplicate_Basenames, then files with the same base names are
1442 -- authorized within a project for source-based languages (never for unit
1443 -- based languages).
1445 -- If Compiler_Driver_Mandatory is true, then a Compiler.Driver attribute
1446 -- for each language must be defined, or we will not look for its source
1449 -- When_No_Sources indicates what should be done when no sources of a
1450 -- language are found in a project where this language is declared.
1451 -- If Require_Sources_Other_Lang is true, then all languages must have at
1452 -- least one source file, or an error is reported via When_No_Sources. If
1453 -- it is false, this is only required for Ada (and only if it is a language
1454 -- of the project). When this parameter is set to False, we do not check
1455 -- that a proper naming scheme is defined for languages other than Ada.
1457 -- If Report_Error is null, use the standard error reporting mechanism
1458 -- (Errout). Otherwise, report errors using Report_Error.
1460 -- If Error_On_Unknown_Language is true, an error is displayed if some of
1461 -- the source files listed in the project do not match any naming scheme
1463 -- If Require_Obj_Dirs is true, then all object directories must exist
1464 -- (possibly after they have been created automatically if the appropriate
1465 -- switches were specified), or an error is raised.
1467 Gprbuild_Flags : constant Processing_Flags;
1468 Gprclean_Flags : constant Processing_Flags;
1469 Gnatmake_Flags : constant Processing_Flags;
1470 -- Flags used by the various tools. They all display the error messages
1477 procedure Record_Temp_File
1478 (Tree : Project_Tree_Ref;
1479 Path : Path_Name_Type);
1480 -- Record the path of a newly created temporary file, so that it can be
1483 procedure Delete_All_Temp_Files (Tree : Project_Tree_Ref);
1484 -- Delete all recorded temporary files.
1485 -- Does nothing if Debug.Debug_Flag_N is set
1487 procedure Delete_Temporary_File
1488 (Tree : Project_Tree_Ref;
1489 Path : Path_Name_Type);
1490 -- Delete a temporary file from the disk. The file is also removed from the
1491 -- list of temporary files to delete at the end of the program, in case
1492 -- another program running on the same machine has recreated it.
1493 -- Does nothing if Debug.Debug_Flag_N is set
1497 All_Packages : constant String_List_Access := null;
1499 No_Project_Tree : constant Project_Tree_Ref := null;
1501 Ignored : constant Variable_Kind := Single;
1503 Nil_Variable_Value : constant Variable_Value :=
1504 (Project => No_Project,
1506 Location => No_Location,
1509 Virtual_Prefix : constant String := "v$";
1510 -- The prefix for virtual extending projects. Because of the '$', which is
1511 -- normally forbidden for project names, there cannot be any name clash.
1513 type Source_Iterator is record
1514 In_Tree : Project_Tree_Ref;
1516 Project : Project_List;
1517 All_Projects : Boolean;
1518 -- Current project and whether we should move on to the next
1520 Language : Language_Ptr;
1521 -- Current language processed
1523 Language_Name : Name_Id;
1524 -- Only sources of this language will be returned (or all if No_Name)
1526 Current : Source_Id;
1529 procedure Add_To_Buffer
1531 To : in out String_Access;
1532 Last : in out Natural);
1533 -- Append a String to the Buffer
1535 package Temp_Files_Table is new GNAT.Dynamic_Tables
1536 (Table_Component_Type => Path_Name_Type,
1537 Table_Index_Type => Integer,
1538 Table_Low_Bound => 1,
1539 Table_Initial => 10,
1540 Table_Increment => 10);
1541 -- Table to store the path name of all the created temporary files, so that
1542 -- they can be deleted at the end, or when the program is interrupted.
1544 type Private_Project_Tree_Data is record
1545 Temp_Files : Temp_Files_Table.Instance;
1546 -- Temporary files created as part of running tools (pragma files,
1547 -- mapping files,...)
1549 Current_Source_Path_File : Path_Name_Type := No_Path;
1550 -- Current value of project source path file env var. Used to avoid
1551 -- setting the env var to the same value. When different from No_Path,
1552 -- this indicates that logical names (VMS) or environment variables were
1553 -- created and should be deassigned to avoid polluting the environment
1557 Current_Object_Path_File : Path_Name_Type := No_Path;
1558 -- Current value of project object path file env var. Used to avoid
1559 -- setting the env var to the same value.
1563 -- Type to represent the part of a project tree which is private to the
1566 type Processing_Flags is record
1567 Require_Sources_Other_Lang : Boolean;
1568 Report_Error : Error_Handler;
1569 When_No_Sources : Error_Warning;
1570 Allow_Duplicate_Basenames : Boolean;
1571 Compiler_Driver_Mandatory : Boolean;
1572 Error_On_Unknown_Language : Boolean;
1573 Require_Obj_Dirs : Error_Warning;
1576 Gprbuild_Flags : constant Processing_Flags :=
1577 (Report_Error => null,
1578 When_No_Sources => Warning,
1579 Require_Sources_Other_Lang => True,
1580 Allow_Duplicate_Basenames => False,
1581 Compiler_Driver_Mandatory => True,
1582 Error_On_Unknown_Language => True,
1583 Require_Obj_Dirs => Error);
1585 Gprclean_Flags : constant Processing_Flags :=
1586 (Report_Error => null,
1587 When_No_Sources => Warning,
1588 Require_Sources_Other_Lang => True,
1589 Allow_Duplicate_Basenames => False,
1590 Compiler_Driver_Mandatory => True,
1591 Error_On_Unknown_Language => True,
1592 Require_Obj_Dirs => Warning);
1594 Gnatmake_Flags : constant Processing_Flags :=
1595 (Report_Error => null,
1596 When_No_Sources => Error,
1597 Require_Sources_Other_Lang => False,
1598 Allow_Duplicate_Basenames => False,
1599 Compiler_Driver_Mandatory => False,
1600 Error_On_Unknown_Language => False,
1601 Require_Obj_Dirs => Error);