Merge from trunk:
[official-gcc.git] / main / gcc / ada / prj.ads
blob1beff66a9da962d69087c0253dfcc0bf1d8f7d15
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2014, Free Software Foundation, Inc. --
10 -- --
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. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
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 Osint;
35 with Scans; use Scans;
36 with Types; use Types;
38 with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
39 with GNAT.Dynamic_Tables;
40 with GNAT.OS_Lib; use GNAT.OS_Lib;
42 package Prj is
44 procedure Add_Restricted_Language (Name : String);
45 -- Call by gprbuild for each language specify by switch
46 -- --restricted-to-languages=.
48 procedure Remove_All_Restricted_Languages;
49 -- Call by gprbuild in CodePeer mode to ignore switches
50 -- --restricted-to-languages=.
52 function Is_Allowed_Language (Name : Name_Id) return Boolean;
53 -- Returns True if --restricted-to-languages= is not used or if Name
54 -- is one of the restricted languages.
56 All_Other_Names : constant Name_Id := Names_High_Bound;
57 -- Name used to replace others as an index of an associative array
58 -- attribute in situations where this is allowed.
60 Subdirs : String_Ptr := null;
61 -- The value after the equal sign in switch --subdirs=...
62 -- Contains the relative subdirectory.
64 type Library_Support is (None, Static_Only, Full);
65 -- Support for Library Project File.
66 -- - None: Library Project Files are not supported at all
67 -- - Static_Only: Library Project Files are only supported for static
68 -- libraries.
69 -- - Full: Library Project Files are supported for static and dynamic
70 -- (shared) libraries.
72 type Yes_No_Unknown is (Yes, No, Unknown);
73 -- Tri-state to decide if -lgnarl is needed when linking
75 type Attribute_Default_Value is
76 (Read_Only_Value, -- For read only attributes (Name, Project_Dir)
77 Empty_Value, -- Empty string or empty string list
78 Dot_Value, -- "." or (".")
79 Object_Dir_Value, -- 'Object_Dir
80 Target_Value); -- 'Target (special rules)
81 -- Describe the default values of attributes that are referenced but not
82 -- declared.
84 pragma Warnings (Off);
85 type Project_Qualifier is
86 (Unspecified,
88 -- The following clash with Standard is OK, and justified by the context
89 -- which really wants to use the same set of qualifiers.
91 Standard,
93 Library,
94 Configuration,
95 Abstract_Project,
96 Aggregate,
97 Aggregate_Library);
98 pragma Warnings (On);
99 -- Qualifiers that can prefix the reserved word "project" in a project
100 -- file:
101 -- Standard: standard project ...
102 -- Library: library project is ...
103 -- Abstract_Project: abstract project is
104 -- Aggregate: aggregate project is
105 -- Aggregate_Library: aggregate library project is ...
106 -- Configuration: configuration project is ...
108 subtype Aggregate_Project is
109 Project_Qualifier range Aggregate .. Aggregate_Library;
111 All_Packages : constant String_List_Access;
112 -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
113 -- Prj.Part, indicating that all packages should be checked.
115 type Project_Tree_Data;
116 type Project_Tree_Ref is access all Project_Tree_Data;
117 -- Reference to a project tree. Several project trees may exist in memory
118 -- at the same time.
120 No_Project_Tree : constant Project_Tree_Ref;
122 procedure Free (Tree : in out Project_Tree_Ref);
123 -- Free memory associated with the tree
125 Config_Project_File_Extension : String := ".cgpr";
126 Project_File_Extension : String := ".gpr";
127 -- The standard config and user project file name extensions. They are not
128 -- constants, because Canonical_Case_File_Name is called on these variables
129 -- in the body of Prj.
131 function Empty_File return File_Name_Type;
132 function Empty_String return Name_Id;
133 -- Return the id for an empty string ""
135 function Dot_String return Name_Id;
136 -- Return the id for "."
138 type Path_Information is record
139 Name : Path_Name_Type := No_Path;
140 Display_Name : Path_Name_Type := No_Path;
141 end record;
142 -- Directory names always end with a directory separator
144 No_Path_Information : constant Path_Information := (No_Path, No_Path);
146 type Project_Data;
147 type Project_Id is access all Project_Data;
148 No_Project : constant Project_Id := null;
149 -- Id of a Project File
151 type String_List_Id is new Nat;
152 Nil_String : constant String_List_Id := 0;
153 type String_Element is record
154 Value : Name_Id := No_Name;
155 Index : Int := 0;
156 Display_Value : Name_Id := No_Name;
157 Location : Source_Ptr := No_Location;
158 Flag : Boolean := False;
159 Next : String_List_Id := Nil_String;
160 end record;
161 -- To hold values for string list variables and array elements.
162 -- Component Flag may be used for various purposes. For source
163 -- directories, it indicates if the directory contains Ada source(s).
165 package String_Element_Table is new GNAT.Dynamic_Tables
166 (Table_Component_Type => String_Element,
167 Table_Index_Type => String_List_Id,
168 Table_Low_Bound => 1,
169 Table_Initial => 200,
170 Table_Increment => 100);
171 -- The table for string elements in string lists
173 type Variable_Kind is (Undefined, List, Single);
174 -- Different kinds of variables
176 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
177 -- The defined kinds of variables
179 Ignored : constant Variable_Kind;
180 -- Used to indicate that a package declaration must be ignored while
181 -- processing the project tree (unknown package name).
183 type Variable_Value (Kind : Variable_Kind := Undefined) is record
184 Project : Project_Id := No_Project;
185 Location : Source_Ptr := No_Location;
186 Default : Boolean := False;
187 case Kind is
188 when Undefined =>
189 null;
190 when List =>
191 Values : String_List_Id := Nil_String;
192 when Single =>
193 Value : Name_Id := No_Name;
194 Index : Int := 0;
195 end case;
196 end record;
197 -- Values for variables and array elements. Default is True if the
198 -- current value is the default one for the variable.
200 Nil_Variable_Value : constant Variable_Value;
201 -- Value of a non existing variable or array element
203 type Variable_Id is new Nat;
204 No_Variable : constant Variable_Id := 0;
205 type Variable is record
206 Next : Variable_Id := No_Variable;
207 Name : Name_Id;
208 Value : Variable_Value;
209 end record;
210 -- To hold the list of variables in a project file and in packages
212 package Variable_Element_Table is new GNAT.Dynamic_Tables
213 (Table_Component_Type => Variable,
214 Table_Index_Type => Variable_Id,
215 Table_Low_Bound => 1,
216 Table_Initial => 200,
217 Table_Increment => 100);
218 -- The table of variable in list of variables
220 type Array_Element_Id is new Nat;
221 No_Array_Element : constant Array_Element_Id := 0;
222 type Array_Element is record
223 Index : Name_Id;
224 Restricted : Boolean := False;
225 Src_Index : Int := 0;
226 Index_Case_Sensitive : Boolean := True;
227 Value : Variable_Value;
228 Next : Array_Element_Id := No_Array_Element;
229 end record;
230 -- Each Array_Element represents an array element and is linked (Next)
231 -- to the next array element, if any, in the array.
233 package Array_Element_Table is new GNAT.Dynamic_Tables
234 (Table_Component_Type => Array_Element,
235 Table_Index_Type => Array_Element_Id,
236 Table_Low_Bound => 1,
237 Table_Initial => 200,
238 Table_Increment => 100);
239 -- The table that contains all array elements
241 type Array_Id is new Nat;
242 No_Array : constant Array_Id := 0;
243 type Array_Data is record
244 Name : Name_Id := No_Name;
245 Location : Source_Ptr := No_Location;
246 Value : Array_Element_Id := No_Array_Element;
247 Next : Array_Id := No_Array;
248 end record;
249 -- Each Array_Data value represents an array.
250 -- Value is the id of the first element.
251 -- Next is the id of the next array in the project file or package.
253 package Array_Table is new GNAT.Dynamic_Tables
254 (Table_Component_Type => Array_Data,
255 Table_Index_Type => Array_Id,
256 Table_Low_Bound => 1,
257 Table_Initial => 200,
258 Table_Increment => 100);
259 -- The table that contains all arrays
261 type Package_Id is new Nat;
262 No_Package : constant Package_Id := 0;
263 type Declarations is record
264 Variables : Variable_Id := No_Variable;
265 Attributes : Variable_Id := No_Variable;
266 Arrays : Array_Id := No_Array;
267 Packages : Package_Id := No_Package;
268 end record;
269 -- Contains the declarations (variables, single and array attributes,
270 -- packages) for a project or a package in a project.
272 No_Declarations : constant Declarations :=
273 (Variables => No_Variable,
274 Attributes => No_Variable,
275 Arrays => No_Array,
276 Packages => No_Package);
277 -- Default value of Declarations: used if there are no declarations
279 type Package_Element is record
280 Name : Name_Id := No_Name;
281 Decl : Declarations := No_Declarations;
282 Parent : Package_Id := No_Package;
283 Next : Package_Id := No_Package;
284 end record;
285 -- A package (includes declarations that may include other packages)
287 package Package_Table is new GNAT.Dynamic_Tables
288 (Table_Component_Type => Package_Element,
289 Table_Index_Type => Package_Id,
290 Table_Low_Bound => 1,
291 Table_Initial => 100,
292 Table_Increment => 100);
293 -- The table that contains all packages
295 type Language_Data;
296 type Language_Ptr is access all Language_Data;
297 -- Index of language data
299 No_Language_Index : constant Language_Ptr := null;
300 -- Constant indicating that there is no language data
302 function Get_Language_From_Name
303 (Project : Project_Id;
304 Name : String) return Language_Ptr;
305 -- Get a language from a project. This might return null if no such
306 -- language exists in the project
308 Max_Header_Num : constant := 6150;
309 type Header_Num is range 0 .. Max_Header_Num;
310 -- Size for hash table below. The upper bound is an arbitrary value, the
311 -- value here was chosen after testing to determine a good compromise
312 -- between speed of access and memory usage.
314 function Hash (Name : Name_Id) return Header_Num;
315 function Hash (Name : File_Name_Type) return Header_Num;
316 function Hash (Name : Path_Name_Type) return Header_Num;
317 function Hash (Project : Project_Id) return Header_Num;
318 -- Used for computing hash values for names put into hash tables
320 type Language_Kind is (File_Based, Unit_Based);
321 -- Type for the kind of language. All languages are file based, except Ada
322 -- which is unit based.
324 -- Type of dependency to be checked
326 type Dependency_File_Kind is
327 (None,
328 -- There is no dependency file, the source must always be recompiled
330 Makefile,
331 -- The dependency file is a Makefile fragment indicating all the files
332 -- the source depends on. If the object file or the dependency file is
333 -- more recent than any of these files, the source must be recompiled.
335 ALI_File,
336 -- The dependency file is an ALI file and the source must be recompiled
337 -- if the object or ALI file is more recent than any of the sources
338 -- listed in the D lines.
340 ALI_Closure);
341 -- The dependency file is an ALI file and the source must be recompiled
342 -- if the object or ALI file is more recent than any source in the full
343 -- closure.
345 Makefile_Dependency_Suffix : constant String := ".d";
346 ALI_Dependency_Suffix : constant String := ".ali";
347 Switches_Dependency_Suffix : constant String := ".cswi";
349 Binder_Exchange_Suffix : constant String := ".bexch";
350 -- Suffix for binder exchange files
352 Library_Exchange_Suffix : constant String := ".lexch";
353 -- Suffix for library exchange files
355 type Name_List_Index is new Nat;
356 No_Name_List : constant Name_List_Index := 0;
358 type Name_Node is record
359 Name : Name_Id := No_Name;
360 Next : Name_List_Index := No_Name_List;
361 end record;
363 package Name_List_Table is new GNAT.Dynamic_Tables
364 (Table_Component_Type => Name_Node,
365 Table_Index_Type => Name_List_Index,
366 Table_Low_Bound => 1,
367 Table_Initial => 10,
368 Table_Increment => 100);
369 -- The table for lists of names
371 function Length
372 (Table : Name_List_Table.Instance;
373 List : Name_List_Index) return Natural;
374 -- Return the number of elements in specified list
376 type Number_List_Index is new Nat;
377 No_Number_List : constant Number_List_Index := 0;
379 type Number_Node is record
380 Number : Natural := 0;
381 Next : Number_List_Index := No_Number_List;
382 end record;
384 package Number_List_Table is new GNAT.Dynamic_Tables
385 (Table_Component_Type => Number_Node,
386 Table_Index_Type => Number_List_Index,
387 Table_Low_Bound => 1,
388 Table_Initial => 10,
389 Table_Increment => 100);
390 -- The table for lists of numbers
392 package Mapping_Files_Htable is new Simple_HTable
393 (Header_Num => Header_Num,
394 Element => Path_Name_Type,
395 No_Element => No_Path,
396 Key => Path_Name_Type,
397 Hash => Hash,
398 Equal => "=");
399 -- A hash table to store the mapping files that are not used
401 -- The following record ???
403 type Lang_Naming_Data is record
404 Dot_Replacement : File_Name_Type := No_File;
405 -- The string to replace '.' in the source file name (for Ada)
407 Casing : Casing_Type := All_Lower_Case;
408 -- The casing of the source file name (for Ada)
410 Separate_Suffix : File_Name_Type := No_File;
411 -- String to append to unit name for source file name of an Ada subunit
413 Spec_Suffix : File_Name_Type := No_File;
414 -- The string to append to the unit name for the
415 -- source file name of a spec.
417 Body_Suffix : File_Name_Type := No_File;
418 -- The string to append to the unit name for the
419 -- source file name of a body.
420 end record;
422 No_Lang_Naming_Data : constant Lang_Naming_Data :=
423 (Dot_Replacement => No_File,
424 Casing => All_Lower_Case,
425 Separate_Suffix => No_File,
426 Spec_Suffix => No_File,
427 Body_Suffix => No_File);
429 function Is_Standard_GNAT_Naming (Naming : Lang_Naming_Data) return Boolean;
430 -- True if the naming scheme is GNAT's default naming scheme. This
431 -- is to take into account shortened names like "Ada." (a-), "System." (s-)
432 -- and so on.
434 type Source_Data;
435 type Source_Id is access all Source_Data;
437 function Is_Compilable (Source : Source_Id) return Boolean;
438 pragma Inline (Is_Compilable);
439 -- Return True if we know how to compile Source (i.e. if a compiler is
440 -- defined). This doesn't indicate whether the source should be compiled.
442 function Object_To_Global_Archive (Source : Source_Id) return Boolean;
443 pragma Inline (Object_To_Global_Archive);
444 -- Return True if the object file should be put in the global archive.
445 -- This is for Ada, when only the closure of a main needs to be
446 -- (re)compiled.
448 function Other_Part (Source : Source_Id) return Source_Id;
449 pragma Inline (Other_Part);
450 -- Source ID for the other part, if any: for a spec, returns its body;
451 -- for a body, returns its spec.
453 No_Source : constant Source_Id := null;
455 type Path_Syntax_Kind is
456 (Canonical, -- Unix style
457 Host); -- Host specific syntax
459 -- The following record describes the configuration of a language
461 type Language_Config is record
462 Kind : Language_Kind := File_Based;
463 -- Kind of language. Most languages are file based. A few, such as Ada,
464 -- are unit based.
466 Naming_Data : Lang_Naming_Data;
467 -- The naming data for the languages (prefixes, etc.)
469 Include_Compatible_Languages : Name_List_Index := No_Name_List;
470 -- List of languages that are "include compatible" with this language. A
471 -- language B (for example "C") is "include compatible" with a language
472 -- A (for example "C++") if it is expected that sources of language A
473 -- may "include" header files from language B.
475 Compiler_Driver : File_Name_Type := No_File;
476 -- The name of the executable for the compiler of the language
478 Compiler_Driver_Path : String_Access := null;
479 -- The path name of the executable for the compiler of the language
481 Compiler_Leading_Required_Switches : Name_List_Index := No_Name_List;
482 -- The list of initial switches that are required as a minimum to invoke
483 -- the compiler driver.
485 Compiler_Trailing_Required_Switches : Name_List_Index := No_Name_List;
486 -- The list of final switches that are required as a minimum to invoke
487 -- the compiler driver.
489 Multi_Unit_Switches : Name_List_Index := No_Name_List;
490 -- The switch(es) to indicate the index of a unit in a multi-source file
492 Multi_Unit_Object_Separator : Character := ' ';
493 -- The string separating the base name of a source from the index of the
494 -- unit in a multi-source file, in the object file name.
496 Path_Syntax : Path_Syntax_Kind := Host;
497 -- Value may be Canonical (Unix style) or Host (host syntax)
499 Source_File_Switches : Name_List_Index := No_Name_List;
500 -- Optional switches to be put before the source file. The source file
501 -- path name is appended to the last switch in the list.
502 -- Example: ("-i", "");
504 Object_File_Suffix : Name_Id := No_Name;
505 -- Optional alternate object file suffix
507 Object_File_Switches : Name_List_Index := No_Name_List;
508 -- Optional object file switches. When this is defined, the switches
509 -- are used to specify the object file. The object file name is appended
510 -- to the last switch in the list. Example: ("-o", "").
512 Object_Path_Switches : Name_List_Index := No_Name_List;
513 -- List of switches to specify to the compiler the path name of a
514 -- temporary file containing the list of object directories in the
515 -- correct order.
517 Compilation_PIC_Option : Name_List_Index := No_Name_List;
518 -- The option(s) to compile a source in Position Independent Code for
519 -- shared libraries. Specified in the configuration. When not specified,
520 -- there is no need for such switch.
522 Object_Generated : Boolean := True;
523 -- False if no object file is generated
525 Objects_Linked : Boolean := True;
526 -- False if object files are not use to link executables and build
527 -- libraries.
529 Runtime_Library_Dir : Name_Id := No_Name;
530 -- Path name of the runtime library directory, if any
532 Runtime_Source_Dir : Name_Id := No_Name;
533 -- Path name of the runtime source directory, if any
535 Mapping_File_Switches : Name_List_Index := No_Name_List;
536 -- The option(s) to provide a mapping file to the compiler. Specified in
537 -- the configuration. When value is No_Name_List, there is no mapping
538 -- file.
540 Mapping_Spec_Suffix : File_Name_Type := No_File;
541 -- Placeholder representing the spec suffix in a mapping file
543 Mapping_Body_Suffix : File_Name_Type := No_File;
544 -- Placeholder representing the body suffix in a mapping file
546 Config_File_Switches : Name_List_Index := No_Name_List;
547 -- The option(s) to provide a config file to the compiler. Specified in
548 -- the configuration. If value is No_Name_List there is no config file.
550 Dependency_Kind : Dependency_File_Kind := None;
551 -- The kind of dependency to be checked: none, Makefile fragment or
552 -- ALI file (for Ada).
554 Dependency_Option : Name_List_Index := No_Name_List;
555 -- The option(s) to be used to create the dependency file. When value is
556 -- No_Name_List, there is not such option(s).
558 Compute_Dependency : Name_List_Index := No_Name_List;
559 -- Hold the value of attribute Dependency_Driver, if declared for the
560 -- language.
562 Include_Option : Name_List_Index := No_Name_List;
563 -- Hold the value of attribute Include_Switches, if declared for the
564 -- language.
566 Include_Path : Name_Id := No_Name;
567 -- Name of environment variable declared by attribute Include_Path for
568 -- the language.
570 Include_Path_File : Name_Id := No_Name;
571 -- Name of environment variable declared by attribute Include_Path_File
572 -- for the language.
574 Objects_Path : Name_Id := No_Name;
575 -- Name of environment variable declared by attribute Objects_Path for
576 -- the language.
578 Objects_Path_File : Name_Id := No_Name;
579 -- Name of environment variable declared by attribute Objects_Path_File
580 -- for the language.
582 Config_Body : Name_Id := No_Name;
583 -- The template for a pragma Source_File_Name(_Project) for a specific
584 -- file name of a body.
586 Config_Body_Index : Name_Id := No_Name;
587 -- The template for a pragma Source_File_Name(_Project) for a specific
588 -- file name of a body in a multi-source file.
590 Config_Body_Pattern : Name_Id := No_Name;
591 -- The template for a pragma Source_File_Name(_Project) for a naming
592 -- body pattern.
594 Config_Spec : Name_Id := No_Name;
595 -- The template for a pragma Source_File_Name(_Project) for a specific
596 -- file name of a spec.
598 Config_Spec_Index : Name_Id := No_Name;
599 -- The template for a pragma Source_File_Name(_Project) for a specific
600 -- file name of a spec in a multi-source file.
602 Config_Spec_Pattern : Name_Id := No_Name;
603 -- The template for a pragma Source_File_Name(_Project) for a naming
604 -- spec pattern.
606 Config_File_Unique : Boolean := False;
607 -- True if the config file specified to the compiler needs to be unique.
608 -- If it is unique, then all config files are concatenated into a temp
609 -- config file.
611 Binder_Driver : File_Name_Type := No_File;
612 -- The name of the binder driver for the language, if any
614 Binder_Driver_Path : Path_Name_Type := No_Path;
615 -- The path name of the binder driver
617 Binder_Required_Switches : Name_List_Index := No_Name_List;
618 -- Hold the value of attribute Binder'Required_Switches for the language
620 Binder_Prefix : Name_Id := No_Name;
621 -- Hold the value of attribute Binder'Prefix for the language
623 Toolchain_Version : Name_Id := No_Name;
624 -- Hold the value of attribute Toolchain_Version for the language
626 Toolchain_Description : Name_Id := No_Name;
627 -- Hold the value of attribute Toolchain_Description for the language
629 Clean_Object_Artifacts : Name_List_Index := No_Name_List;
630 -- List of object artifact extensions to be deleted by gprclean
632 Clean_Source_Artifacts : Name_List_Index := No_Name_List;
633 -- List of source artifact extensions to be deleted by gprclean
635 end record;
637 No_Language_Config : constant Language_Config :=
638 (Kind => File_Based,
639 Naming_Data => No_Lang_Naming_Data,
640 Include_Compatible_Languages => No_Name_List,
641 Compiler_Driver => No_File,
642 Compiler_Driver_Path => null,
643 Compiler_Leading_Required_Switches
644 => No_Name_List,
645 Compiler_Trailing_Required_Switches
646 => No_Name_List,
647 Multi_Unit_Switches => No_Name_List,
648 Multi_Unit_Object_Separator => ' ',
649 Path_Syntax => Canonical,
650 Source_File_Switches => No_Name_List,
651 Object_File_Suffix => No_Name,
652 Object_File_Switches => No_Name_List,
653 Object_Path_Switches => No_Name_List,
654 Compilation_PIC_Option => No_Name_List,
655 Object_Generated => True,
656 Objects_Linked => True,
657 Runtime_Library_Dir => No_Name,
658 Runtime_Source_Dir => No_Name,
659 Mapping_File_Switches => No_Name_List,
660 Mapping_Spec_Suffix => No_File,
661 Mapping_Body_Suffix => No_File,
662 Config_File_Switches => No_Name_List,
663 Dependency_Kind => None,
664 Dependency_Option => No_Name_List,
665 Compute_Dependency => No_Name_List,
666 Include_Option => No_Name_List,
667 Include_Path => No_Name,
668 Include_Path_File => No_Name,
669 Objects_Path => No_Name,
670 Objects_Path_File => No_Name,
671 Config_Body => No_Name,
672 Config_Body_Index => No_Name,
673 Config_Body_Pattern => No_Name,
674 Config_Spec => No_Name,
675 Config_Spec_Index => No_Name,
676 Config_Spec_Pattern => No_Name,
677 Config_File_Unique => False,
678 Binder_Driver => No_File,
679 Binder_Driver_Path => No_Path,
680 Binder_Required_Switches => No_Name_List,
681 Binder_Prefix => No_Name,
682 Toolchain_Version => No_Name,
683 Toolchain_Description => No_Name,
684 Clean_Object_Artifacts => No_Name_List,
685 Clean_Source_Artifacts => No_Name_List);
687 type Language_Data is record
688 Name : Name_Id := No_Name;
689 -- The name of the language in lower case
691 Display_Name : Name_Id := No_Name;
692 -- The name of the language, as found in attribute Languages
694 Config : Language_Config := No_Language_Config;
695 -- Configuration of the language
697 First_Source : Source_Id := No_Source;
698 -- Head of the list of sources of the language in the project
700 Mapping_Files : Mapping_Files_Htable.Instance :=
701 Mapping_Files_Htable.Nil;
702 -- Hash table containing the mapping of the sources to their path names
704 Next : Language_Ptr := No_Language_Index;
705 -- Next language of the project
707 end record;
709 No_Language_Data : constant Language_Data :=
710 (Name => No_Name,
711 Display_Name => No_Name,
712 Config => No_Language_Config,
713 First_Source => No_Source,
714 Mapping_Files => Mapping_Files_Htable.Nil,
715 Next => No_Language_Index);
717 type Language_List_Element;
718 type Language_List is access all Language_List_Element;
719 type Language_List_Element is record
720 Language : Language_Ptr := No_Language_Index;
721 Next : Language_List;
722 end record;
724 type Source_Kind is (Spec, Impl, Sep);
725 subtype Spec_Or_Body is Source_Kind range Spec .. Impl;
727 -- The following declarations declare a structure used to store the Name
728 -- and File and Path names of a unit, with a reference to its GNAT Project
729 -- File(s). Some units might have neither Spec nor Impl when they were
730 -- created for a "separate".
732 type File_Names_Data is array (Spec_Or_Body) of Source_Id;
734 type Unit_Data is record
735 Name : Name_Id := No_Name;
736 File_Names : File_Names_Data;
737 end record;
739 type Unit_Index is access all Unit_Data;
741 No_Unit_Index : constant Unit_Index := null;
742 -- Used to indicate a null entry for no unit
744 type Source_Roots;
745 type Roots_Access is access Source_Roots;
746 type Source_Roots is record
747 Root : Source_Id;
748 Next : Roots_Access;
749 end record;
750 -- A list to store the roots associated with a main unit. These are the
751 -- files that need to linked along with the main (for instance a C file
752 -- corresponding to an Ada file). In general, these are dependencies that
753 -- cannot be computed automatically by the builder.
755 type Naming_Exception_Type is (No, Yes, Inherited);
757 -- Structure to define source data
759 type Source_Data is record
760 Initialized : Boolean := False;
761 -- Set to True when Source_Data is completely initialized
763 Project : Project_Id := No_Project;
764 -- Project of the source
766 Location : Source_Ptr := No_Location;
767 -- Location in the project file of the declaration of the source in
768 -- package Naming.
770 Source_Dir_Rank : Natural := 0;
771 -- The rank of the source directory in list declared with attribute
772 -- Source_Dirs. Two source files with the same name cannot appears in
773 -- different directory with the same rank. That can happen when the
774 -- recursive notation <dir>/** is used in attribute Source_Dirs.
776 Language : Language_Ptr := No_Language_Index;
777 -- Language of the source
779 In_Interfaces : Boolean := True;
780 -- False when the source is not included in interfaces, when attribute
781 -- Interfaces is declared.
783 Declared_In_Interfaces : Boolean := False;
784 -- True when source is declared in attribute Interfaces
786 Alternate_Languages : Language_List := null;
787 -- List of languages a header file may also be, in addition of language
788 -- Language_Name.
790 Kind : Source_Kind := Spec;
791 -- Kind of the source: spec, body or subunit
793 Unit : Unit_Index := No_Unit_Index;
794 -- Name of the unit, if language is unit based. This is only set for
795 -- those files that are part of the compilation set (for instance a
796 -- file in an extended project that is overridden will not have this
797 -- field set).
799 Index : Int := 0;
800 -- Index of the source in a multi unit source file (the same Source_Data
801 -- is duplicated several times when there are several units in the same
802 -- file). Index is 0 if there is either no unit or a single one, and
803 -- starts at 1 when there are multiple units
805 Compilable : Yes_No_Unknown := Unknown;
806 -- Updated at the first call to Is_Compilable. Yes if source file is
807 -- compilable.
809 In_The_Queue : Boolean := False;
810 -- True if the source has been put in the queue
812 Locally_Removed : Boolean := False;
813 -- True if the source has been "excluded"
815 Suppressed : Boolean := False;
816 -- True if the source is a locally removed direct source of the project.
817 -- These sources should not be put in the mapping file.
819 Replaced_By : Source_Id := No_Source;
820 -- Source in an extending project that replaces the current source
822 File : File_Name_Type := No_File;
823 -- Canonical file name of the source
825 Display_File : File_Name_Type := No_File;
826 -- File name of the source, for display purposes
828 Path : Path_Information := No_Path_Information;
829 -- Path name of the source
831 Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
832 -- Time stamp of the source file
834 Object_Project : Project_Id := No_Project;
835 -- Project where the object file is. This might be different from
836 -- Project when using extending project files.
838 Object : File_Name_Type := No_File;
839 -- File name of the object file
841 Current_Object_Path : Path_Name_Type := No_Path;
842 -- Object path of an existing object file
844 Object_Path : Path_Name_Type := No_Path;
845 -- Object path of the real object file
847 Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
848 -- Object file time stamp
850 Dep_Name : File_Name_Type := No_File;
851 -- Dependency file simple name
853 Current_Dep_Path : Path_Name_Type := No_Path;
854 -- Path name of an existing dependency file
856 Dep_Path : Path_Name_Type := No_Path;
857 -- Path name of the real dependency file
859 Dep_TS : aliased Osint.File_Attributes := Osint.Unknown_Attributes;
860 -- Dependency file time stamp
862 Switches : File_Name_Type := No_File;
863 -- File name of the switches file. For all languages, this is a file
864 -- that ends with the .cswi extension.
866 Switches_Path : Path_Name_Type := No_Path;
867 -- Path name of the switches file
869 Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
870 -- Switches file time stamp
872 Naming_Exception : Naming_Exception_Type := No;
873 -- True if the source has an exceptional name
875 Duplicate_Unit : Boolean := False;
876 -- True when a duplicate unit has been reported for this source
878 Next_In_Lang : Source_Id := No_Source;
879 -- Link to another source of the same language in the same project
881 Next_With_File_Name : Source_Id := No_Source;
882 -- Link to another source with the same base file name
884 Roots : Roots_Access := null;
885 -- The roots for a main unit
887 end record;
889 No_Source_Data : constant Source_Data :=
890 (Initialized => False,
891 Project => No_Project,
892 Location => No_Location,
893 Source_Dir_Rank => 0,
894 Language => No_Language_Index,
895 In_Interfaces => True,
896 Declared_In_Interfaces => False,
897 Alternate_Languages => null,
898 Kind => Spec,
899 Unit => No_Unit_Index,
900 Index => 0,
901 Locally_Removed => False,
902 Suppressed => False,
903 Compilable => Unknown,
904 In_The_Queue => False,
905 Replaced_By => No_Source,
906 File => No_File,
907 Display_File => No_File,
908 Path => No_Path_Information,
909 Source_TS => Empty_Time_Stamp,
910 Object_Project => No_Project,
911 Object => No_File,
912 Current_Object_Path => No_Path,
913 Object_Path => No_Path,
914 Object_TS => Empty_Time_Stamp,
915 Dep_Name => No_File,
916 Current_Dep_Path => No_Path,
917 Dep_Path => No_Path,
918 Dep_TS => Osint.Unknown_Attributes,
919 Switches => No_File,
920 Switches_Path => No_Path,
921 Switches_TS => Empty_Time_Stamp,
922 Naming_Exception => No,
923 Duplicate_Unit => False,
924 Next_In_Lang => No_Source,
925 Next_With_File_Name => No_Source,
926 Roots => null);
928 package Source_Files_Htable is new Simple_HTable
929 (Header_Num => Header_Num,
930 Element => Source_Id,
931 No_Element => No_Source,
932 Key => File_Name_Type,
933 Hash => Hash,
934 Equal => "=");
935 -- Mapping of source file names to source ids
937 package Source_Paths_Htable is new Simple_HTable
938 (Header_Num => Header_Num,
939 Element => Source_Id,
940 No_Element => No_Source,
941 Key => Path_Name_Type,
942 Hash => Hash,
943 Equal => "=");
944 -- Mapping of source paths to source ids
946 type Lib_Kind is (Static, Dynamic, Relocatable);
948 type Policy is (Autonomous, Compliant, Controlled, Restricted, Direct);
949 -- Type to specify the symbol policy, when symbol control is supported.
950 -- See full explanation about this type in package Symbols.
951 -- Autonomous: Create a symbol file without considering any reference
952 -- Compliant: Try to be as compatible as possible with an existing ref
953 -- Controlled: Fail if symbols are not the same as those in the reference
954 -- Restricted: Restrict the symbols to those in the symbol file
955 -- Direct: The symbol file is used as is
957 type Symbol_Record is record
958 Symbol_File : Path_Name_Type := No_Path;
959 Reference : Path_Name_Type := No_Path;
960 Symbol_Policy : Policy := Autonomous;
961 end record;
962 -- Type to keep the symbol data to be used when building a shared library
964 No_Symbols : constant Symbol_Record :=
965 (Symbol_File => No_Path,
966 Reference => No_Path,
967 Symbol_Policy => Autonomous);
968 -- The default value of the symbol data
970 function Image (The_Casing : Casing_Type) return String;
971 -- Similar to 'Image (but avoid use of this attribute in compiler)
973 function Value (Image : String) return Casing_Type;
974 -- Similar to 'Value (but avoid use of this attribute in compiler)
975 -- Raises Constraint_Error if not a Casing_Type image.
977 -- The following record contains data for a naming scheme
979 function Get_Object_Directory
980 (Project : Project_Id;
981 Including_Libraries : Boolean;
982 Only_If_Ada : Boolean := False) return Path_Name_Type;
983 -- Return the object directory to use for the project. This depends on
984 -- whether we have a library project or a standard project. This function
985 -- might return No_Name when no directory applies. If the project is a
986 -- library project file and Including_Libraries is True then the library
987 -- ALI dir is returned instead of the object dir, except when there is no
988 -- ALI files in the Library ALI dir and the object directory exists. If
989 -- Only_If_Ada is True, then No_Name is returned when the project doesn't
990 -- include any Ada source.
992 procedure Compute_All_Imported_Projects
993 (Root_Project : Project_Id;
994 Tree : Project_Tree_Ref);
995 -- For all projects in the tree, compute the list of the projects imported
996 -- directly or indirectly by project Root_Project. The result is stored in
997 -- Project.All_Imported_Projects for each project
999 function Ultimate_Extending_Project_Of
1000 (Proj : Project_Id) return Project_Id;
1001 -- Returns the ultimate extending project of project Proj. If project Proj
1002 -- is not extended, returns Proj.
1004 type Project_List_Element;
1005 type Project_List is access all Project_List_Element;
1006 type Project_List_Element is record
1007 Project : Project_Id := No_Project;
1008 From_Encapsulated_Lib : Boolean := False;
1009 Next : Project_List := null;
1010 end record;
1011 -- A list of projects
1013 procedure Free_List
1014 (List : in out Project_List;
1015 Free_Project : Boolean);
1016 -- Free the list of projects, if Free_Project, each project is also freed
1018 type Response_File_Format is
1019 (None,
1020 GNU,
1021 Object_List,
1022 Option_List,
1023 GCC,
1024 GCC_GNU,
1025 GCC_Object_List,
1026 GCC_Option_List);
1027 -- The format of the different response files
1029 type Project_Configuration is record
1030 Target : Name_Id := No_Name;
1031 -- The target of the configuration, when specified
1033 Run_Path_Option : Name_List_Index := No_Name_List;
1034 -- The option to use when linking to specify the path where to look for
1035 -- libraries.
1037 Run_Path_Origin : Name_Id := No_Name;
1038 -- Specify the string (such as "$ORIGIN") to indicate paths relative to
1039 -- the directory of the executable in the run path option.
1041 Library_Install_Name_Option : Name_Id := No_Name;
1042 -- When this is not an empty list, this option, followed by the single
1043 -- name of the shared library file is used when linking a shared
1044 -- library.
1046 Separate_Run_Path_Options : Boolean := False;
1047 -- True if each directory needs to be specified in a separate run path
1048 -- option.
1050 Executable_Suffix : Name_Id := No_Name;
1051 -- The suffix of executables, when specified in the configuration or in
1052 -- package Builder of the main project. When this is not specified, the
1053 -- executable suffix is the default for the platform.
1055 -- Linking
1057 Linker : Path_Name_Type := No_Path;
1058 -- Path name of the linker driver. Specified in the configuration or in
1059 -- the package Builder of the main project.
1061 Map_File_Option : Name_Id := No_Name;
1062 -- Option to use when invoking the linker to build a map file
1064 Trailing_Linker_Required_Switches : Name_List_Index := No_Name_List;
1065 -- The minimum options for the linker driver. Specified in the
1066 -- configuration.
1068 Linker_Executable_Option : Name_List_Index := No_Name_List;
1069 -- The option(s) to indicate the name of the executable in the linker
1070 -- command. Specified in the configuration. When not specified, default
1071 -- to -o <executable name>.
1073 Linker_Lib_Dir_Option : Name_Id := No_Name;
1074 -- The option to specify where to find a library for linking. Specified
1075 -- in the configuration. When not specified, defaults to "-L".
1077 Linker_Lib_Name_Option : Name_Id := No_Name;
1078 -- The option to specify the name of a library for linking. Specified in
1079 -- the configuration. When not specified, defaults to "-l".
1081 Max_Command_Line_Length : Natural := 0;
1082 -- When positive and when Resp_File_Format (see below) is not None,
1083 -- if the command line for the invocation of the linker would be greater
1084 -- than this value, a response file is used to invoke the linker.
1086 Resp_File_Format : Response_File_Format := None;
1087 -- The format of a response file, when linking with a response file is
1088 -- supported.
1090 Resp_File_Options : Name_List_Index := No_Name_List;
1091 -- The switches, if any, that precede the path name of the response
1092 -- file in the invocation of the linker.
1094 -- Libraries
1096 Library_Builder : Path_Name_Type := No_Path;
1097 -- The executable to build library (specified in the configuration)
1099 Lib_Support : Library_Support := None;
1100 -- The level of library support. Specified in the configuration. Support
1101 -- is none, static libraries only or both static and shared libraries.
1103 Lib_Encapsulated_Supported : Boolean := False;
1104 -- True when building fully standalone libraries supported on the target
1106 Archive_Builder : Name_List_Index := No_Name_List;
1107 -- The name of the executable to build archives, with the minimum
1108 -- switches. Specified in the configuration.
1110 Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
1111 -- The options to append object files to an archive
1113 Archive_Indexer : Name_List_Index := No_Name_List;
1114 -- The name of the executable to index archives, with the minimum
1115 -- switches. Specified in the configuration.
1117 Archive_Suffix : File_Name_Type := No_File;
1118 -- The suffix of archives. Specified in the configuration. When not
1119 -- specified, defaults to ".a".
1121 Lib_Partial_Linker : Name_List_Index := No_Name_List;
1123 -- Shared libraries
1125 Shared_Lib_Driver : File_Name_Type := No_File;
1126 -- The driver to link shared libraries. Set with attribute Library_GCC.
1127 -- Default to gcc.
1129 Shared_Lib_Prefix : File_Name_Type := No_File;
1130 -- Part of a shared library file name that precedes the name of the
1131 -- library. Specified in the configuration. When not specified, defaults
1132 -- to "lib".
1134 Shared_Lib_Suffix : File_Name_Type := No_File;
1135 -- Suffix of shared libraries, after the library name in the shared
1136 -- library name. Specified in the configuration. When not specified,
1137 -- default to ".so".
1139 Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
1140 -- The minimum options to use when building a shared library
1142 Lib_Version_Options : Name_List_Index := No_Name_List;
1143 -- The options to use to specify a library version
1145 Symbolic_Link_Supported : Boolean := False;
1146 -- True if the platform supports symbolic link files
1148 Lib_Maj_Min_Id_Supported : Boolean := False;
1149 -- True if platform supports library major and minor options, such as
1150 -- libname.so -> libname.so.2 -> libname.so.2.4
1152 Auto_Init_Supported : Boolean := False;
1153 -- True if automatic initialisation is supported for shared stand-alone
1154 -- libraries.
1156 -- Cleaning
1158 Artifacts_In_Exec_Dir : Name_List_Index := No_Name_List;
1159 -- List of regexp file names to be cleaned in the exec directory of the
1160 -- main project.
1162 Artifacts_In_Object_Dir : Name_List_Index := No_Name_List;
1163 -- List of regexp file names to be cleaned in the object directory of
1164 -- all projects.
1166 end record;
1168 Default_Project_Config : constant Project_Configuration :=
1169 (Target => No_Name,
1170 Run_Path_Option => No_Name_List,
1171 Run_Path_Origin => No_Name,
1172 Library_Install_Name_Option => No_Name,
1173 Separate_Run_Path_Options => False,
1174 Executable_Suffix => No_Name,
1175 Linker => No_Path,
1176 Map_File_Option => No_Name,
1177 Trailing_Linker_Required_Switches =>
1178 No_Name_List,
1179 Linker_Executable_Option => No_Name_List,
1180 Linker_Lib_Dir_Option => No_Name,
1181 Linker_Lib_Name_Option => No_Name,
1182 Library_Builder => No_Path,
1183 Max_Command_Line_Length => 0,
1184 Resp_File_Format => None,
1185 Resp_File_Options => No_Name_List,
1186 Lib_Support => None,
1187 Lib_Encapsulated_Supported => False,
1188 Archive_Builder => No_Name_List,
1189 Archive_Builder_Append_Option => No_Name_List,
1190 Archive_Indexer => No_Name_List,
1191 Archive_Suffix => No_File,
1192 Lib_Partial_Linker => No_Name_List,
1193 Shared_Lib_Driver => No_File,
1194 Shared_Lib_Prefix => No_File,
1195 Shared_Lib_Suffix => No_File,
1196 Shared_Lib_Min_Options => No_Name_List,
1197 Lib_Version_Options => No_Name_List,
1198 Symbolic_Link_Supported => False,
1199 Lib_Maj_Min_Id_Supported => False,
1200 Auto_Init_Supported => False,
1201 Artifacts_In_Exec_Dir => No_Name_List,
1202 Artifacts_In_Object_Dir => No_Name_List);
1204 -------------------------
1205 -- Aggregated projects --
1206 -------------------------
1208 type Aggregated_Project;
1209 type Aggregated_Project_List is access all Aggregated_Project;
1210 type Aggregated_Project is record
1211 Path : Path_Name_Type;
1212 Tree : Project_Tree_Ref;
1213 Project : Project_Id;
1214 Next : Aggregated_Project_List;
1215 end record;
1217 procedure Free (List : in out Aggregated_Project_List);
1218 -- Free the memory used for List
1220 procedure Add_Aggregated_Project
1221 (Project : Project_Id;
1222 Path : Path_Name_Type);
1223 -- Add a new aggregated project in Project.
1224 -- The aggregated project has not been processed yet. This procedure should
1225 -- the called while processing the aggregate project, and as a result
1226 -- Prj.Proc.Process will then automatically process the aggregated projects
1228 ------------------
1229 -- Project_Data --
1230 ------------------
1232 -- The following record describes a project file representation
1234 pragma Warnings (Off);
1235 type Standalone is
1236 (No,
1238 -- The following clash with Standard is OK, and justified by the context
1239 -- which really wants to use the same set of qualifiers.
1241 Standard,
1243 Encapsulated);
1244 pragma Warnings (On);
1246 type Project_Data (Qualifier : Project_Qualifier := Unspecified) is record
1248 -------------
1249 -- General --
1250 -------------
1252 Name : Name_Id := No_Name;
1253 -- The name of the project
1255 Display_Name : Name_Id := No_Name;
1256 -- The name of the project with the spelling of its declaration
1258 Externally_Built : Boolean := False;
1259 -- True if the project is externally built. In such case, the Project
1260 -- Manager will not modify anything in this project.
1262 Config : Project_Configuration;
1264 Path : Path_Information := No_Path_Information;
1265 -- The path name of the project file. This include base name of the
1266 -- project file.
1268 Virtual : Boolean := False;
1269 -- True for virtual extending projects
1271 Location : Source_Ptr := No_Location;
1272 -- The location in the project file source of the project name that
1273 -- immediately follows the reserved word "project".
1275 ---------------
1276 -- Languages --
1277 ---------------
1279 Languages : Language_Ptr := No_Language_Index;
1280 -- First index of the language data in the project. Traversing the list
1281 -- gives access to all the languages supported by the project.
1283 --------------
1284 -- Projects --
1285 --------------
1287 Mains : String_List_Id := Nil_String;
1288 -- List of mains specified by attribute Main
1290 Extends : Project_Id := No_Project;
1291 -- The reference of the project file, if any, that this project file
1292 -- extends.
1294 Extended_By : Project_Id := No_Project;
1295 -- The reference of the project file, if any, that extends this project
1296 -- file.
1298 Decl : Declarations := No_Declarations;
1299 -- The declarations (variables, attributes and packages) of this project
1300 -- file.
1302 Imported_Projects : Project_List := null;
1303 -- The list of all directly imported projects, if any
1305 All_Imported_Projects : Project_List := null;
1306 -- The list of all projects imported directly or indirectly, if any.
1307 -- This does not include the project itself.
1309 -----------------
1310 -- Directories --
1311 -----------------
1313 Directory : Path_Information := No_Path_Information;
1314 -- Path name of the directory where the project file resides
1316 Object_Directory : Path_Information := No_Path_Information;
1317 -- The path name of the object directory of this project file
1319 Exec_Directory : Path_Information := No_Path_Information;
1320 -- The path name of the exec directory of this project file. Default is
1321 -- equal to Object_Directory.
1323 Object_Path_File : Path_Name_Type := No_Path;
1324 -- Store the name of the temporary file that contains the list of object
1325 -- directories, when attribute Object_Path_Switches is declared.
1327 -------------
1328 -- Library --
1329 -------------
1331 Library : Boolean := False;
1332 -- True if this is a library project
1334 Library_Name : Name_Id := No_Name;
1335 -- If a library project, name of the library
1337 Library_Kind : Lib_Kind := Static;
1338 -- If a library project, kind of library
1340 Library_Dir : Path_Information := No_Path_Information;
1341 -- If a library project, path name of the directory where the library
1342 -- resides.
1344 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
1345 -- The timestamp of a library file in a library project
1347 Library_Src_Dir : Path_Information := No_Path_Information;
1348 -- If a Stand-Alone Library project, path name of the directory where
1349 -- the sources of the interfaces of the library are copied. By default,
1350 -- if attribute Library_Src_Dir is not specified, sources of the
1351 -- interfaces are not copied anywhere.
1353 Library_ALI_Dir : Path_Information := No_Path_Information;
1354 -- In a library project, path name of the directory where the ALI files
1355 -- are copied. If attribute Library_ALI_Dir is not specified, ALI files
1356 -- are copied in the Library_Dir.
1358 Lib_Internal_Name : Name_Id := No_Name;
1359 -- If a library project, internal name store inside the library
1361 Standalone_Library : Standalone := No;
1362 -- Indicate that this is a Standalone Library Project File
1364 Lib_Interface_ALIs : String_List_Id := Nil_String;
1365 -- For Standalone Library Project Files, list of Interface ALI files
1367 Other_Interfaces : String_List_Id := Nil_String;
1368 -- List of non unit based sources in attribute Interfaces
1370 Lib_Auto_Init : Boolean := False;
1371 -- For non static Stand-Alone Library Project Files, True if the library
1372 -- initialisation should be automatic.
1374 Symbol_Data : Symbol_Record := No_Symbols;
1375 -- Symbol file name, reference symbol file name, symbol policy
1377 Need_To_Build_Lib : Boolean := False;
1378 -- True if the library of a Library Project needs to be built or rebuilt
1380 -------------
1381 -- Sources --
1382 -------------
1383 -- The sources for all languages including Ada are accessible through
1384 -- the Source_Iterator type
1386 Interfaces_Defined : Boolean := False;
1387 -- True if attribute Interfaces is declared for the project or any
1388 -- project it extends.
1390 Include_Path_File : Path_Name_Type := No_Path;
1391 -- The path name of the of the source search directory file.
1392 -- This is only used by gnatmake
1394 Source_Dirs : String_List_Id := Nil_String;
1395 -- The list of all the source directories
1397 Source_Dir_Ranks : Number_List_Index := No_Number_List;
1399 Ada_Include_Path : String_Access := null;
1400 -- The cached value of source search path for this project file. Set by
1401 -- the first call to Prj.Env.Ada_Include_Path for the project. Do not
1402 -- use this field directly outside of the project manager, use
1403 -- Prj.Env.Ada_Include_Path instead.
1405 Has_Multi_Unit_Sources : Boolean := False;
1406 -- Whether there is at least one source file containing multiple units
1408 -------------------
1409 -- Miscellaneous --
1410 -------------------
1412 Ada_Objects_Path : String_Access := null;
1413 -- The cached value of ADA_OBJECTS_PATH for this project file, with
1414 -- library ALI directories for library projects instead of object
1415 -- directories. Do not use this field directly outside of the
1416 -- compiler, use Prj.Env.Ada_Objects_Path instead.
1418 Ada_Objects_Path_No_Libs : String_Access := null;
1419 -- The cached value of ADA_OBJECTS_PATH for this project file with all
1420 -- object directories (no library ALI dir for library projects).
1422 Libgnarl_Needed : Yes_No_Unknown := Unknown;
1423 -- Set to True when libgnarl is needed to link
1425 Objects_Path : String_Access := null;
1426 -- The cached value of the object dir path, used during the binding
1427 -- phase of gprbuild.
1429 Objects_Path_File_With_Libs : Path_Name_Type := No_Path;
1430 -- The cached value of the object path temp file (including library
1431 -- dirs) for this project file.
1433 Objects_Path_File_Without_Libs : Path_Name_Type := No_Path;
1434 -- The cached value of the object path temp file (excluding library
1435 -- dirs) for this project file.
1437 Config_File_Name : Path_Name_Type := No_Path;
1438 -- The path name of the configuration pragmas file, if any
1440 Config_File_Temp : Boolean := False;
1441 -- True if the configuration pragmas file is a temporary file that must
1442 -- be deleted at the end.
1444 Config_Checked : Boolean := False;
1445 -- A flag to avoid checking repetitively the configuration pragmas file
1447 Depth : Natural := 0;
1448 -- The maximum depth of a project in the project graph. Depth of main
1449 -- project is 0.
1451 Unkept_Comments : Boolean := False;
1452 -- True if there are comments in the project sources that cannot be kept
1453 -- in the project tree.
1455 -----------------------------
1456 -- Qualifier-Specific data --
1457 -----------------------------
1459 -- The following fields are only valid for specific types of projects
1461 case Qualifier is
1462 when Aggregate | Aggregate_Library =>
1463 Aggregated_Projects : Aggregated_Project_List := null;
1464 -- List of aggregated projects (which could themselves be
1465 -- aggregate projects).
1467 when others =>
1468 null;
1469 end case;
1470 end record;
1472 function Empty_Project (Qualifier : Project_Qualifier) return Project_Data;
1473 -- Return the representation of an empty project
1475 function Is_Extending
1476 (Extending : Project_Id;
1477 Extended : Project_Id) return Boolean;
1478 -- Return True if Extending is extending the Extended project
1480 function Is_Ext
1481 (Extending : Project_Id;
1482 Extended : Project_Id) return Boolean renames Is_Extending;
1484 function Has_Ada_Sources (Data : Project_Id) return Boolean;
1485 -- Return True if the project has Ada sources
1487 Project_Error : exception;
1488 -- Raised by some subprograms in Prj.Attr
1490 package Units_Htable is new Simple_HTable
1491 (Header_Num => Header_Num,
1492 Element => Unit_Index,
1493 No_Element => No_Unit_Index,
1494 Key => Name_Id,
1495 Hash => Hash,
1496 Equal => "=");
1497 -- Mapping of unit names to indexes in the Units table
1499 ---------------------
1500 -- Source_Iterator --
1501 ---------------------
1503 type Source_Iterator is private;
1505 function For_Each_Source
1506 (In_Tree : Project_Tree_Ref;
1507 Project : Project_Id := No_Project;
1508 Language : Name_Id := No_Name;
1509 Encapsulated_Libs : Boolean := True;
1510 Locally_Removed : Boolean := True) return Source_Iterator;
1511 -- Returns an iterator for all the sources of a project tree, or a specific
1512 -- project, or a specific language. Include sources from aggregated libs if
1513 -- Aggregated_Libs is True. If Locally_Removed is set to False the
1514 -- Locally_Removed files won't be reported.
1516 function Element (Iter : Source_Iterator) return Source_Id;
1517 -- Return the current source (or No_Source if there are no more sources)
1519 procedure Next (Iter : in out Source_Iterator);
1520 -- Move on to the next source
1522 function Find_Source
1523 (In_Tree : Project_Tree_Ref;
1524 Project : Project_Id;
1525 In_Imported_Only : Boolean := False;
1526 In_Extended_Only : Boolean := False;
1527 Base_Name : File_Name_Type;
1528 Index : Int := 0) return Source_Id;
1529 -- Find the first source file with the given name.
1530 -- If In_Extended_Only is True, it will search in project and the project
1531 -- it extends, but not in the imported projects.
1532 -- Elsif In_Imported_Only is True, it will search in project and the
1533 -- projects it imports, but not in the others or in aggregated projects.
1534 -- Else it searches in the whole tree.
1535 -- If Index is specified, this only search for a source with that index.
1537 type Source_Ids is array (Positive range <>) of Source_Id;
1538 No_Sources : constant Source_Ids := (1 .. 0 => No_Source);
1540 function Find_All_Sources
1541 (In_Tree : Project_Tree_Ref;
1542 Project : Project_Id;
1543 In_Imported_Only : Boolean := False;
1544 In_Extended_Only : Boolean := False;
1545 Base_Name : File_Name_Type;
1546 Index : Int := 0) return Source_Ids;
1547 -- Find all source files with the given name:
1549 -- If In_Extended_Only is True, it will search in project and the project
1550 -- it extends, but not in the imported projects.
1552 -- If Extended_Only is False, and In_Imported_Only is True, it will
1553 -- search in project and the projects it imports, but not in the others
1554 -- or in aggregated projects.
1556 -- If both Extended_Only and In_Imported_Only are False (the default)
1557 -- then it searches the whole tree.
1559 -- If Index is specified, this only search for sources with that index.
1561 -----------------------
1562 -- Project_Tree_Data --
1563 -----------------------
1565 package Replaced_Source_HTable is new Simple_HTable
1566 (Header_Num => Header_Num,
1567 Element => File_Name_Type,
1568 No_Element => No_File,
1569 Key => File_Name_Type,
1570 Hash => Hash,
1571 Equal => "=");
1573 type Private_Project_Tree_Data is private;
1574 -- Data for a project tree that is used only by the Project Manager
1576 type Shared_Project_Tree_Data is record
1577 Name_Lists : Name_List_Table.Instance;
1578 Number_Lists : Number_List_Table.Instance;
1579 String_Elements : String_Element_Table.Instance;
1580 Variable_Elements : Variable_Element_Table.Instance;
1581 Array_Elements : Array_Element_Table.Instance;
1582 Arrays : Array_Table.Instance;
1583 Packages : Package_Table.Instance;
1584 Private_Part : Private_Project_Tree_Data;
1585 Dot_String_List : String_List_Id := Nil_String;
1586 end record;
1587 type Shared_Project_Tree_Data_Access is access all Shared_Project_Tree_Data;
1588 -- The data that is shared among multiple trees, when these trees are
1589 -- loaded through the same aggregate project.
1590 -- To avoid ambiguities, limit the number of parameters to the
1591 -- subprograms (we would have to parse the "root project tree" since this
1592 -- is where the configuration file was loaded, in addition to the project's
1593 -- own tree) and make the comparison of projects easier, all trees store
1594 -- the lists in the same tables.
1596 type Project_Tree_Appdata is tagged null record;
1597 type Project_Tree_Appdata_Access is access all Project_Tree_Appdata'Class;
1598 -- Application-specific data that can be associated with a project tree.
1599 -- We do not make the Project_Tree_Data itself tagged for several reasons:
1600 -- - it couldn't have a default value for its discriminant
1601 -- - it would require a "factory" to allocate such data, because trees
1602 -- are created automatically when parsing aggregate projects.
1604 procedure Free (Tree : in out Project_Tree_Appdata);
1605 -- Should be overridden if your derive your own data
1607 type Project_Tree_Data (Is_Root_Tree : Boolean := True) is record
1608 -- The root tree is the one loaded by the user from the command line.
1609 -- Is_Root_Tree is only false for projects aggregated within a root
1610 -- aggregate project.
1612 Projects : Project_List;
1613 -- List of projects in this tree
1615 Replaced_Sources : Replaced_Source_HTable.Instance;
1616 -- The list of sources that have been replaced by sources with
1617 -- different file names.
1619 Replaced_Source_Number : Natural := 0;
1620 -- The number of entries in Replaced_Sources
1622 Units_HT : Units_Htable.Instance;
1623 -- Unit name to Unit_Index (and from there to Source_Id)
1625 Source_Files_HT : Source_Files_Htable.Instance;
1626 -- Base source file names to Source_Id list
1628 Source_Paths_HT : Source_Paths_Htable.Instance;
1629 -- Full path to Source_Id
1630 -- ??? What is behavior for multi-unit source files, where there are
1631 -- several source_id per file ?
1633 Source_Info_File_Name : String_Access := null;
1634 -- The name of the source info file, if specified by the builder
1636 Source_Info_File_Exists : Boolean := False;
1637 -- True when a source info file has been successfully read
1639 Shared : Shared_Project_Tree_Data_Access;
1640 -- The shared data for this tree and all aggregated trees
1642 Appdata : Project_Tree_Appdata_Access;
1643 -- Application-specific data for this tree
1645 case Is_Root_Tree is
1646 when True =>
1647 Shared_Data : aliased Shared_Project_Tree_Data;
1648 -- Do not access directly, only through Shared
1650 when False =>
1651 null;
1652 end case;
1653 end record;
1654 -- Data for a project tree
1656 function Debug_Name (Tree : Project_Tree_Ref) return Name_Id;
1657 -- If debug traces are activated, return an identitier for the project
1658 -- tree. This modifies Name_Buffer.
1660 procedure Expect (The_Token : Token_Type; Token_Image : String);
1661 -- Check that the current token is The_Token. If it is not, then output
1662 -- an error message.
1664 procedure Initialize (Tree : Project_Tree_Ref);
1665 -- This procedure must be called before using any services from the Prj
1666 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
1668 procedure Reset (Tree : Project_Tree_Ref);
1669 -- This procedure resets all the tables that are used when processing a
1670 -- project file tree. Initialize must be called before the call to Reset.
1672 package Project_Boolean_Htable is new Simple_HTable
1673 (Header_Num => Header_Num,
1674 Element => Boolean,
1675 No_Element => False,
1676 Key => Project_Id,
1677 Hash => Hash,
1678 Equal => "=");
1679 -- A table that associates a project to a boolean. This is used to detect
1680 -- whether a project was already processed for instance.
1682 generic
1683 with procedure Action (Project : Project_Id; Tree : Project_Tree_Ref);
1684 procedure For_Project_And_Aggregated
1685 (Root_Project : Project_Id;
1686 Root_Tree : Project_Tree_Ref);
1687 -- Execute Action for Root_Project and all its aggregated projects
1688 -- recursively.
1690 generic
1691 type State is limited private;
1692 with procedure Action
1693 (Project : Project_Id;
1694 Tree : Project_Tree_Ref;
1695 With_State : in out State);
1696 procedure For_Every_Project_Imported
1697 (By : Project_Id;
1698 Tree : Project_Tree_Ref;
1699 With_State : in out State;
1700 Include_Aggregated : Boolean := True;
1701 Imported_First : Boolean := False);
1702 -- Call Action for each project imported directly or indirectly by project
1703 -- By, as well as extended projects.
1705 -- The order of processing depends on Imported_First:
1707 -- If False, Action is called according to the order of importation: if A
1708 -- imports B, directly or indirectly, Action will be called for A before
1709 -- it is called for B. If two projects import each other directly or
1710 -- indirectly (using at least one "limited with"), it is not specified
1711 -- for which of these two projects Action will be called first.
1713 -- The order is reversed if Imported_First is True
1715 -- With_State may be used by Action to choose a behavior or to report some
1716 -- global result.
1718 -- If Include_Aggregated is True, then an aggregate project will recurse
1719 -- into the projects it aggregates. Otherwise, the latter are never
1720 -- returned.
1722 -- In_Aggregate_Lib is True if the project is in an aggregate library
1724 -- The Tree argument passed to the callback is required in the case of
1725 -- aggregated projects, since they might not be using the same tree as 'By'
1727 type Project_Context is record
1728 In_Aggregate_Lib : Boolean;
1729 -- True if the project is part of an aggregate library
1731 From_Encapsulated_Lib : Boolean;
1732 -- True if the project is imported from an encapsulated library
1733 end record;
1735 generic
1736 type State is limited private;
1737 with procedure Action
1738 (Project : Project_Id;
1739 Tree : Project_Tree_Ref;
1740 Context : Project_Context;
1741 With_State : in out State);
1742 procedure For_Every_Project_Imported_Context
1743 (By : Project_Id;
1744 Tree : Project_Tree_Ref;
1745 With_State : in out State;
1746 Include_Aggregated : Boolean := True;
1747 Imported_First : Boolean := False);
1748 -- As for For_Every_Project_Imported but with an associated context
1750 generic
1751 with procedure Action
1752 (Project : Project_Id;
1753 Tree : Project_Tree_Ref;
1754 Context : Project_Context);
1755 procedure For_Project_And_Aggregated_Context
1756 (Root_Project : Project_Id;
1757 Root_Tree : Project_Tree_Ref);
1758 -- As for For_Project_And_Aggregated but with an associated context
1760 function Extend_Name
1761 (File : File_Name_Type;
1762 With_Suffix : String) return File_Name_Type;
1763 -- Replace the extension of File with With_Suffix
1765 function Object_Name
1766 (Source_File_Name : File_Name_Type;
1767 Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
1768 -- Returns the object file name corresponding to a source file name
1770 function Object_Name
1771 (Source_File_Name : File_Name_Type;
1772 Source_Index : Int;
1773 Index_Separator : Character;
1774 Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
1775 -- Returns the object file name corresponding to a unit in a multi-source
1776 -- file.
1778 function Dependency_Name
1779 (Source_File_Name : File_Name_Type;
1780 Dependency : Dependency_File_Kind) return File_Name_Type;
1781 -- Returns the dependency file name corresponding to a source file name
1783 function Switches_Name
1784 (Source_File_Name : File_Name_Type) return File_Name_Type;
1785 -- Returns the switches file name corresponding to a source file name
1787 procedure Set_Path_File_Var (Name : String; Value : String);
1788 -- Call Setenv, after calling To_Host_File_Spec
1790 function Current_Source_Path_File_Of
1791 (Shared : Shared_Project_Tree_Data_Access) return Path_Name_Type;
1792 -- Get the current include path file name
1794 procedure Set_Current_Source_Path_File_Of
1795 (Shared : Shared_Project_Tree_Data_Access;
1796 To : Path_Name_Type);
1797 -- Record the current include path file name
1799 function Current_Object_Path_File_Of
1800 (Shared : Shared_Project_Tree_Data_Access) return Path_Name_Type;
1801 -- Get the current object path file name
1803 procedure Set_Current_Object_Path_File_Of
1804 (Shared : Shared_Project_Tree_Data_Access;
1805 To : Path_Name_Type);
1806 -- Record the current object path file name
1808 -----------
1809 -- Flags --
1810 -----------
1812 type Processing_Flags is private;
1813 -- Flags used while parsing and processing a project tree to configure the
1814 -- behavior of the parser, and indicate how to report error messages. This
1815 -- structure does not allocate memory and never needs to be freed
1817 type Error_Warning is (Silent, Warning, Error);
1818 -- Severity of some situations, such as: no Ada sources in a project where
1819 -- Ada is one of the language.
1821 -- When the situation occurs, the behaviour depends on the setting:
1823 -- - Silent: no action
1824 -- - Warning: issue a warning, does not cause the tool to fail
1825 -- - Error: issue an error, causes the tool to fail
1827 type Error_Handler is access procedure
1828 (Project : Project_Id;
1829 Is_Warning : Boolean);
1830 -- This warns when an error was found when parsing a project. The error
1831 -- itself is handled through Prj.Err (and Prj.Err.Finalize should be called
1832 -- to actually print the error). This ensures that duplicate error messages
1833 -- are always correctly removed, that errors msgs are sorted, and that all
1834 -- tools will report the same error to the user.
1836 function Create_Flags
1837 (Report_Error : Error_Handler;
1838 When_No_Sources : Error_Warning;
1839 Require_Sources_Other_Lang : Boolean := True;
1840 Allow_Duplicate_Basenames : Boolean := True;
1841 Compiler_Driver_Mandatory : Boolean := False;
1842 Error_On_Unknown_Language : Boolean := True;
1843 Require_Obj_Dirs : Error_Warning := Error;
1844 Allow_Invalid_External : Error_Warning := Error;
1845 Missing_Source_Files : Error_Warning := Error;
1846 Ignore_Missing_With : Boolean := False)
1847 return Processing_Flags;
1848 -- Function used to create Processing_Flags structure
1850 -- If Allow_Duplicate_Basenames, then files with the same base names are
1851 -- authorized within a project for source-based languages (never for unit
1852 -- based languages).
1854 -- If Compiler_Driver_Mandatory is true, then a Compiler.Driver attribute
1855 -- for each language must be defined, or we will not look for its source
1856 -- files.
1858 -- When_No_Sources indicates what should be done when no sources of a
1859 -- language are found in a project where this language is declared.
1860 -- If Require_Sources_Other_Lang is true, then all languages must have at
1861 -- least one source file, or an error is reported via When_No_Sources. If
1862 -- it is false, this is only required for Ada (and only if it is a language
1863 -- of the project). When this parameter is set to False, we do not check
1864 -- that a proper naming scheme is defined for languages other than Ada.
1866 -- If Report_Error is null, use the standard error reporting mechanism
1867 -- (Errout). Otherwise, report errors using Report_Error.
1869 -- If Error_On_Unknown_Language is true, an error is displayed if some of
1870 -- the source files listed in the project do not match any naming scheme
1872 -- If Require_Obj_Dirs is true, then all object directories must exist
1873 -- (possibly after they have been created automatically if the appropriate
1874 -- switches were specified), or an error is raised.
1876 -- If Allow_Invalid_External is Silent, then no error is reported when an
1877 -- invalid value is used for an external variable (and it doesn't match its
1878 -- type). Instead, the first possible value is used.
1880 -- Missing_Source_Files indicates whether it is an error or a warning that
1881 -- a source file mentioned in the Source_Files attributes is not actually
1882 -- found in the source directories. This also impacts errors for missing
1883 -- source directories.
1885 -- If Ignore_Missing_With is True, then a "with" statement that cannot be
1886 -- resolved will simply be ignored. However, in such a case, the flag
1887 -- Incomplete_With in the project tree will be set to True.
1888 -- This is meant for use by tools so that they can properly set the
1889 -- project path in such a case:
1890 -- * no "gnatls" found (so no default project path)
1891 -- * user project sets Project.IDE'gnatls attribute to a cross gnatls
1892 -- * user project also includes a "with" that can only be resolved
1893 -- once we have found the gnatls
1895 Gprbuild_Flags : constant Processing_Flags;
1896 Gprinstall_Flags : constant Processing_Flags;
1897 Gprclean_Flags : constant Processing_Flags;
1898 Gprexec_Flags : constant Processing_Flags;
1899 Gnatmake_Flags : constant Processing_Flags;
1900 -- Flags used by the various tools. They all display the error messages
1901 -- through Prj.Err.
1903 ----------------
1904 -- Temp Files --
1905 ----------------
1907 procedure Record_Temp_File
1908 (Shared : Shared_Project_Tree_Data_Access;
1909 Path : Path_Name_Type);
1910 -- Record the path of a newly created temporary file, so that it can be
1911 -- deleted later.
1913 procedure Delete_All_Temp_Files
1914 (Shared : Shared_Project_Tree_Data_Access);
1915 -- Delete all recorded temporary files.
1916 -- Does nothing if Debug.Debug_Flag_N is set
1918 procedure Delete_Temp_Config_Files (Project_Tree : Project_Tree_Ref);
1919 -- Delete all temporary config files. Does nothing if Debug.Debug_Flag_N is
1920 -- set or if Project_Tree is null. This initially came from gnatmake
1921 -- ??? Should this be combined with Delete_All_Temp_Files above
1923 procedure Delete_Temporary_File
1924 (Shared : Shared_Project_Tree_Data_Access := null;
1925 Path : Path_Name_Type);
1926 -- Delete a temporary file from the disk. The file is also removed from the
1927 -- list of temporary files to delete at the end of the program, in case
1928 -- another program running on the same machine has recreated it. Does
1929 -- nothing if Debug.Debug_Flag_N is set
1931 Virtual_Prefix : constant String := "v$";
1932 -- The prefix for virtual extending projects. Because of the '$', which is
1933 -- normally forbidden for project names, there cannot be any name clash.
1935 -----------
1936 -- Debug --
1937 -----------
1939 type Verbosity is (Default, Medium, High);
1940 pragma Ordered (Verbosity);
1941 -- Verbosity when parsing GNAT Project Files
1942 -- Default is default (very quiet, if no errors).
1943 -- Medium is more verbose.
1944 -- High is extremely verbose.
1946 Current_Verbosity : Verbosity := Default;
1947 -- The current value of the verbosity the project files are parsed with
1949 procedure Debug_Indent;
1950 -- Inserts a series of blanks depending on the current indentation level
1952 procedure Debug_Output (Str : String);
1953 procedure Debug_Output (Str : String; Str2 : Name_Id);
1954 -- If Current_Verbosity is not Default, outputs Str.
1955 -- This indents Str based on the current indentation level for traces
1956 -- Debug_Error is intended to be used to report an error in the traces.
1958 procedure Debug_Increase_Indent
1959 (Str : String := ""; Str2 : Name_Id := No_Name);
1960 procedure Debug_Decrease_Indent (Str : String := "");
1961 -- Increase or decrease the indentation level for debug traces. This
1962 -- indentation level only affects output done through Debug_Output.
1964 private
1965 All_Packages : constant String_List_Access := null;
1967 No_Project_Tree : constant Project_Tree_Ref := null;
1969 Ignored : constant Variable_Kind := Single;
1971 Nil_Variable_Value : constant Variable_Value :=
1972 (Project => No_Project,
1973 Kind => Undefined,
1974 Location => No_Location,
1975 Default => False);
1977 type Source_Iterator is record
1978 In_Tree : Project_Tree_Ref;
1980 Project : Project_List;
1981 All_Projects : Boolean;
1982 -- Current project and whether we should move on to the next
1984 Language : Language_Ptr;
1985 -- Current language processed
1987 Language_Name : Name_Id;
1988 -- Only sources of this language will be returned (or all if No_Name)
1990 Current : Source_Id;
1992 Encapsulated_Libs : Boolean;
1993 -- True if we want to include the sources from encapsulated libs
1995 Locally_Removed : Boolean;
1996 end record;
1998 procedure Add_To_Buffer
1999 (S : String;
2000 To : in out String_Access;
2001 Last : in out Natural);
2002 -- Append a String to the Buffer
2004 -- Table used to store the path name of all the created temporary files, so
2005 -- that they can be deleted at the end, or when the program is interrupted.
2007 package Temp_Files_Table is new GNAT.Dynamic_Tables
2008 (Table_Component_Type => Path_Name_Type,
2009 Table_Index_Type => Integer,
2010 Table_Low_Bound => 1,
2011 Table_Initial => 10,
2012 Table_Increment => 10);
2014 -- The following type is used to represent the part of a project tree which
2015 -- is private to the Project Manager.
2017 type Private_Project_Tree_Data is record
2018 Temp_Files : Temp_Files_Table.Instance;
2019 -- Temporary files created as part of running tools (pragma files,
2020 -- mapping files,...)
2022 Current_Source_Path_File : Path_Name_Type := No_Path;
2023 -- Current value of project source path file env var. Used to avoid
2024 -- setting the env var to the same value. When different from No_Path,
2025 -- this indicates that environment variables were created and should be
2026 -- deassigned to avoid polluting the environment. For gnatmake only.
2028 Current_Object_Path_File : Path_Name_Type := No_Path;
2029 -- Current value of project object path file env var. Used to avoid
2030 -- setting the env var to the same value.
2031 -- gnatmake only
2032 end record;
2034 -- The following type is used to hold processing flags which show what
2035 -- functions are required for the various tools that are handled.
2037 type Processing_Flags is record
2038 Require_Sources_Other_Lang : Boolean;
2039 Report_Error : Error_Handler;
2040 When_No_Sources : Error_Warning;
2041 Allow_Duplicate_Basenames : Boolean;
2042 Compiler_Driver_Mandatory : Boolean;
2043 Error_On_Unknown_Language : Boolean;
2044 Require_Obj_Dirs : Error_Warning;
2045 Allow_Invalid_External : Error_Warning;
2046 Missing_Source_Files : Error_Warning;
2047 Ignore_Missing_With : Boolean;
2048 end record;
2050 Gprbuild_Flags : constant Processing_Flags :=
2051 (Report_Error => null,
2052 When_No_Sources => Warning,
2053 Require_Sources_Other_Lang => True,
2054 Allow_Duplicate_Basenames => False,
2055 Compiler_Driver_Mandatory => True,
2056 Error_On_Unknown_Language => True,
2057 Require_Obj_Dirs => Error,
2058 Allow_Invalid_External => Error,
2059 Missing_Source_Files => Error,
2060 Ignore_Missing_With => False);
2062 Gprinstall_Flags : constant Processing_Flags :=
2063 (Report_Error => null,
2064 When_No_Sources => Warning,
2065 Require_Sources_Other_Lang => True,
2066 Allow_Duplicate_Basenames => False,
2067 Compiler_Driver_Mandatory => True,
2068 Error_On_Unknown_Language => True,
2069 Require_Obj_Dirs => Silent,
2070 Allow_Invalid_External => Error,
2071 Missing_Source_Files => Error,
2072 Ignore_Missing_With => False);
2074 Gprclean_Flags : constant Processing_Flags :=
2075 (Report_Error => null,
2076 When_No_Sources => Warning,
2077 Require_Sources_Other_Lang => True,
2078 Allow_Duplicate_Basenames => False,
2079 Compiler_Driver_Mandatory => True,
2080 Error_On_Unknown_Language => True,
2081 Require_Obj_Dirs => Warning,
2082 Allow_Invalid_External => Error,
2083 Missing_Source_Files => Error,
2084 Ignore_Missing_With => False);
2086 Gprexec_Flags : constant Processing_Flags :=
2087 (Report_Error => null,
2088 When_No_Sources => Silent,
2089 Require_Sources_Other_Lang => False,
2090 Allow_Duplicate_Basenames => False,
2091 Compiler_Driver_Mandatory => False,
2092 Error_On_Unknown_Language => True,
2093 Require_Obj_Dirs => Silent,
2094 Allow_Invalid_External => Error,
2095 Missing_Source_Files => Silent,
2096 Ignore_Missing_With => False);
2098 Gnatmake_Flags : constant Processing_Flags :=
2099 (Report_Error => null,
2100 When_No_Sources => Error,
2101 Require_Sources_Other_Lang => False,
2102 Allow_Duplicate_Basenames => False,
2103 Compiler_Driver_Mandatory => False,
2104 Error_On_Unknown_Language => False,
2105 Require_Obj_Dirs => Error,
2106 Allow_Invalid_External => Error,
2107 Missing_Source_Files => Error,
2108 Ignore_Missing_With => False);
2110 end Prj;