1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2005, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- The following package declares the data types for GNAT project.
28 -- These data types may be used by GNAT Project-aware tools.
30 -- Children of these package implements various services on these data types.
31 -- See in particular Prj.Pars and Prj.Env.
33 with Casing; use Casing;
34 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;
46 All_Packages : constant String_List_Access;
47 -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
48 -- Prj.Part, indicating that all packages should be checked.
50 type Project_Tree_Data;
51 type Project_Tree_Ref is access all Project_Tree_Data;
52 -- Reference to a project tree.
53 -- Several project trees may exist in memory at the same time.
55 No_Project_Tree : constant Project_Tree_Ref;
57 function Default_Ada_Spec_Suffix return Name_Id;
58 pragma Inline (Default_Ada_Spec_Suffix);
59 -- The Name_Id for the standard GNAT suffix for Ada spec source file
60 -- name ".ads". Initialized by Prj.Initialize.
62 function Default_Ada_Body_Suffix return Name_Id;
63 pragma Inline (Default_Ada_Body_Suffix);
64 -- The Name_Id for the standard GNAT suffix for Ada body source file
65 -- name ".adb". Initialized by Prj.Initialize.
67 function Slash return Name_Id;
68 pragma Inline (Slash);
69 -- "/", used as the path of locally removed files
71 Project_File_Extension : String := ".gpr";
72 -- The standard project file name extension. It is not a constant, because
73 -- Canonical_Case_File_Name is called on this variable in the body of Prj.
75 -----------------------------------------------------
76 -- Multi-language Stuff That Will be Modified Soon --
77 -----------------------------------------------------
79 -- Still should be properly commented ???
81 type Language_Index is new Nat;
83 No_Language_Index : constant Language_Index := 0;
84 First_Language_Index : constant Language_Index := 1;
85 First_Language_Indexes_Last : constant Language_Index := 5;
87 Ada_Language_Index : constant Language_Index :=
89 C_Language_Index : constant Language_Index :=
90 Ada_Language_Index + 1;
91 C_Plus_Plus_Language_Index : constant Language_Index :=
94 Last_Language_Index : Language_Index := No_Language_Index;
96 subtype First_Language_Indexes is Language_Index
97 range First_Language_Index .. First_Language_Indexes_Last;
99 type Header_Num is range 0 .. 2047;
101 function Hash is new System.HTable.Hash (Header_Num => Header_Num);
103 function Hash (Name : Name_Id) return Header_Num;
105 package Language_Indexes is new System.HTable.Simple_HTable
106 (Header_Num => Header_Num,
107 Element => Language_Index,
108 No_Element => No_Language_Index,
112 -- Mapping of language names to language indexes
114 package Language_Names is new Table.Table
115 (Table_Component_Type => Name_Id,
116 Table_Index_Type => Language_Index,
117 Table_Low_Bound => 1,
119 Table_Increment => 100,
120 Table_Name => "Prj.Language_Names");
121 -- The table for the name of programming languages
123 procedure Add_Language_Name (Name : Name_Id);
125 procedure Display_Language_Name (Language : Language_Index);
127 type Languages_In_Project is array (First_Language_Indexes) of Boolean;
128 -- Set of supported languages used in a project
130 No_Languages : constant Languages_In_Project := (others => False);
131 -- No supported languages are used
133 type Supp_Language_Index is new Nat;
134 No_Supp_Language_Index : constant Supp_Language_Index := 0;
136 type Supp_Language is record
137 Index : Language_Index := No_Language_Index;
138 Present : Boolean := False;
139 Next : Supp_Language_Index := No_Supp_Language_Index;
142 package Present_Language_Table is new GNAT.Dynamic_Tables
143 (Table_Component_Type => Supp_Language,
144 Table_Index_Type => Supp_Language_Index,
145 Table_Low_Bound => 1,
147 Table_Increment => 100);
148 -- The table for the presence of languages with an index that is outside
149 -- of First_Language_Indexes.
151 type Impl_Suffix_Array is array (First_Language_Indexes) of Name_Id;
152 -- Suffixes for the non spec sources of the different supported languages
155 No_Impl_Suffixes : constant Impl_Suffix_Array := (others => No_Name);
156 -- A default value for the non spec source suffixes
158 type Supp_Suffix is record
159 Index : Language_Index := No_Language_Index;
160 Suffix : Name_Id := No_Name;
161 Next : Supp_Language_Index := No_Supp_Language_Index;
164 package Supp_Suffix_Table is new GNAT.Dynamic_Tables
165 (Table_Component_Type => Supp_Suffix,
166 Table_Index_Type => Supp_Language_Index,
167 Table_Low_Bound => 1,
169 Table_Increment => 100);
170 -- The table for the presence of languages with an index that is outside
171 -- of First_Language_Indexes.
173 type Language_Kind is (GNU, other);
175 type Name_List_Index is new Nat;
176 No_Name_List : constant Name_List_Index := 0;
178 type Name_Node is record
179 Name : Name_Id := No_Name;
180 Next : Name_List_Index := No_Name_List;
183 package Name_List_Table is new GNAT.Dynamic_Tables
184 (Table_Component_Type => Name_Node,
185 Table_Index_Type => Name_List_Index,
186 Table_Low_Bound => 1,
188 Table_Increment => 100);
189 -- The table for lists of names used in package Language_Processing
191 type Language_Processing_Data is record
192 Compiler_Drivers : Name_List_Index := No_Name_List;
193 Compiler_Paths : Name_Id := No_Name;
194 Compiler_Kinds : Language_Kind := GNU;
195 Dependency_Options : Name_List_Index := No_Name_List;
196 Compute_Dependencies : Name_List_Index := No_Name_List;
197 Include_Options : Name_List_Index := No_Name_List;
198 Binder_Drivers : Name_Id := No_Name;
199 Binder_Driver_Paths : Name_Id := No_Name;
202 Default_Language_Processing_Data :
203 constant Language_Processing_Data :=
204 (Compiler_Drivers => No_Name_List,
205 Compiler_Paths => No_Name,
206 Compiler_Kinds => GNU,
207 Dependency_Options => No_Name_List,
208 Compute_Dependencies => No_Name_List,
209 Include_Options => No_Name_List,
210 Binder_Drivers => No_Name,
211 Binder_Driver_Paths => No_Name);
213 type First_Language_Processing_Data is
214 array (First_Language_Indexes) of Language_Processing_Data;
216 Default_First_Language_Processing_Data :
217 constant First_Language_Processing_Data :=
218 (others => Default_Language_Processing_Data);
220 type Supp_Language_Data is record
221 Index : Language_Index := No_Language_Index;
222 Data : Language_Processing_Data := Default_Language_Processing_Data;
223 Next : Supp_Language_Index := No_Supp_Language_Index;
226 package Supp_Language_Table is new GNAT.Dynamic_Tables
227 (Table_Component_Type => Supp_Language_Data,
228 Table_Index_Type => Supp_Language_Index,
229 Table_Low_Bound => 1,
231 Table_Increment => 100);
232 -- The table for language data when there are more languages than
233 -- in First_Language_Indexes.
235 type Other_Source_Id is new Nat;
236 No_Other_Source : constant Other_Source_Id := 0;
238 type Other_Source is record
239 Language : Language_Index; -- language of the source
240 File_Name : Name_Id; -- source file simple name
241 Path_Name : Name_Id; -- source full path name
242 Source_TS : Time_Stamp_Type; -- source file time stamp
243 Object_Name : Name_Id; -- object file simple name
244 Object_Path : Name_Id; -- object full path name
245 Object_TS : Time_Stamp_Type; -- object file time stamp
246 Dep_Name : Name_Id; -- dependency file simple name
247 Dep_Path : Name_Id; -- dependency full path name
248 Dep_TS : Time_Stamp_Type; -- dependency file time stamp
249 Naming_Exception : Boolean := False; -- True if a naming exception
250 Next : Other_Source_Id := No_Other_Source;
252 -- Data for a source in a language other than Ada
254 package Other_Source_Table is new GNAT.Dynamic_Tables
255 (Table_Component_Type => Other_Source,
256 Table_Index_Type => Other_Source_Id,
257 Table_Low_Bound => 1,
258 Table_Initial => 200,
259 Table_Increment => 100);
260 -- The table for sources of languages other than Ada
262 ----------------------------------
263 -- End of multi-language stuff --
264 ----------------------------------
266 type Verbosity is (Default, Medium, High);
267 -- Verbosity when parsing GNAT Project Files
268 -- Default is default (very quiet, if no errors).
269 -- Medium is more verbose.
270 -- High is extremely verbose.
272 Current_Verbosity : Verbosity := Default;
273 -- The current value of the verbosity the project files are parsed with
275 type Lib_Kind is (Static, Dynamic, Relocatable);
276 type Policy is (Autonomous, Compliant, Controlled, Restricted);
277 -- Type to specify the symbol policy, when symbol control is supported.
278 -- See full explanation about this type in package Symbols.
279 -- Autonomous: Create a symbol file without considering any reference
280 -- Compliant: Try to be as compatible as possible with an existing ref
281 -- Controlled: Fail if symbols are not the same as those in the reference
282 -- Restricted: Restrict the symbols to those in the symbol file
284 type Symbol_Record is record
285 Symbol_File : Name_Id := No_Name;
286 Reference : Name_Id := No_Name;
287 Symbol_Policy : Policy := Autonomous;
289 -- Type to keep the symbol data to be used when building a shared library
291 No_Symbols : constant Symbol_Record :=
292 (Symbol_File => No_Name,
293 Reference => No_Name,
294 Symbol_Policy => Autonomous);
295 -- The default value of the symbol data
297 function Empty_String return Name_Id;
298 -- Return the Name_Id for an empty string ""
300 type Project_Id is new Nat;
301 No_Project : constant Project_Id := 0;
302 -- Id of a Project File
304 type String_List_Id is new Nat;
305 Nil_String : constant String_List_Id := 0;
306 type String_Element is record
307 Value : Name_Id := No_Name;
309 Display_Value : Name_Id := No_Name;
310 Location : Source_Ptr := No_Location;
311 Flag : Boolean := False;
312 Next : String_List_Id := Nil_String;
314 -- To hold values for string list variables and array elements.
315 -- Component Flag may be used for various purposes. For source
316 -- directories, it indicates if the directory contains Ada source(s).
318 package String_Element_Table is new GNAT.Dynamic_Tables
319 (Table_Component_Type => String_Element,
320 Table_Index_Type => String_List_Id,
321 Table_Low_Bound => 1,
322 Table_Initial => 200,
323 Table_Increment => 100);
324 -- The table for string elements in string lists
326 type Variable_Kind is (Undefined, List, Single);
327 -- Different kinds of variables
329 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
330 -- The defined kinds of variables
332 Ignored : constant Variable_Kind;
333 -- Used to indicate that a package declaration must be ignored
334 -- while processing the project tree (unknown package name).
336 type Variable_Value (Kind : Variable_Kind := Undefined) is record
337 Project : Project_Id := No_Project;
338 Location : Source_Ptr := No_Location;
339 Default : Boolean := False;
344 Values : String_List_Id := Nil_String;
346 Value : Name_Id := No_Name;
350 -- Values for variables and array elements. Default is True if the
351 -- current value is the default one for the variable
353 Nil_Variable_Value : constant Variable_Value;
354 -- Value of a non existing variable or array element
356 type Variable_Id is new Nat;
357 No_Variable : constant Variable_Id := 0;
358 type Variable is record
359 Next : Variable_Id := No_Variable;
361 Value : Variable_Value;
363 -- To hold the list of variables in a project file and in packages
365 package Variable_Element_Table is new GNAT.Dynamic_Tables
366 (Table_Component_Type => Variable,
367 Table_Index_Type => Variable_Id,
368 Table_Low_Bound => 1,
369 Table_Initial => 200,
370 Table_Increment => 100);
371 -- The table of variable in list of variables
373 type Array_Element_Id is new Nat;
374 No_Array_Element : constant Array_Element_Id := 0;
375 type Array_Element is record
377 Src_Index : Int := 0;
378 Index_Case_Sensitive : Boolean := True;
379 Value : Variable_Value;
380 Next : Array_Element_Id := No_Array_Element;
382 -- Each Array_Element represents an array element and is linked (Next)
383 -- to the next array element, if any, in the array.
385 package Array_Element_Table is new GNAT.Dynamic_Tables
386 (Table_Component_Type => Array_Element,
387 Table_Index_Type => Array_Element_Id,
388 Table_Low_Bound => 1,
389 Table_Initial => 200,
390 Table_Increment => 100);
391 -- The table that contains all array elements
393 type Array_Id is new Nat;
394 No_Array : constant Array_Id := 0;
395 type Array_Data is record
396 Name : Name_Id := No_Name;
397 Value : Array_Element_Id := No_Array_Element;
398 Next : Array_Id := No_Array;
400 -- Each Array_Data value represents an array.
401 -- Value is the id of the first element.
402 -- Next is the id of the next array in the project file or package.
404 package Array_Table is new GNAT.Dynamic_Tables
405 (Table_Component_Type => Array_Data,
406 Table_Index_Type => Array_Id,
407 Table_Low_Bound => 1,
408 Table_Initial => 200,
409 Table_Increment => 100);
410 -- The table that contains all arrays
412 type Package_Id is new Nat;
413 No_Package : constant Package_Id := 0;
414 type Declarations is record
415 Variables : Variable_Id := No_Variable;
416 Attributes : Variable_Id := No_Variable;
417 Arrays : Array_Id := No_Array;
418 Packages : Package_Id := No_Package;
420 -- Contains the declarations (variables, single and array attributes,
421 -- packages) for a project or a package in a project.
423 No_Declarations : constant Declarations :=
424 (Variables => No_Variable,
425 Attributes => No_Variable,
427 Packages => No_Package);
428 -- Default value of Declarations: indicates that there is no declarations
430 type Package_Element is record
431 Name : Name_Id := No_Name;
432 Decl : Declarations := No_Declarations;
433 Parent : Package_Id := No_Package;
434 Next : Package_Id := No_Package;
436 -- A package (includes declarations that may include other packages)
438 package Package_Table is new GNAT.Dynamic_Tables
439 (Table_Component_Type => Package_Element,
440 Table_Index_Type => Package_Id,
441 Table_Low_Bound => 1,
442 Table_Initial => 100,
443 Table_Increment => 100);
444 -- The table that contains all packages
446 function Image (Casing : Casing_Type) return String;
447 -- Similar to 'Image (but avoid use of this attribute in compiler)
449 function Value (Image : String) return Casing_Type;
450 -- Similar to 'Value (but avoid use of this attribute in compiler)
451 -- Raises Constraint_Error if not a Casing_Type image.
453 -- The following record contains data for a naming scheme
455 type Naming_Data is record
457 Dot_Replacement : Name_Id := No_Name;
458 -- The string to replace '.' in the source file name (for Ada)
460 Dot_Repl_Loc : Source_Ptr := No_Location;
461 -- The position in the project file source where Dot_Replacement is
464 Casing : Casing_Type := All_Lower_Case;
465 -- The casing of the source file name (for Ada)
467 Spec_Suffix : Array_Element_Id := No_Array_Element;
468 -- The string to append to the unit name for the
469 -- source file name of a spec.
470 -- Indexed by the programming language.
472 Ada_Spec_Suffix : Name_Id := No_Name;
473 -- The suffix of the Ada spec sources
475 Spec_Suffix_Loc : Source_Ptr := No_Location;
476 -- The position in the project file source where
477 -- Ada_Spec_Suffix is defined.
479 Impl_Suffixes : Impl_Suffix_Array := No_Impl_Suffixes;
480 Supp_Suffixes : Supp_Language_Index := No_Supp_Language_Index;
481 -- The source suffixes of the different languages
483 Body_Suffix : Array_Element_Id := No_Array_Element;
484 -- The string to append to the unit name for the
485 -- source file name of a body.
486 -- Indexed by the programming language.
488 Ada_Body_Suffix : Name_Id := No_Name;
489 -- The suffix of the Ada body sources
491 Body_Suffix_Loc : Source_Ptr := No_Location;
492 -- The position in the project file source where
493 -- Ada_Body_Suffix is defined.
495 Separate_Suffix : Name_Id := No_Name;
496 -- String to append to unit name for source file name of an Ada subunit
498 Sep_Suffix_Loc : Source_Ptr := No_Location;
499 -- Position in the project file source where Separate_Suffix is defined
501 Specs : Array_Element_Id := No_Array_Element;
502 -- An associative array mapping individual specs to source file names
503 -- This is specific to Ada.
505 Bodies : Array_Element_Id := No_Array_Element;
506 -- An associative array mapping individual bodies to source file names
507 -- This is specific to Ada.
509 Specification_Exceptions : Array_Element_Id := No_Array_Element;
510 -- An associative array listing spec file names that do not have the
511 -- spec suffix. Not used by Ada. Indexed by programming language name.
513 Implementation_Exceptions : Array_Element_Id := No_Array_Element;
514 -- An associative array listing body file names that do not have the
515 -- body suffix. Not used by Ada. Indexed by programming language name.
519 function Standard_Naming_Data
520 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
521 pragma Inline (Standard_Naming_Data);
522 -- The standard GNAT naming scheme when Tree is No_Project_Tree.
523 -- Otherwise, return the default naming scheme for the project tree Tree,
524 -- which must have been Initialized.
526 function Same_Naming_Scheme
527 (Left, Right : Naming_Data) return Boolean;
528 -- Returns True if Left and Right are the same naming scheme
529 -- not considering Specs and Bodies.
531 type Project_List is new Nat;
532 Empty_Project_List : constant Project_List := 0;
533 -- A list of project files
535 type Project_Element is record
536 Project : Project_Id := No_Project;
537 Next : Project_List := Empty_Project_List;
539 -- Element in a list of project files. Next is the id of the next
540 -- project file in the list.
542 package Project_List_Table is new GNAT.Dynamic_Tables
543 (Table_Component_Type => Project_Element,
544 Table_Index_Type => Project_List,
545 Table_Low_Bound => 1,
546 Table_Initial => 100,
547 Table_Increment => 100);
548 -- The table that contains the lists of project files
550 -- The following record describes a project file representation
552 type Project_Data is record
553 Externally_Built : Boolean := False;
555 Languages : Languages_In_Project := No_Languages;
556 Supp_Languages : Supp_Language_Index := No_Supp_Language_Index;
557 -- Indicate the different languages of the source of this project
559 First_Referred_By : Project_Id := No_Project;
560 -- The project, if any, that was the first to be known as importing or
561 -- extending this project. Set by Prj.Proc.Process.
563 Name : Name_Id := No_Name;
564 -- The name of the project. Set by Prj.Proc.Process
566 Display_Name : Name_Id := No_Name;
567 -- The name of the project with the spelling of its declaration.
568 -- Set by Prj.Proc.Process.
570 Path_Name : Name_Id := No_Name;
571 -- The path name of the project file. Set by Prj.Proc.Process
573 Display_Path_Name : Name_Id := No_Name;
574 -- The path name used for display purposes. May be different from
575 -- Path_Name for platforms where the file names are case-insensitive.
577 Virtual : Boolean := False;
578 -- True for virtual extending projects
580 Location : Source_Ptr := No_Location;
581 -- The location in the project file source of the reserved word
582 -- project. Set by Prj.Proc.Process.
584 Mains : String_List_Id := Nil_String;
585 -- List of mains specified by attribute Main. Set by Prj.Nmsc.Check
587 Directory : Name_Id := No_Name;
588 -- Directory where the project file resides. Set by Prj.Proc.Process
590 Display_Directory : Name_Id := No_Name;
593 Dir_Path : String_Access;
594 -- Same as Directory, but as an access to String. Set by
595 -- Make.Compile_Sources.Collect_Arguments_And_Compile.
597 Library : Boolean := False;
598 -- True if this is a library project. Set by
599 -- Prj.Nmsc.Language_Independent_Check.
601 Library_Dir : Name_Id := No_Name;
602 -- If a library project, directory where resides the library Set by
603 -- Prj.Nmsc.Language_Independent_Check.
605 Display_Library_Dir : Name_Id := No_Name;
606 -- The name of the library directory, for display purposes. May be
607 -- different from Library_Dir for platforms where the file names are
610 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
611 -- The timestamp of a library file in a library project.
612 -- Set by MLib.Prj.Check_Library.
614 Library_Src_Dir : Name_Id := No_Name;
615 -- If a Stand-Alone Library project, directory where the sources
616 -- of the interfaces of the library are copied. By default, if
617 -- attribute Library_Src_Dir is not specified, sources of the interfaces
618 -- are not copied anywhere. Set by Prj.Nmsc.Check_Stand_Alone_Library.
620 Display_Library_Src_Dir : Name_Id := No_Name;
621 -- The name of the library source directory, for display purposes.
622 -- May be different from Library_Src_Dir for platforms where the file
623 -- names are case-insensitive.
625 Library_ALI_Dir : Name_Id := No_Name;
626 -- In a library project, directory where the ALI files are copied.
627 -- If attribute Library_ALI_Dir is not specified, ALI files are
628 -- copied in the Library_Dir. Set by Prj.Nmsc.Check_Library_Attributes.
630 Display_Library_ALI_Dir : Name_Id := No_Name;
631 -- The name of the library ALI directory, for display purposes. May be
632 -- different from Library_ALI_Dir for platforms where the file names are
635 Library_Name : Name_Id := No_Name;
636 -- If a library project, name of the library
637 -- Set by Prj.Nmsc.Language_Independent_Check.
639 Library_Kind : Lib_Kind := Static;
640 -- If a library project, kind of library
641 -- Set by Prj.Nmsc.Language_Independent_Check.
643 Lib_Internal_Name : Name_Id := No_Name;
644 -- If a library project, internal name store inside the library Set by
645 -- Prj.Nmsc.Language_Independent_Check.
647 Standalone_Library : Boolean := False;
648 -- Indicate that this is a Standalone Library Project File. Set by
651 Lib_Interface_ALIs : String_List_Id := Nil_String;
652 -- For Standalone Library Project Files, indicate the list of Interface
653 -- ALI files. Set by Prj.Nmsc.Check.
655 Lib_Auto_Init : Boolean := False;
656 -- For non static Standalone Library Project Files, indicate if
657 -- the library initialisation should be automatic.
659 Symbol_Data : Symbol_Record := No_Symbols;
660 -- Symbol file name, reference symbol file name, symbol policy
662 Ada_Sources_Present : Boolean := True;
663 -- A flag that indicates if there are Ada sources in this project file.
664 -- There are no sources if any of the following is true:
665 -- 1) Source_Dirs is specified as an empty list
666 -- 2) Source_Files is specified as an empty list
667 -- 3) Ada is not in the list of the specified Languages
669 Other_Sources_Present : Boolean := True;
670 -- A flag that indicates that there are non-Ada sources in this project
672 Sources : String_List_Id := Nil_String;
673 -- The list of all the source file names.
674 -- Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
676 First_Other_Source : Other_Source_Id := No_Other_Source;
677 Last_Other_Source : Other_Source_Id := No_Other_Source;
678 -- Head and tail of the list of sources of languages other than Ada
680 Imported_Directories_Switches : Argument_List_Access := null;
681 -- List of the -I switches to be used when compiling sources of
682 -- languages other than Ada.
684 Include_Path : String_Access := null;
685 -- Value to be used as CPATH, when using a GCC, instead of a list of
688 Include_Data_Set : Boolean := False;
689 -- Set True when Imported_Directories_Switches or Include_Path are set
691 Source_Dirs : String_List_Id := Nil_String;
692 -- The list of all the source directories.
693 -- Set by Prj.Nmsc.Language_Independent_Check.
695 Known_Order_Of_Source_Dirs : Boolean := True;
696 -- False, if there is any /** in the Source_Dirs, because in this case
697 -- the ordering of the source subdirs depend on the OS. If True,
698 -- duplicate file names in the same project file are allowed.
700 Object_Directory : Name_Id := No_Name;
701 -- The object directory of this project file.
702 -- Set by Prj.Nmsc.Language_Independent_Check.
704 Display_Object_Dir : Name_Id := No_Name;
705 -- The name of the object directory, for display purposes.
706 -- May be different from Object_Directory for platforms where the file
707 -- names are case-insensitive.
709 Exec_Directory : Name_Id := No_Name;
710 -- The exec directory of this project file. Default is equal to
711 -- Object_Directory. Set by Prj.Nmsc.Language_Independent_Check.
713 Display_Exec_Dir : Name_Id := No_Name;
714 -- The name of the exec directory, for display purposes. May be
715 -- different from Exec_Directory for platforms where the file names are
718 Extends : Project_Id := No_Project;
719 -- The reference of the project file, if any, that this project file
720 -- extends. Set by Prj.Proc.Process.
722 Extended_By : Project_Id := No_Project;
723 -- The reference of the project file, if any, that extends this project
724 -- file. Set by Prj.Proc.Process.
726 Naming : Naming_Data := Standard_Naming_Data;
727 -- The naming scheme of this project file.
728 -- Set by Prj.Nmsc.Check_Naming_Scheme.
730 First_Language_Processing : First_Language_Processing_Data :=
731 Default_First_Language_Processing_Data;
732 -- Comment needed ???
734 Supp_Language_Processing : Supp_Language_Index := No_Supp_Language_Index;
737 Default_Linker : Name_Id := No_Name;
738 Default_Linker_Path : Name_Id := No_Name;
740 Decl : Declarations := No_Declarations;
741 -- The declarations (variables, attributes and packages) of this
742 -- project file. Set by Prj.Proc.Process.
744 Imported_Projects : Project_List := Empty_Project_List;
745 -- The list of all directly imported projects, if any. Set by
748 All_Imported_Projects : Project_List := Empty_Project_List;
749 -- The list of all projects imported directly or indirectly, if any.
750 -- Set by Make.Initialize.
752 Ada_Include_Path : String_Access := null;
753 -- The cached value of ADA_INCLUDE_PATH for this project file. Do not
754 -- use this field directly outside of the compiler, use
755 -- Prj.Env.Ada_Include_Path instead. Set by Prj.Env.Ada_Include_Path.
757 Ada_Objects_Path : String_Access := null;
758 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
759 -- use this field directly outside of the compiler, use
760 -- Prj.Env.Ada_Objects_Path instead. Set by Prj.Env.Ada_Objects_Path
762 Include_Path_File : Name_Id := No_Name;
763 -- The cached value of the source path temp file for this project file.
764 -- Set by gnatmake (Prj.Env.Set_Ada_Paths).
766 Objects_Path_File_With_Libs : Name_Id := No_Name;
767 -- The cached value of the object path temp file (including library
768 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
770 Objects_Path_File_Without_Libs : Name_Id := No_Name;
771 -- The cached value of the object path temp file (excluding library
772 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
774 Config_File_Name : Name_Id := No_Name;
775 -- The name of the configuration pragmas file, if any.
776 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
778 Config_File_Temp : Boolean := False;
779 -- An indication that the configuration pragmas file is
780 -- a temporary file that must be deleted at the end.
781 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
783 Config_Checked : Boolean := False;
784 -- A flag to avoid checking repetitively the configuration pragmas file.
785 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
787 Language_Independent_Checked : Boolean := False;
788 -- A flag that indicates that the project file has been checked
789 -- for language independent features: Object_Directory,
790 -- Source_Directories, Library, non empty Naming Suffixes.
792 Checked : Boolean := False;
793 -- A flag to avoid checking repetitively the naming scheme of
794 -- this project file. Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
796 Seen : Boolean := False;
797 -- A flag to mark a project as "visited" to avoid processing the same
798 -- project several time.
800 Need_To_Build_Lib : Boolean := False;
801 -- Indicates that the library of a Library Project needs to be built or
804 Depth : Natural := 0;
805 -- The maximum depth of a project in the project graph.
806 -- Depth of main project is 0.
808 Unkept_Comments : Boolean := False;
809 -- True if there are comments in the project sources that cannot
810 -- be kept in the project tree.
814 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
815 -- Return the representation of an empty project in project Tree tree.
816 -- The project tree Tree must have been Initialized and/or Reset.
818 Project_Error : exception;
819 -- Raised by some subprograms in Prj.Attr
821 package Project_Table is new GNAT.Dynamic_Tables (
822 Table_Component_Type => Project_Data,
823 Table_Index_Type => Project_Id,
824 Table_Low_Bound => 1,
825 Table_Initial => 100,
826 Table_Increment => 100);
827 -- The set of all project files
830 (Specification, Body_Part);
832 type File_Name_Data is record
833 Name : Name_Id := No_Name;
835 Display_Name : Name_Id := No_Name;
836 Path : Name_Id := No_Name;
837 Display_Path : Name_Id := No_Name;
838 Project : Project_Id := No_Project;
839 Needs_Pragma : Boolean := False;
841 -- File and Path name of a spec or body
843 type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
845 type Unit_Id is new Nat;
846 No_Unit : constant Unit_Id := 0;
847 type Unit_Data is record
848 Name : Name_Id := No_Name;
849 File_Names : File_Names_Data;
851 -- Name and File and Path names of a unit, with a reference to its
852 -- GNAT Project File(s).
854 package Unit_Table is new GNAT.Dynamic_Tables
855 (Table_Component_Type => Unit_Data,
856 Table_Index_Type => Unit_Id,
857 Table_Low_Bound => 1,
858 Table_Initial => 100,
859 Table_Increment => 100);
860 -- Table of all units in a project tree
862 package Units_Htable is new Simple_HTable
863 (Header_Num => Header_Num,
865 No_Element => No_Unit,
869 -- Mapping of unit names to indexes in the Units table
871 type Unit_Project is record
872 Unit : Unit_Id := No_Unit;
873 Project : Project_Id := No_Project;
876 No_Unit_Project : constant Unit_Project := (No_Unit, No_Project);
878 package Files_Htable is new Simple_HTable
879 (Header_Num => Header_Num,
880 Element => Unit_Project,
881 No_Element => No_Unit_Project,
885 -- Mapping of file names to indexes in the Units table
887 type Private_Project_Tree_Data is private;
888 -- Data for a project tree that is used only by the Project Manager
890 type Project_Tree_Data is
892 Present_Languages : Present_Language_Table.Instance;
893 Supp_Suffixes : Supp_Suffix_Table.Instance;
894 Name_Lists : Name_List_Table.Instance;
895 Supp_Languages : Supp_Language_Table.Instance;
896 Other_Sources : Other_Source_Table.Instance;
897 String_Elements : String_Element_Table.Instance;
898 Variable_Elements : Variable_Element_Table.Instance;
899 Array_Elements : Array_Element_Table.Instance;
900 Arrays : Array_Table.Instance;
901 Packages : Package_Table.Instance;
902 Project_Lists : Project_List_Table.Instance;
903 Projects : Project_Table.Instance;
904 Units : Unit_Table.Instance;
905 Units_HT : Units_Htable.Instance;
906 Files_HT : Files_Htable.Instance;
907 Private_Part : Private_Project_Tree_Data;
909 -- Data for a project tree
911 type Put_Line_Access is access procedure
913 Project : Project_Id;
914 In_Tree : Project_Tree_Ref);
915 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
917 procedure Expect (The_Token : Token_Type; Token_Image : String);
918 -- Check that the current token is The_Token. If it is not, then
919 -- output an error message.
921 procedure Initialize (Tree : Project_Tree_Ref);
922 -- This procedure must be called before using any services from the Prj
923 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
925 procedure Reset (Tree : Project_Tree_Ref);
926 -- This procedure resets all the tables that are used when processing a
927 -- project file tree. Initialize must be called before the call to Reset.
929 procedure Register_Default_Naming_Scheme
931 Default_Spec_Suffix : Name_Id;
932 Default_Body_Suffix : Name_Id;
933 In_Tree : Project_Tree_Ref);
934 -- Register the default suffixes for a given language. These extensions
935 -- will be ignored if the user has specified a new naming scheme in a
938 -- Otherwise, this information will be automatically added to Naming_Data
939 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
942 type State is limited private;
943 with procedure Action
944 (Project : Project_Id;
945 With_State : in out State);
946 procedure For_Every_Project_Imported
948 In_Tree : Project_Tree_Ref;
949 With_State : in out State);
950 -- Call Action for each project imported directly or indirectly by project
951 -- By. Action is called according to the order of importation: if A
952 -- imports B, directly or indirectly, Action will be called for A before
953 -- it is called for B. If two projects import each other directly or
954 -- indirectly (using at least one "limited with"), it is not specified
955 -- for which of these two projects Action will be called first. Projects
956 -- that are extended by other projects are not considered. With_State may
957 -- be used by Action to choose a behavior or to report some global result.
959 ----------------------------------------------------------
960 -- Other multi-language stuff that may be modified soon --
961 ----------------------------------------------------------
964 (Language : Language_Index;
965 In_Project : Project_Data;
966 In_Tree : Project_Tree_Ref) return Boolean;
967 -- Return True when Language is one of the languages used in
968 -- project In_Project.
971 (Language : Language_Index;
973 In_Project : in out Project_Data;
974 In_Tree : Project_Tree_Ref);
975 -- Indicate if Language is or not a language used in project In_Project
977 function Language_Processing_Data_Of
978 (Language : Language_Index;
979 In_Project : Project_Data;
980 In_Tree : Project_Tree_Ref) return Language_Processing_Data;
981 -- Return the Language_Processing_Data for language Language in project
982 -- In_Project. Return the default when no Language_Processing_Data are
983 -- defined for the language.
986 (Language_Processing : Language_Processing_Data;
987 For_Language : Language_Index;
988 In_Project : in out Project_Data;
989 In_Tree : Project_Tree_Ref);
990 -- Set the Language_Processing_Data for language Language in project
994 (Language : Language_Index;
995 In_Project : Project_Data;
996 In_Tree : Project_Tree_Ref) return Name_Id;
997 -- Return the suffix for language Language in project In_Project. Return
998 -- No_Name when no suffix is defined for the language.
1002 For_Language : Language_Index;
1003 In_Project : in out Project_Data;
1004 In_Tree : Project_Tree_Ref);
1005 -- Set the suffix for language Language in project In_Project
1009 All_Packages : constant String_List_Access := null;
1011 No_Project_Tree : constant Project_Tree_Ref := null;
1013 Ignored : constant Variable_Kind := Single;
1015 Nil_Variable_Value : constant Variable_Value :=
1016 (Project => No_Project,
1018 Location => No_Location,
1021 Virtual_Prefix : constant String := "v$";
1022 -- The prefix for virtual extending projects. Because of the '$', which is
1023 -- normally forbidden for project names, there cannot be any name clash.
1025 Empty_Name : Name_Id;
1026 -- Name_Id for an empty name (no characters). Initialized by the call
1027 -- to procedure Initialize.
1029 procedure Add_To_Buffer
1031 To : in out String_Access;
1032 Last : in out Natural);
1033 -- Append a String to the Buffer
1035 type Naming_Id is new Nat;
1037 package Naming_Table is new GNAT.Dynamic_Tables
1038 (Table_Component_Type => Naming_Data,
1039 Table_Index_Type => Naming_Id,
1040 Table_Low_Bound => 1,
1042 Table_Increment => 100);
1045 package Path_File_Table is new GNAT.Dynamic_Tables
1046 (Table_Component_Type => Name_Id,
1047 Table_Index_Type => Natural,
1048 Table_Low_Bound => 1,
1049 Table_Initial => 50,
1050 Table_Increment => 50);
1051 -- Table storing all the temp path file names.
1052 -- Used by Delete_All_Path_Files.
1054 package Source_Path_Table is new GNAT.Dynamic_Tables
1055 (Table_Component_Type => Name_Id,
1056 Table_Index_Type => Natural,
1057 Table_Low_Bound => 1,
1058 Table_Initial => 50,
1059 Table_Increment => 50);
1060 -- A table to store the source dirs before creating the source path file
1062 package Object_Path_Table is new GNAT.Dynamic_Tables
1063 (Table_Component_Type => Name_Id,
1064 Table_Index_Type => Natural,
1065 Table_Low_Bound => 1,
1066 Table_Initial => 50,
1067 Table_Increment => 50);
1068 -- A table to store the object dirs, before creating the object path file
1070 type Private_Project_Tree_Data is record
1071 Namings : Naming_Table.Instance;
1072 Path_Files : Path_File_Table.Instance;
1073 Source_Paths : Source_Path_Table.Instance;
1074 Object_Paths : Object_Path_Table.Instance;
1075 Default_Naming : Naming_Data;