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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 type Language_Index
is new Nat
;
81 No_Language_Index
: constant Language_Index
:= 0;
82 First_Language_Index
: constant Language_Index
:= 1;
83 First_Language_Indexes_Last
: constant Language_Index
:= 5;
85 Ada_Language_Index
: constant Language_Index
:=
87 C_Language_Index
: constant Language_Index
:=
88 Ada_Language_Index
+ 1;
89 C_Plus_Plus_Language_Index
: constant Language_Index
:=
92 Last_Language_Index
: Language_Index
:= No_Language_Index
;
94 subtype First_Language_Indexes
is Language_Index
95 range First_Language_Index
.. First_Language_Indexes_Last
;
97 type Header_Num
is range 0 .. 2047;
99 function Hash
is new System
.HTable
.Hash
(Header_Num
=> Header_Num
);
101 function Hash
(Name
: Name_Id
) return Header_Num
;
103 package Language_Indexes
is new System
.HTable
.Simple_HTable
104 (Header_Num
=> Header_Num
,
105 Element
=> Language_Index
,
106 No_Element
=> No_Language_Index
,
110 -- Mapping of language names to language indexes
112 package Language_Names
is new Table
.Table
113 (Table_Component_Type
=> Name_Id
,
114 Table_Index_Type
=> Language_Index
,
115 Table_Low_Bound
=> 1,
117 Table_Increment
=> 100,
118 Table_Name
=> "Prj.Language_Names");
119 -- The table for the name of programming languages
121 procedure Add_Language_Name
(Name
: Name_Id
);
123 procedure Display_Language_Name
(Language
: Language_Index
);
125 type Languages_In_Project
is array (First_Language_Indexes
) of Boolean;
126 -- Set of supported languages used in a project
128 No_Languages
: constant Languages_In_Project
:= (others => False);
129 -- No supported languages are used
131 type Supp_Language_Index
is new Nat
;
132 No_Supp_Language_Index
: constant Supp_Language_Index
:= 0;
134 type Supp_Language
is record
135 Index
: Language_Index
:= No_Language_Index
;
136 Present
: Boolean := False;
137 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
140 package Present_Language_Table
is new GNAT
.Dynamic_Tables
141 (Table_Component_Type
=> Supp_Language
,
142 Table_Index_Type
=> Supp_Language_Index
,
143 Table_Low_Bound
=> 1,
145 Table_Increment
=> 100);
146 -- The table for the presence of languages with an index that is outside
147 -- of First_Language_Indexes.
149 type Impl_Suffix_Array
is array (First_Language_Indexes
) of Name_Id
;
150 -- Suffixes for the non spec sources of the different supported languages
153 No_Impl_Suffixes
: constant Impl_Suffix_Array
:= (others => No_Name
);
154 -- A default value for the non spec source suffixes
156 type Supp_Suffix
is record
157 Index
: Language_Index
:= No_Language_Index
;
158 Suffix
: Name_Id
:= No_Name
;
159 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
162 package Supp_Suffix_Table
is new GNAT
.Dynamic_Tables
163 (Table_Component_Type
=> Supp_Suffix
,
164 Table_Index_Type
=> Supp_Language_Index
,
165 Table_Low_Bound
=> 1,
167 Table_Increment
=> 100);
168 -- The table for the presence of languages with an index that is outside
169 -- of First_Language_Indexes.
171 type Language_Kind
is (GNU
, other
);
173 type Name_List_Index
is new Nat
;
174 No_Name_List
: constant Name_List_Index
:= 0;
176 type Name_Node
is record
177 Name
: Name_Id
:= No_Name
;
178 Next
: Name_List_Index
:= No_Name_List
;
181 package Name_List_Table
is new GNAT
.Dynamic_Tables
182 (Table_Component_Type
=> Name_Node
,
183 Table_Index_Type
=> Name_List_Index
,
184 Table_Low_Bound
=> 1,
186 Table_Increment
=> 100);
187 -- The table for lists of names used in package Language_Processing
189 type Language_Processing_Data
is record
190 Compiler_Drivers
: Name_List_Index
:= No_Name_List
;
191 Compiler_Paths
: Name_Id
:= No_Name
;
192 Compiler_Kinds
: Language_Kind
:= GNU
;
193 Dependency_Options
: Name_List_Index
:= No_Name_List
;
194 Compute_Dependencies
: Name_List_Index
:= No_Name_List
;
195 Include_Options
: Name_List_Index
:= No_Name_List
;
196 Binder_Drivers
: Name_Id
:= No_Name
;
197 Binder_Driver_Paths
: Name_Id
:= No_Name
;
200 Default_Language_Processing_Data
:
201 constant Language_Processing_Data
:=
202 (Compiler_Drivers
=> No_Name_List
,
203 Compiler_Paths
=> No_Name
,
204 Compiler_Kinds
=> GNU
,
205 Dependency_Options
=> No_Name_List
,
206 Compute_Dependencies
=> No_Name_List
,
207 Include_Options
=> No_Name_List
,
208 Binder_Drivers
=> No_Name
,
209 Binder_Driver_Paths
=> No_Name
);
211 type First_Language_Processing_Data
is
212 array (First_Language_Indexes
) of Language_Processing_Data
;
214 Default_First_Language_Processing_Data
:
215 constant First_Language_Processing_Data
:=
216 (others => Default_Language_Processing_Data
);
218 type Supp_Language_Data
is record
219 Index
: Language_Index
:= No_Language_Index
;
220 Data
: Language_Processing_Data
:= Default_Language_Processing_Data
;
221 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
224 package Supp_Language_Table
is new GNAT
.Dynamic_Tables
225 (Table_Component_Type
=> Supp_Language_Data
,
226 Table_Index_Type
=> Supp_Language_Index
,
227 Table_Low_Bound
=> 1,
229 Table_Increment
=> 100);
230 -- The table for language data when there are more languages than
231 -- in First_Language_Indexes.
233 type Other_Source_Id
is new Nat
;
234 No_Other_Source
: constant Other_Source_Id
:= 0;
235 type Other_Source
is record
236 Language
: Language_Index
; -- language of the source
237 File_Name
: Name_Id
; -- source file simple name
238 Path_Name
: Name_Id
; -- source full path name
239 Source_TS
: Time_Stamp_Type
; -- source file time stamp
240 Object_Name
: Name_Id
; -- object file simple name
241 Object_Path
: Name_Id
; -- object full path name
242 Object_TS
: Time_Stamp_Type
; -- object file time stamp
243 Dep_Name
: Name_Id
; -- dependency file simple name
244 Dep_Path
: Name_Id
; -- dependency full path name
245 Dep_TS
: Time_Stamp_Type
; -- dependency file time stamp
246 Naming_Exception
: Boolean := False; -- True if a naming exception
247 Next
: Other_Source_Id
:= No_Other_Source
;
249 -- Data for a source in a language other than Ada
251 package Other_Source_Table
is new GNAT
.Dynamic_Tables
252 (Table_Component_Type
=> Other_Source
,
253 Table_Index_Type
=> Other_Source_Id
,
254 Table_Low_Bound
=> 1,
255 Table_Initial
=> 200,
256 Table_Increment
=> 100);
257 -- The table for sources of languages other than Ada
259 ----------------------------------
260 -- End of multi-language stuff --
261 ----------------------------------
263 type Verbosity
is (Default
, Medium
, High
);
264 -- Verbosity when parsing GNAT Project Files
265 -- Default is default (very quiet, if no errors).
266 -- Medium is more verbose.
267 -- High is extremely verbose.
269 Current_Verbosity
: Verbosity
:= Default
;
270 -- The current value of the verbosity the project files are parsed with
272 type Lib_Kind
is (Static
, Dynamic
, Relocatable
);
273 type Policy
is (Autonomous
, Compliant
, Controlled
, Restricted
);
274 -- Type to specify the symbol policy, when symbol control is supported.
275 -- See full explanation about this type in package Symbols.
276 -- Autonomous: Create a symbol file without considering any reference
277 -- Compliant: Try to be as compatible as possible with an existing ref
278 -- Controlled: Fail if symbols are not the same as those in the reference
279 -- Restricted: Restrict the symbols to those in the symbol file
281 type Symbol_Record
is record
282 Symbol_File
: Name_Id
:= No_Name
;
283 Reference
: Name_Id
:= No_Name
;
284 Symbol_Policy
: Policy
:= Autonomous
;
286 -- Type to keep the symbol data to be used when building a shared library
288 No_Symbols
: constant Symbol_Record
:=
289 (Symbol_File
=> No_Name
,
290 Reference
=> No_Name
,
291 Symbol_Policy
=> Autonomous
);
292 -- The default value of the symbol data
294 function Empty_String
return Name_Id
;
295 -- Return the Name_Id for an empty string ""
297 type Project_Id
is new Nat
;
298 No_Project
: constant Project_Id
:= 0;
299 -- Id of a Project File
301 type String_List_Id
is new Nat
;
302 Nil_String
: constant String_List_Id
:= 0;
303 type String_Element
is record
304 Value
: Name_Id
:= No_Name
;
306 Display_Value
: Name_Id
:= No_Name
;
307 Location
: Source_Ptr
:= No_Location
;
308 Flag
: Boolean := False;
309 Next
: String_List_Id
:= Nil_String
;
311 -- To hold values for string list variables and array elements.
312 -- Component Flag may be used for various purposes. For source
313 -- directories, it indicates if the directory contains Ada source(s).
315 package String_Element_Table
is new GNAT
.Dynamic_Tables
316 (Table_Component_Type
=> String_Element
,
317 Table_Index_Type
=> String_List_Id
,
318 Table_Low_Bound
=> 1,
319 Table_Initial
=> 200,
320 Table_Increment
=> 100);
321 -- The table for string elements in string lists
323 type Variable_Kind
is (Undefined
, List
, Single
);
324 -- Different kinds of variables
326 subtype Defined_Variable_Kind
is Variable_Kind
range List
.. Single
;
327 -- The defined kinds of variables
329 Ignored
: constant Variable_Kind
;
330 -- Used to indicate that a package declaration must be ignored
331 -- while processing the project tree (unknown package name).
333 type Variable_Value
(Kind
: Variable_Kind
:= Undefined
) is record
334 Project
: Project_Id
:= No_Project
;
335 Location
: Source_Ptr
:= No_Location
;
336 Default
: Boolean := False;
341 Values
: String_List_Id
:= Nil_String
;
343 Value
: Name_Id
:= No_Name
;
347 -- Values for variables and array elements. Default is True if the
348 -- current value is the default one for the variable
350 Nil_Variable_Value
: constant Variable_Value
;
351 -- Value of a non existing variable or array element
353 type Variable_Id
is new Nat
;
354 No_Variable
: constant Variable_Id
:= 0;
355 type Variable
is record
356 Next
: Variable_Id
:= No_Variable
;
358 Value
: Variable_Value
;
360 -- To hold the list of variables in a project file and in packages
362 package Variable_Element_Table
is new GNAT
.Dynamic_Tables
363 (Table_Component_Type
=> Variable
,
364 Table_Index_Type
=> Variable_Id
,
365 Table_Low_Bound
=> 1,
366 Table_Initial
=> 200,
367 Table_Increment
=> 100);
368 -- The table of variable in list of variables
370 type Array_Element_Id
is new Nat
;
371 No_Array_Element
: constant Array_Element_Id
:= 0;
372 type Array_Element
is record
374 Src_Index
: Int
:= 0;
375 Index_Case_Sensitive
: Boolean := True;
376 Value
: Variable_Value
;
377 Next
: Array_Element_Id
:= No_Array_Element
;
379 -- Each Array_Element represents an array element and is linked (Next)
380 -- to the next array element, if any, in the array.
382 package Array_Element_Table
is new GNAT
.Dynamic_Tables
383 (Table_Component_Type
=> Array_Element
,
384 Table_Index_Type
=> Array_Element_Id
,
385 Table_Low_Bound
=> 1,
386 Table_Initial
=> 200,
387 Table_Increment
=> 100);
388 -- The table that contains all array elements
390 type Array_Id
is new Nat
;
391 No_Array
: constant Array_Id
:= 0;
392 type Array_Data
is record
393 Name
: Name_Id
:= No_Name
;
394 Value
: Array_Element_Id
:= No_Array_Element
;
395 Next
: Array_Id
:= No_Array
;
397 -- Each Array_Data value represents an array.
398 -- Value is the id of the first element.
399 -- Next is the id of the next array in the project file or package.
401 package Array_Table
is new GNAT
.Dynamic_Tables
402 (Table_Component_Type
=> Array_Data
,
403 Table_Index_Type
=> Array_Id
,
404 Table_Low_Bound
=> 1,
405 Table_Initial
=> 200,
406 Table_Increment
=> 100);
407 -- The table that contains all arrays
409 type Package_Id
is new Nat
;
410 No_Package
: constant Package_Id
:= 0;
411 type Declarations
is record
412 Variables
: Variable_Id
:= No_Variable
;
413 Attributes
: Variable_Id
:= No_Variable
;
414 Arrays
: Array_Id
:= No_Array
;
415 Packages
: Package_Id
:= No_Package
;
417 -- Contains the declarations (variables, single and array attributes,
418 -- packages) for a project or a package in a project.
420 No_Declarations
: constant Declarations
:=
421 (Variables
=> No_Variable
,
422 Attributes
=> No_Variable
,
424 Packages
=> No_Package
);
425 -- Default value of Declarations: indicates that there is no declarations
427 type Package_Element
is record
428 Name
: Name_Id
:= No_Name
;
429 Decl
: Declarations
:= No_Declarations
;
430 Parent
: Package_Id
:= No_Package
;
431 Next
: Package_Id
:= No_Package
;
433 -- A package. Includes declarations that may include other packages
435 package Package_Table
is new GNAT
.Dynamic_Tables
436 (Table_Component_Type
=> Package_Element
,
437 Table_Index_Type
=> Package_Id
,
438 Table_Low_Bound
=> 1,
439 Table_Initial
=> 100,
440 Table_Increment
=> 100);
441 -- The table that contains all packages
443 function Image
(Casing
: Casing_Type
) return String;
444 -- Similar to 'Image (but avoid use of this attribute in compiler)
446 function Value
(Image
: String) return Casing_Type
;
447 -- Similar to 'Value (but avoid use of this attribute in compiler)
448 -- Raises Constraint_Error if not a Casing_Type image.
450 -- The following record contains data for a naming scheme
452 type Naming_Data
is record
454 Dot_Replacement
: Name_Id
:= No_Name
;
455 -- The string to replace '.' in the source file name (for Ada)
457 Dot_Repl_Loc
: Source_Ptr
:= No_Location
;
458 -- The position in the project file source where Dot_Replacement is
461 Casing
: Casing_Type
:= All_Lower_Case
;
462 -- The casing of the source file name (for Ada)
464 Spec_Suffix
: Array_Element_Id
:= No_Array_Element
;
465 -- The string to append to the unit name for the
466 -- source file name of a spec.
467 -- Indexed by the programming language.
469 Ada_Spec_Suffix
: Name_Id
:= No_Name
;
470 -- The suffix of the Ada spec sources
472 Spec_Suffix_Loc
: Source_Ptr
:= No_Location
;
473 -- The position in the project file source where
474 -- Ada_Spec_Suffix is defined.
476 Impl_Suffixes
: Impl_Suffix_Array
:= No_Impl_Suffixes
;
477 Supp_Suffixes
: Supp_Language_Index
:= No_Supp_Language_Index
;
478 -- The source suffixes of the different languages
480 Body_Suffix
: Array_Element_Id
:= No_Array_Element
;
481 -- The string to append to the unit name for the
482 -- source file name of a body.
483 -- Indexed by the programming language.
485 Ada_Body_Suffix
: Name_Id
:= No_Name
;
486 -- The suffix of the Ada body sources
488 Body_Suffix_Loc
: Source_Ptr
:= No_Location
;
489 -- The position in the project file source where
490 -- Ada_Body_Suffix is defined.
492 Separate_Suffix
: Name_Id
:= No_Name
;
493 -- String to append to unit name for source file name of an Ada subunit
495 Sep_Suffix_Loc
: Source_Ptr
:= No_Location
;
496 -- Position in the project file source where Separate_Suffix is defined
498 Specs
: Array_Element_Id
:= No_Array_Element
;
499 -- An associative array mapping individual specs to source file names
500 -- This is specific to Ada.
502 Bodies
: Array_Element_Id
:= No_Array_Element
;
503 -- An associative array mapping individual bodies to source file names
504 -- This is specific to Ada.
506 Specification_Exceptions
: Array_Element_Id
:= No_Array_Element
;
507 -- An associative array listing spec file names that do not have the
508 -- spec suffix. Not used by Ada. Indexed by programming language name.
510 Implementation_Exceptions
: Array_Element_Id
:= No_Array_Element
;
511 -- An associative array listing body file names that do not have the
512 -- body suffix. Not used by Ada. Indexed by programming language name.
516 function Standard_Naming_Data
517 (Tree
: Project_Tree_Ref
:= No_Project_Tree
) return Naming_Data
;
518 pragma Inline
(Standard_Naming_Data
);
519 -- The standard GNAT naming scheme when Tree is No_Project_Tree.
520 -- Otherwise, return the default naming scheme for the project tree Tree,
521 -- which must have been Initialized.
523 function Same_Naming_Scheme
524 (Left
, Right
: Naming_Data
) return Boolean;
525 -- Returns True if Left and Right are the same naming scheme
526 -- not considering Specs and Bodies.
528 type Project_List
is new Nat
;
529 Empty_Project_List
: constant Project_List
:= 0;
530 -- A list of project files
532 type Project_Element
is record
533 Project
: Project_Id
:= No_Project
;
534 Next
: Project_List
:= Empty_Project_List
;
536 -- Element in a list of project files. Next is the id of the next
537 -- project file in the list.
539 package Project_List_Table
is new GNAT
.Dynamic_Tables
540 (Table_Component_Type
=> Project_Element
,
541 Table_Index_Type
=> Project_List
,
542 Table_Low_Bound
=> 1,
543 Table_Initial
=> 100,
544 Table_Increment
=> 100);
545 -- The table that contains the lists of project files
547 -- The following record describes a project file representation
549 type Project_Data
is record
550 Externally_Built
: Boolean := False;
552 Languages
: Languages_In_Project
:= No_Languages
;
553 Supp_Languages
: Supp_Language_Index
:= No_Supp_Language_Index
;
554 -- Indicate the different languages of the source of this project
556 First_Referred_By
: Project_Id
:= No_Project
;
557 -- The project, if any, that was the first to be known as importing or
558 -- extending this project. Set by Prj.Proc.Process.
560 Name
: Name_Id
:= No_Name
;
561 -- The name of the project. Set by Prj.Proc.Process
563 Display_Name
: Name_Id
:= No_Name
;
564 -- The name of the project with the spelling of its declaration.
565 -- Set by Prj.Proc.Process.
567 Path_Name
: Name_Id
:= No_Name
;
568 -- The path name of the project file. Set by Prj.Proc.Process
570 Display_Path_Name
: Name_Id
:= No_Name
;
571 -- The path name used for display purposes. May be different from
572 -- Path_Name for platforms where the file names are case-insensitive.
574 Virtual
: Boolean := False;
575 -- True for virtual extending projects
577 Location
: Source_Ptr
:= No_Location
;
578 -- The location in the project file source of the reserved word
579 -- project. Set by Prj.Proc.Process.
581 Mains
: String_List_Id
:= Nil_String
;
582 -- List of mains specified by attribute Main. Set by Prj.Nmsc.Check
584 Directory
: Name_Id
:= No_Name
;
585 -- Directory where the project file resides. Set by Prj.Proc.Process
587 Display_Directory
: Name_Id
:= No_Name
;
589 Dir_Path
: String_Access
;
590 -- Same as Directory, but as an access to String. Set by
591 -- Make.Compile_Sources.Collect_Arguments_And_Compile.
593 Library
: Boolean := False;
594 -- True if this is a library project. Set by
595 -- Prj.Nmsc.Language_Independent_Check.
597 Library_Dir
: Name_Id
:= No_Name
;
598 -- If a library project, directory where resides the library Set by
599 -- Prj.Nmsc.Language_Independent_Check.
601 Display_Library_Dir
: Name_Id
:= No_Name
;
602 -- The name of the library directory, for display purposes. May be
603 -- different from Library_Dir for platforms where the file names are
606 Library_Src_Dir
: Name_Id
:= No_Name
;
607 -- If a library project, directory where the sources and the ALI files
608 -- of the library are copied. By default, if attribute Library_Src_Dir
609 -- is not specified, sources are not copied anywhere and ALI files are
610 -- copied in the Library Directory. Set by
611 -- Prj.Nmsc.Language_Independent_Check.
613 Display_Library_Src_Dir
: Name_Id
:= No_Name
;
614 -- The name of the library source directory, for display purposes.
615 -- May be different from Library_Src_Dir for platforms where the file
616 -- names are case-insensitive.
618 Library_Name
: Name_Id
:= No_Name
;
619 -- If a library project, name of the library
620 -- Set by Prj.Nmsc.Language_Independent_Check.
622 Library_Kind
: Lib_Kind
:= Static
;
623 -- If a library project, kind of library
624 -- Set by Prj.Nmsc.Language_Independent_Check.
626 Lib_Internal_Name
: Name_Id
:= No_Name
;
627 -- If a library project, internal name store inside the library Set by
628 -- Prj.Nmsc.Language_Independent_Check.
630 Standalone_Library
: Boolean := False;
631 -- Indicate that this is a Standalone Library Project File. Set by
634 Lib_Interface_ALIs
: String_List_Id
:= Nil_String
;
635 -- For Standalone Library Project Files, indicate the list of Interface
636 -- ALI files. Set by Prj.Nmsc.Check.
638 Lib_Auto_Init
: Boolean := False;
639 -- For non static Standalone Library Project Files, indicate if
640 -- the library initialisation should be automatic.
642 Symbol_Data
: Symbol_Record
:= No_Symbols
;
643 -- Symbol file name, reference symbol file name, symbol policy
645 Ada_Sources_Present
: Boolean := True;
646 -- A flag that indicates if there are Ada sources in this project file.
647 -- There are no sources if any of the following is true:
648 -- 1) Source_Dirs is specified as an empty list
649 -- 2) Source_Files is specified as an empty list
650 -- 3) Ada is not in the list of the specified Languages
652 Other_Sources_Present
: Boolean := True;
653 -- A flag that indicates that there are non-Ada sources in this project
655 Sources
: String_List_Id
:= Nil_String
;
656 -- The list of all the source file names. Set by
657 -- Prj.Nmsc.Check_Ada_Naming_Scheme.
659 First_Other_Source
: Other_Source_Id
:= No_Other_Source
;
660 Last_Other_Source
: Other_Source_Id
:= No_Other_Source
;
661 -- Head and tail of the list of sources of languages other than Ada
663 Imported_Directories_Switches
: Argument_List_Access
:= null;
664 -- List of the -I switches to be used when compiling sources of
665 -- languages other than Ada.
667 Include_Path
: String_Access
:= null;
668 -- Value to be used as CPATH, when using a GCC, instead of a list of
671 Include_Data_Set
: Boolean := False;
672 -- Set True when Imported_Directories_Switches or Include_Path are set
674 Source_Dirs
: String_List_Id
:= Nil_String
;
675 -- The list of all the source directories.
676 -- Set by Prj.Nmsc.Language_Independent_Check.
678 Known_Order_Of_Source_Dirs
: Boolean := True;
679 -- False, if there is any /** in the Source_Dirs, because in this case
680 -- the ordering of the source subdirs depend on the OS. If True,
681 -- duplicate file names in the same project file are allowed.
683 Object_Directory
: Name_Id
:= No_Name
;
684 -- The object directory of this project file.
685 -- Set by Prj.Nmsc.Language_Independent_Check.
687 Display_Object_Dir
: Name_Id
:= No_Name
;
688 -- The name of the object directory, for display purposes.
689 -- May be different from Object_Directory for platforms where the file
690 -- names are case-insensitive.
692 Exec_Directory
: Name_Id
:= No_Name
;
693 -- The exec directory of this project file. Default is equal to
694 -- Object_Directory. Set by Prj.Nmsc.Language_Independent_Check.
696 Display_Exec_Dir
: Name_Id
:= No_Name
;
697 -- The name of the exec directory, for display purposes. May be
698 -- different from Exec_Directory for platforms where the file names are
701 Extends
: Project_Id
:= No_Project
;
702 -- The reference of the project file, if any, that this project file
703 -- extends. Set by Prj.Proc.Process.
705 Extended_By
: Project_Id
:= No_Project
;
706 -- The reference of the project file, if any, that extends this project
707 -- file. Set by Prj.Proc.Process.
709 Naming
: Naming_Data
:= Standard_Naming_Data
;
710 -- The naming scheme of this project file.
711 -- Set by Prj.Nmsc.Check_Naming_Scheme.
713 First_Language_Processing
: First_Language_Processing_Data
:=
714 Default_First_Language_Processing_Data
;
716 Supp_Language_Processing
: Supp_Language_Index
:=
717 No_Supp_Language_Index
;
719 Default_Linker
: Name_Id
:= No_Name
;
720 Default_Linker_Path
: Name_Id
:= No_Name
;
722 Decl
: Declarations
:= No_Declarations
;
723 -- The declarations (variables, attributes and packages) of this
724 -- project file. Set by Prj.Proc.Process.
726 Imported_Projects
: Project_List
:= Empty_Project_List
;
727 -- The list of all directly imported projects, if any. Set by
730 Ada_Include_Path
: String_Access
:= null;
731 -- The cached value of ADA_INCLUDE_PATH for this project file. Do not
732 -- use this field directly outside of the compiler, use
733 -- Prj.Env.Ada_Include_Path instead. Set by Prj.Env.Ada_Include_Path.
735 Ada_Objects_Path
: String_Access
:= null;
736 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
737 -- use this field directly outside of the compiler, use
738 -- Prj.Env.Ada_Objects_Path instead. Set by Prj.Env.Ada_Objects_Path
740 Include_Path_File
: Name_Id
:= No_Name
;
741 -- The cached value of the source path temp file for this project file.
742 -- Set by gnatmake (Prj.Env.Set_Ada_Paths).
744 Objects_Path_File_With_Libs
: Name_Id
:= No_Name
;
745 -- The cached value of the object path temp file (including library
746 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
748 Objects_Path_File_Without_Libs
: Name_Id
:= No_Name
;
749 -- The cached value of the object path temp file (excluding library
750 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
752 Config_File_Name
: Name_Id
:= No_Name
;
753 -- The name of the configuration pragmas file, if any.
754 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
756 Config_File_Temp
: Boolean := False;
757 -- An indication that the configuration pragmas file is
758 -- a temporary file that must be deleted at the end.
759 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
761 Config_Checked
: Boolean := False;
762 -- A flag to avoid checking repetitively the configuration pragmas file.
763 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
765 Language_Independent_Checked
: Boolean := False;
766 -- A flag that indicates that the project file has been checked
767 -- for language independent features: Object_Directory,
768 -- Source_Directories, Library, non empty Naming Suffixes.
770 Checked
: Boolean := False;
771 -- A flag to avoid checking repetitively the naming scheme of
772 -- this project file. Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
774 Seen
: Boolean := False;
775 -- A flag to mark a project as "visited" to avoid processing the same
776 -- project several time.
778 Need_To_Build_Lib
: Boolean := False;
779 -- Indicates that the library of a Library Project needs to be built or
782 Depth
: Natural := 0;
783 -- The maximum depth of a project in the project graph.
784 -- Depth of main project is 0.
786 Unkept_Comments
: Boolean := False;
787 -- True if there are comments in the project sources that cannot
788 -- be kept in the project tree.
792 function Empty_Project
(Tree
: Project_Tree_Ref
) return Project_Data
;
793 -- Return the representation of an empty project in project Tree tree.
794 -- The project tree Tree must have been Initialized and/or Reset.
796 Project_Error
: exception;
797 -- Raised by some subprograms in Prj.Attr
799 package Project_Table
is new GNAT
.Dynamic_Tables
(
800 Table_Component_Type
=> Project_Data
,
801 Table_Index_Type
=> Project_Id
,
802 Table_Low_Bound
=> 1,
803 Table_Initial
=> 100,
804 Table_Increment
=> 100);
805 -- The set of all project files
808 (Specification
, Body_Part
);
810 type File_Name_Data
is record
811 Name
: Name_Id
:= No_Name
;
813 Display_Name
: Name_Id
:= No_Name
;
814 Path
: Name_Id
:= No_Name
;
815 Display_Path
: Name_Id
:= No_Name
;
816 Project
: Project_Id
:= No_Project
;
817 Needs_Pragma
: Boolean := False;
819 -- File and Path name of a spec or body
821 type File_Names_Data
is array (Spec_Or_Body
) of File_Name_Data
;
823 type Unit_Id
is new Nat
;
824 No_Unit
: constant Unit_Id
:= 0;
825 type Unit_Data
is record
826 Name
: Name_Id
:= No_Name
;
827 File_Names
: File_Names_Data
;
829 -- Name and File and Path names of a unit, with a reference to its
830 -- GNAT Project File(s).
832 package Unit_Table
is new GNAT
.Dynamic_Tables
833 (Table_Component_Type
=> Unit_Data
,
834 Table_Index_Type
=> Unit_Id
,
835 Table_Low_Bound
=> 1,
836 Table_Initial
=> 100,
837 Table_Increment
=> 100);
838 -- Table of all units in a project tree
840 package Units_Htable
is new Simple_HTable
841 (Header_Num
=> Header_Num
,
843 No_Element
=> No_Unit
,
847 -- Mapping of unit names to indexes in the Units table
849 type Unit_Project
is record
850 Unit
: Unit_Id
:= No_Unit
;
851 Project
: Project_Id
:= No_Project
;
854 No_Unit_Project
: constant Unit_Project
:= (No_Unit
, No_Project
);
856 package Files_Htable
is new Simple_HTable
857 (Header_Num
=> Header_Num
,
858 Element
=> Unit_Project
,
859 No_Element
=> No_Unit_Project
,
863 -- Mapping of file names to indexes in the Units table
865 type Private_Project_Tree_Data
is private;
866 -- Data for a project tree that is used only by the Project Manager
868 type Project_Tree_Data
is
870 Present_Languages
: Present_Language_Table
.Instance
;
871 Supp_Suffixes
: Supp_Suffix_Table
.Instance
;
872 Name_Lists
: Name_List_Table
.Instance
;
873 Supp_Languages
: Supp_Language_Table
.Instance
;
874 Other_Sources
: Other_Source_Table
.Instance
;
875 String_Elements
: String_Element_Table
.Instance
;
876 Variable_Elements
: Variable_Element_Table
.Instance
;
877 Array_Elements
: Array_Element_Table
.Instance
;
878 Arrays
: Array_Table
.Instance
;
879 Packages
: Package_Table
.Instance
;
880 Project_Lists
: Project_List_Table
.Instance
;
881 Projects
: Project_Table
.Instance
;
882 Units
: Unit_Table
.Instance
;
883 Units_HT
: Units_Htable
.Instance
;
884 Files_HT
: Files_Htable
.Instance
;
885 Private_Part
: Private_Project_Tree_Data
;
887 -- Data for a project tree
889 type Put_Line_Access
is access procedure
891 Project
: Project_Id
;
892 In_Tree
: Project_Tree_Ref
);
893 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
895 procedure Expect
(The_Token
: Token_Type
; Token_Image
: String);
896 -- Check that the current token is The_Token. If it is not, then
897 -- output an error message.
899 procedure Initialize
(Tree
: Project_Tree_Ref
);
900 -- This procedure must be called before using any services from the Prj
901 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
903 procedure Reset
(Tree
: Project_Tree_Ref
);
904 -- This procedure resets all the tables that are used when processing a
905 -- project file tree. Initialize must be called before the call to Reset.
907 procedure Register_Default_Naming_Scheme
909 Default_Spec_Suffix
: Name_Id
;
910 Default_Body_Suffix
: Name_Id
;
911 In_Tree
: Project_Tree_Ref
);
912 -- Register the default suffixes for a given language. These extensions
913 -- will be ignored if the user has specified a new naming scheme in a
916 -- Otherwise, this information will be automatically added to Naming_Data
917 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
920 type State
is limited private;
921 with procedure Action
922 (Project
: Project_Id
;
923 With_State
: in out State
);
924 procedure For_Every_Project_Imported
926 In_Tree
: Project_Tree_Ref
;
927 With_State
: in out State
);
928 -- Call Action for each project imported directly or indirectly by project
929 -- By. Action is called according to the order of importation: if A
930 -- imports B, directly or indirectly, Action will be called for A before
931 -- it is called for B. If two projects import each other directly or
932 -- indirectly (using at least one "limited with"), it is not specified
933 -- for which of these two projects Action will be called first. Projects
934 -- that are extended by other projects are not considered. With_State may
935 -- be used by Action to choose a behavior or to report some global result.
937 ----------------------------------------------------------
938 -- Other multi-language stuff that may be modified soon --
939 ----------------------------------------------------------
942 (Language
: Language_Index
;
943 In_Project
: Project_Data
;
944 In_Tree
: Project_Tree_Ref
) return Boolean;
945 -- Return True when Language is one of the languages used in
949 (Language
: Language_Index
;
951 In_Project
: in out Project_Data
;
952 In_Tree
: Project_Tree_Ref
);
953 -- Indicate if Language is or not a language used in project Project
955 function Language_Processing_Data_Of
956 (Language
: Language_Index
;
957 In_Project
: Project_Data
;
958 In_Tree
: Project_Tree_Ref
) return Language_Processing_Data
;
959 -- Return the Language_Processing_Data for language Language in project
960 -- In_Project. Return the default when no Language_Processing_Data are
961 -- defined for the language.
964 (Language_Processing
: Language_Processing_Data
;
965 For_Language
: Language_Index
;
966 In_Project
: in out Project_Data
;
967 In_Tree
: Project_Tree_Ref
);
968 -- Set the Language_Processing_Data for language Language in project
972 (Language
: Language_Index
;
973 In_Project
: Project_Data
;
974 In_Tree
: Project_Tree_Ref
) return Name_Id
;
975 -- Return the suffix for language Language in project In_Project. Return
976 -- No_Name when no suffix is defined for the language.
980 For_Language
: Language_Index
;
981 In_Project
: in out Project_Data
;
982 In_Tree
: Project_Tree_Ref
);
983 -- Set the suffix for language Language in project In_Project
987 All_Packages
: constant String_List_Access
:= null;
989 No_Project_Tree
: constant Project_Tree_Ref
:= null;
991 Ignored
: constant Variable_Kind
:= Single
;
993 Nil_Variable_Value
: constant Variable_Value
:=
994 (Project
=> No_Project
,
996 Location
=> No_Location
,
999 Virtual_Prefix
: constant String := "v$";
1000 -- The prefix for virtual extending projects. Because of the '$', which is
1001 -- normally forbidden for project names, there cannot be any name clash.
1003 Empty_Name
: Name_Id
;
1004 -- Name_Id for an empty name (no characters). Initialized by the call
1005 -- to procedure Initialize.
1007 procedure Add_To_Buffer
1009 To
: in out String_Access
;
1010 Last
: in out Natural);
1011 -- Append a String to the Buffer
1013 type Naming_Id
is new Nat
;
1015 package Naming_Table
is new GNAT
.Dynamic_Tables
1016 (Table_Component_Type
=> Naming_Data
,
1017 Table_Index_Type
=> Naming_Id
,
1018 Table_Low_Bound
=> 1,
1020 Table_Increment
=> 100);
1022 package Path_File_Table
is new GNAT
.Dynamic_Tables
1023 (Table_Component_Type
=> Name_Id
,
1024 Table_Index_Type
=> Natural,
1025 Table_Low_Bound
=> 1,
1026 Table_Initial
=> 50,
1027 Table_Increment
=> 50);
1028 -- Table storing all the temp path file names.
1029 -- Used by Delete_All_Path_Files.
1031 package Source_Path_Table
is new GNAT
.Dynamic_Tables
1032 (Table_Component_Type
=> Name_Id
,
1033 Table_Index_Type
=> Natural,
1034 Table_Low_Bound
=> 1,
1035 Table_Initial
=> 50,
1036 Table_Increment
=> 50);
1037 -- A table to store the source dirs before creating the source path file
1039 package Object_Path_Table
is new GNAT
.Dynamic_Tables
1040 (Table_Component_Type
=> Name_Id
,
1041 Table_Index_Type
=> Natural,
1042 Table_Low_Bound
=> 1,
1043 Table_Initial
=> 50,
1044 Table_Increment
=> 50);
1045 -- A table to store the object dirs, before creating the object path file
1047 type Private_Project_Tree_Data
is record
1048 Namings
: Naming_Table
.Instance
;
1049 Path_Files
: Path_File_Table
.Instance
;
1050 Source_Paths
: Source_Path_Table
.Instance
;
1051 Object_Paths
: Object_Path_Table
.Instance
;
1052 Default_Naming
: Naming_Data
;