1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2004 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
.OS_Lib
; use GNAT
.OS_Lib
;
40 with System
.HTable
; use System
.HTable
;
45 -- Name_Id for an empty name (no characters). Initialized by the call
46 -- to procedure Initialize.
48 All_Packages
: constant String_List_Access
:= null;
49 -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
50 -- Prj.Part, indicating that all packages should be checked.
52 Virtual_Prefix
: constant String := "v$";
53 -- The prefix for virtual extending projects. Because of the '$', which is
54 -- normally forbidden for project names, there cannot be any name clash.
56 Project_File_Extension
: String := ".gpr";
57 -- The standard project file name extension. It is not a constant, because
58 -- Canonical_Case_File_Name is called on this variable in the body of Prj.
60 Default_Ada_Spec_Suffix
: Name_Id
;
61 -- The Name_Id for the standard GNAT suffix for Ada spec source file
62 -- name ".ads". Initialized by Prj.Initialize.
64 Default_Ada_Body_Suffix
: Name_Id
;
65 -- The Name_Id for the standard GNAT suffix for Ada body source file
66 -- name ".adb". Initialized by Prj.Initialize.
69 -- "/", used as the path of locally removed files
71 type Language_Index
is new Nat
;
73 No_Language_Index
: constant Language_Index
:= 0;
74 First_Language_Index
: constant Language_Index
:= 1;
75 First_Language_Indexes_Last
: constant Language_Index
:= 5;
77 Ada_Language_Index
: constant Language_Index
:=
79 C_Language_Index
: constant Language_Index
:=
80 Ada_Language_Index
+ 1;
81 C_Plus_Plus_Language_Index
: constant Language_Index
:=
84 Last_Language_Index
: Language_Index
:= No_Language_Index
;
86 subtype First_Language_Indexes
is Language_Index
87 range First_Language_Index
.. First_Language_Indexes_Last
;
89 type Header_Num
is range 0 .. 2047;
91 function Hash
is new System
.HTable
.Hash
(Header_Num
=> Header_Num
);
93 function Hash
(Name
: Name_Id
) return Header_Num
;
95 package Language_Indexes
is new System
.HTable
.Simple_HTable
96 (Header_Num
=> Header_Num
,
97 Element
=> Language_Index
,
98 No_Element
=> No_Language_Index
,
102 -- Mapping of language names to language indexes
104 package Language_Names
is new Table
.Table
105 (Table_Component_Type
=> Name_Id
,
106 Table_Index_Type
=> Language_Index
,
107 Table_Low_Bound
=> 1,
109 Table_Increment
=> 100,
110 Table_Name
=> "Prj.Language_Names");
111 -- The table for the name of programming languages
113 procedure Add_Language_Name
(Name
: Name_Id
);
115 procedure Display_Language_Name
(Language
: Language_Index
);
117 type Languages_In_Project
is array (First_Language_Indexes
) of Boolean;
118 -- Set of supported languages used in a project
120 No_Languages
: constant Languages_In_Project
:= (others => False);
121 -- No supported languages are used
123 type Supp_Language_Index
is new Nat
;
124 No_Supp_Language_Index
: constant Supp_Language_Index
:= 0;
126 type Supp_Language
is record
127 Index
: Language_Index
:= No_Language_Index
;
128 Present
: Boolean := False;
129 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
132 package Present_Languages
is new Table
.Table
133 (Table_Component_Type
=> Supp_Language
,
134 Table_Index_Type
=> Supp_Language_Index
,
135 Table_Low_Bound
=> 1,
137 Table_Increment
=> 100,
138 Table_Name
=> "Prj.Present_Languages");
139 -- The table for the presence of languages with an index that is outside
140 -- of First_Language_Indexes.
142 type Impl_Suffix_Array
is array (First_Language_Indexes
) of Name_Id
;
143 -- Suffixes for the non spec sources of the different supported languages
146 No_Impl_Suffixes
: constant Impl_Suffix_Array
:= (others => No_Name
);
147 -- A default value for the non spec source suffixes
149 type Supp_Suffix
is record
150 Index
: Language_Index
:= No_Language_Index
;
151 Suffix
: Name_Id
:= No_Name
;
152 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
155 package Supp_Suffix_Table
is new Table
.Table
156 (Table_Component_Type
=> Supp_Suffix
,
157 Table_Index_Type
=> Supp_Language_Index
,
158 Table_Low_Bound
=> 1,
160 Table_Increment
=> 100,
161 Table_Name
=> "Prj.Supp_Suffix_Table");
162 -- The table for the presence of languages with an index that is outside
163 -- of First_Language_Indexes.
165 type Language_Kind
is (GNU
, other
);
167 type Name_List_Index
is new Nat
;
168 No_Name_List
: constant Name_List_Index
:= 0;
170 type Name_Node
is record
171 Name
: Name_Id
:= No_Name
;
172 Next
: Name_List_Index
:= No_Name_List
;
175 package Name_Lists
is new Table
.Table
176 (Table_Component_Type
=> Name_Node
,
177 Table_Index_Type
=> Name_List_Index
,
178 Table_Low_Bound
=> 1,
180 Table_Increment
=> 100,
181 Table_Name
=> "Prj.Name_Lists");
182 -- The table for lists of names used in package Language_Processing
184 type Language_Processing_Data
is record
185 Compiler_Drivers
: Name_List_Index
:= No_Name_List
;
186 Compiler_Paths
: Name_Id
:= No_Name
;
187 Compiler_Kinds
: Language_Kind
:= GNU
;
188 Dependency_Options
: Name_List_Index
:= No_Name_List
;
189 Compute_Dependencies
: Name_List_Index
:= No_Name_List
;
190 Include_Options
: Name_List_Index
:= No_Name_List
;
191 Binder_Drivers
: Name_Id
:= No_Name
;
192 Binder_Driver_Paths
: Name_Id
:= No_Name
;
195 Default_Language_Processing_Data
:
196 constant Language_Processing_Data
:=
197 (Compiler_Drivers
=> No_Name_List
,
198 Compiler_Paths
=> No_Name
,
199 Compiler_Kinds
=> GNU
,
200 Dependency_Options
=> No_Name_List
,
201 Compute_Dependencies
=> No_Name_List
,
202 Include_Options
=> No_Name_List
,
203 Binder_Drivers
=> No_Name
,
204 Binder_Driver_Paths
=> No_Name
);
206 type First_Language_Processing_Data
is
207 array (First_Language_Indexes
) of Language_Processing_Data
;
209 Default_First_Language_Processing_Data
: First_Language_Processing_Data
:=
210 (others => Default_Language_Processing_Data
);
212 type Supp_Language_Data
is record
213 Index
: Language_Index
:= No_Language_Index
;
214 Data
: Language_Processing_Data
:= Default_Language_Processing_Data
;
215 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
218 package Supp_Languages
is new Table
.Table
219 (Table_Component_Type
=> Supp_Language_Data
,
220 Table_Index_Type
=> Supp_Language_Index
,
221 Table_Low_Bound
=> 1,
223 Table_Increment
=> 100,
224 Table_Name
=> "Prj.Supp_Languages");
225 -- The table for language data when there are more languages than
226 -- in First_Language_Indexes.
228 type Other_Source_Id
is new Nat
;
229 No_Other_Source
: constant Other_Source_Id
:= 0;
230 type Other_Source
is record
231 Language
: Language_Index
; -- language of the source
232 File_Name
: Name_Id
; -- source file simple name
233 Path_Name
: Name_Id
; -- source full path name
234 Source_TS
: Time_Stamp_Type
; -- source file time stamp
235 Object_Name
: Name_Id
; -- object file simple name
236 Object_Path
: Name_Id
; -- object full path name
237 Object_TS
: Time_Stamp_Type
; -- object file time stamp
238 Dep_Name
: Name_Id
; -- dependency file simple name
239 Dep_Path
: Name_Id
; -- dependency full path name
240 Dep_TS
: Time_Stamp_Type
; -- dependency file time stamp
241 Naming_Exception
: Boolean := False; -- True if a naming exception
242 Next
: Other_Source_Id
:= No_Other_Source
;
244 -- Data for a source in a language other than Ada
246 package Other_Sources
is new Table
.Table
247 (Table_Component_Type
=> Other_Source
,
248 Table_Index_Type
=> Other_Source_Id
,
249 Table_Low_Bound
=> 1,
250 Table_Initial
=> 200,
251 Table_Increment
=> 100,
252 Table_Name
=> "Prj.Other_Sources");
253 -- The table for sources of languages other than Ada
255 type Verbosity
is (Default
, Medium
, High
);
256 -- Verbosity when parsing GNAT Project Files
257 -- Default is default (very quiet, if no errors).
258 -- Medium is more verbose.
259 -- High is extremely verbose.
261 type Lib_Kind
is (Static
, Dynamic
, Relocatable
);
262 type Policy
is (Autonomous
, Compliant
, Controlled
, Restricted
);
263 -- Type to specify the symbol policy, when symbol control is supported.
264 -- See full explanation about this type in package Symbols.
265 -- Autonomous: Create a symbol file without considering any reference
266 -- Compliant: Try to be as compatible as possible with an existing ref
267 -- Controlled: Fail if symbols are not the same as those in the reference
268 -- Restricted: Restrict the symbols to those in the symbol file
270 type Symbol_Record
is record
271 Symbol_File
: Name_Id
:= No_Name
;
272 Reference
: Name_Id
:= No_Name
;
273 Symbol_Policy
: Policy
:= Autonomous
;
275 -- Type to keep the symbol data to be used when building a shared library
277 No_Symbols
: Symbol_Record
:=
278 (Symbol_File
=> No_Name
,
279 Reference
=> No_Name
,
280 Symbol_Policy
=> Autonomous
);
281 -- The default value of the symbol data
283 function Empty_String
return Name_Id
;
284 -- Return the Name_Id for an empty string ""
286 type Project_Id
is new Nat
;
287 No_Project
: constant Project_Id
:= 0;
288 -- Id of a Project File
290 type String_List_Id
is new Nat
;
291 Nil_String
: constant String_List_Id
:= 0;
292 type String_Element
is record
293 Value
: Name_Id
:= No_Name
;
295 Display_Value
: Name_Id
:= No_Name
;
296 Location
: Source_Ptr
:= No_Location
;
297 Flag
: Boolean := False;
298 Next
: String_List_Id
:= Nil_String
;
300 -- To hold values for string list variables and array elements.
301 -- Component Flag may be used for various purposes. For source
302 -- directories, it indicates if the directory contains Ada source(s).
304 package String_Elements
is new Table
.Table
305 (Table_Component_Type
=> String_Element
,
306 Table_Index_Type
=> String_List_Id
,
307 Table_Low_Bound
=> 1,
308 Table_Initial
=> 200,
309 Table_Increment
=> 100,
310 Table_Name
=> "Prj.String_Elements");
311 -- The table for string elements in string lists
313 type Variable_Kind
is (Undefined
, List
, Single
);
314 -- Different kinds of variables
316 subtype Defined_Variable_Kind
is Variable_Kind
range List
.. Single
;
317 -- The defined kinds of variables
319 Ignored
: constant Variable_Kind
:= Single
;
320 -- Used to indicate that a package declaration must be ignored
321 -- while processing the project tree (unknown package name).
323 type Variable_Value
(Kind
: Variable_Kind
:= Undefined
) is record
324 Project
: Project_Id
:= No_Project
;
325 Location
: Source_Ptr
:= No_Location
;
326 Default
: Boolean := False;
331 Values
: String_List_Id
:= Nil_String
;
333 Value
: Name_Id
:= No_Name
;
337 -- Values for variables and array elements. Default is True if the
338 -- current value is the default one for the variable
340 Nil_Variable_Value
: constant Variable_Value
:=
341 (Project
=> No_Project
,
343 Location
=> No_Location
,
345 -- Value of a non existing variable or array element
347 type Variable_Id
is new Nat
;
348 No_Variable
: constant Variable_Id
:= 0;
349 type Variable
is record
350 Next
: Variable_Id
:= No_Variable
;
352 Value
: Variable_Value
;
354 -- To hold the list of variables in a project file and in packages
356 package Variable_Elements
is new Table
.Table
357 (Table_Component_Type
=> Variable
,
358 Table_Index_Type
=> Variable_Id
,
359 Table_Low_Bound
=> 1,
360 Table_Initial
=> 200,
361 Table_Increment
=> 100,
362 Table_Name
=> "Prj.Variable_Elements");
363 -- The table of variable in list of variables
365 type Array_Element_Id
is new Nat
;
366 No_Array_Element
: constant Array_Element_Id
:= 0;
367 type Array_Element
is record
369 Src_Index
: Int
:= 0;
370 Index_Case_Sensitive
: Boolean := True;
371 Value
: Variable_Value
;
372 Next
: Array_Element_Id
:= No_Array_Element
;
374 -- Each Array_Element represents an array element and is linked (Next)
375 -- to the next array element, if any, in the array.
377 package Array_Elements
is new Table
.Table
378 (Table_Component_Type
=> Array_Element
,
379 Table_Index_Type
=> Array_Element_Id
,
380 Table_Low_Bound
=> 1,
381 Table_Initial
=> 200,
382 Table_Increment
=> 100,
383 Table_Name
=> "Prj.Array_Elements");
384 -- The table that contains all array elements
386 type Array_Id
is new Nat
;
387 No_Array
: constant Array_Id
:= 0;
388 type Array_Data
is record
389 Name
: Name_Id
:= No_Name
;
390 Value
: Array_Element_Id
:= No_Array_Element
;
391 Next
: Array_Id
:= No_Array
;
393 -- Each Array_Data value represents an array.
394 -- Value is the id of the first element.
395 -- Next is the id of the next array in the project file or package.
397 package Arrays
is new Table
.Table
398 (Table_Component_Type
=> Array_Data
,
399 Table_Index_Type
=> Array_Id
,
400 Table_Low_Bound
=> 1,
401 Table_Initial
=> 200,
402 Table_Increment
=> 100,
403 Table_Name
=> "Prj.Arrays");
404 -- The table that contains all arrays
406 type Package_Id
is new Nat
;
407 No_Package
: constant Package_Id
:= 0;
408 type Declarations
is record
409 Variables
: Variable_Id
:= No_Variable
;
410 Attributes
: Variable_Id
:= No_Variable
;
411 Arrays
: Array_Id
:= No_Array
;
412 Packages
: Package_Id
:= No_Package
;
414 -- Contains the declarations (variables, single and array attributes,
415 -- packages) for a project or a package in a project.
417 No_Declarations
: constant Declarations
:=
418 (Variables
=> No_Variable
,
419 Attributes
=> No_Variable
,
421 Packages
=> No_Package
);
422 -- Default value of Declarations: indicates that there is no declarations.
424 type Package_Element
is record
425 Name
: Name_Id
:= No_Name
;
426 Decl
: Declarations
:= No_Declarations
;
427 Parent
: Package_Id
:= No_Package
;
428 Next
: Package_Id
:= No_Package
;
430 -- A package. Includes declarations that may include other packages.
432 package Packages
is new Table
.Table
433 (Table_Component_Type
=> Package_Element
,
434 Table_Index_Type
=> Package_Id
,
435 Table_Low_Bound
=> 1,
436 Table_Initial
=> 100,
437 Table_Increment
=> 100,
438 Table_Name
=> "Prj.Packages");
439 -- The table that contains all packages.
441 function Image
(Casing
: Casing_Type
) return String;
442 -- Similar to 'Image (but avoid use of this attribute in compiler)
444 function Value
(Image
: String) return Casing_Type
;
445 -- Similar to 'Value (but avoid use of this attribute in compiler)
446 -- Raises Constraint_Error if not a Casing_Type image.
448 -- The following record contains data for a naming scheme
450 type Naming_Data
is record
452 Dot_Replacement
: Name_Id
:= No_Name
;
453 -- The string to replace '.' in the source file name (for Ada).
455 Dot_Repl_Loc
: Source_Ptr
:= No_Location
;
456 -- The position in the project file source where
457 -- Dot_Replacement is defined.
459 Casing
: Casing_Type
:= All_Lower_Case
;
460 -- The casing of the source file name (for Ada).
462 Spec_Suffix
: Array_Element_Id
:= No_Array_Element
;
463 -- The string to append to the unit name for the
464 -- source file name of a spec.
465 -- Indexed by the programming language.
467 Ada_Spec_Suffix
: Name_Id
:= No_Name
;
468 -- The suffix of the Ada spec sources
470 Spec_Suffix_Loc
: Source_Ptr
:= No_Location
;
471 -- The position in the project file source where
472 -- Ada_Spec_Suffix is defined.
474 Impl_Suffixes
: Impl_Suffix_Array
:= No_Impl_Suffixes
;
475 Supp_Suffixes
: Supp_Language_Index
:= No_Supp_Language_Index
;
476 -- The source suffixes of the different languages
478 Body_Suffix
: Array_Element_Id
:= No_Array_Element
;
479 -- The string to append to the unit name for the
480 -- source file name of a body.
481 -- Indexed by the programming language.
483 Ada_Body_Suffix
: Name_Id
:= No_Name
;
484 -- The suffix of the Ada body sources
486 Body_Suffix_Loc
: Source_Ptr
:= No_Location
;
487 -- The position in the project file source where
488 -- Ada_Body_Suffix is defined.
490 Separate_Suffix
: Name_Id
:= No_Name
;
491 -- String to append to unit name for source file name of an Ada subunit.
493 Sep_Suffix_Loc
: Source_Ptr
:= No_Location
;
494 -- Position in the project file source where Separate_Suffix is defined.
496 Specs
: Array_Element_Id
:= No_Array_Element
;
497 -- An associative array mapping individual specs to source file names.
498 -- This is specific to Ada.
500 Bodies
: Array_Element_Id
:= No_Array_Element
;
501 -- An associative array mapping individual bodies to source file names.
502 -- This is specific to Ada.
504 Specification_Exceptions
: Array_Element_Id
:= No_Array_Element
;
505 -- An associative array listing spec file names that do not have the
506 -- spec suffix. Not used by Ada. Indexed by programming language name.
508 Implementation_Exceptions
: Array_Element_Id
:= No_Array_Element
;
509 -- An associative array listing body file names that do not have the
510 -- body suffix. Not used by Ada. Indexed by programming language name.
514 function Standard_Naming_Data
return Naming_Data
;
515 pragma Inline
(Standard_Naming_Data
);
516 -- The standard GNAT naming scheme
518 function Same_Naming_Scheme
519 (Left
, Right
: Naming_Data
) return Boolean;
520 -- Returns True if Left and Right are the same naming scheme
521 -- not considering Specs and Bodies.
523 type Project_List
is new Nat
;
524 Empty_Project_List
: constant Project_List
:= 0;
525 -- A list of project files
527 type Project_Element
is record
528 Project
: Project_Id
:= No_Project
;
529 Next
: Project_List
:= Empty_Project_List
;
531 -- Element in a list of project files. Next is the id of the next
532 -- project file in the list.
534 package Project_Lists
is new Table
.Table
535 (Table_Component_Type
=> Project_Element
,
536 Table_Index_Type
=> Project_List
,
537 Table_Low_Bound
=> 1,
538 Table_Initial
=> 100,
539 Table_Increment
=> 100,
540 Table_Name
=> "Prj.Project_Lists");
541 -- The table that contains the lists of project files
543 -- The following record describes a project file representation
545 type Project_Data
is record
546 Externally_Built
: Boolean := False;
548 Languages
: Languages_In_Project
:= No_Languages
;
549 Supp_Languages
: Supp_Language_Index
:= No_Supp_Language_Index
;
550 -- Indicate the different languages of the source of this project
552 First_Referred_By
: Project_Id
:= No_Project
;
553 -- The project, if any, that was the first to be known
554 -- as importing or extending this project.
555 -- Set by Prj.Proc.Process.
557 Name
: Name_Id
:= No_Name
;
558 -- The name of the project. Set by Prj.Proc.Process.
560 Path_Name
: Name_Id
:= No_Name
;
561 -- The path name of the project file. Set by Prj.Proc.Process.
563 Display_Path_Name
: Name_Id
:= No_Name
;
564 -- The path name used for display purposes. May be different from
565 -- Path_Name for platforms where the file names are case-insensitive.
567 Virtual
: Boolean := False;
568 -- True for virtual extending projects
570 Location
: Source_Ptr
:= No_Location
;
571 -- The location in the project file source of the reserved word
572 -- project. Set by Prj.Proc.Process.
574 Mains
: String_List_Id
:= Nil_String
;
575 -- List of mains specified by attribute Main. Set by Prj.Nmsc.Check.
577 Directory
: Name_Id
:= No_Name
;
578 -- Directory where the project file resides. Set by Prj.Proc.Process.
580 Display_Directory
: Name_Id
:= No_Name
;
582 Dir_Path
: String_Access
;
583 -- Same as Directory, but as an access to String.
584 -- Set by Make.Compile_Sources.Collect_Arguments_And_Compile.
586 Library
: Boolean := False;
587 -- True if this is a library project.
588 -- Set by Prj.Nmsc.Language_Independent_Check.
590 Library_Dir
: Name_Id
:= No_Name
;
591 -- If a library project, directory where resides the library
592 -- Set by Prj.Nmsc.Language_Independent_Check.
594 Display_Library_Dir
: Name_Id
:= No_Name
;
595 -- The name of the library directory, for display purposes.
596 -- May be different from Library_Dir for platforms where the file names
597 -- are case-insensitive.
599 Library_Src_Dir
: Name_Id
:= No_Name
;
600 -- If a library project, directory where the sources and the ALI files
601 -- of the library are copied. By default, if attribute Library_Src_Dir
602 -- is not specified, sources are not copied anywhere and ALI files are
603 -- copied in the Library Directory.
604 -- Set by Prj.Nmsc.Language_Independent_Check.
606 Display_Library_Src_Dir
: Name_Id
:= No_Name
;
607 -- The name of the library source directory, for display purposes.
608 -- May be different from Library_Src_Dir for platforms where the file
609 -- names are case-insensitive.
611 Library_Name
: Name_Id
:= No_Name
;
612 -- If a library project, name of the library
613 -- Set by Prj.Nmsc.Language_Independent_Check.
615 Library_Kind
: Lib_Kind
:= Static
;
616 -- If a library project, kind of library
617 -- Set by Prj.Nmsc.Language_Independent_Check.
619 Lib_Internal_Name
: Name_Id
:= No_Name
;
620 -- If a library project, internal name store inside the library
621 -- Set by Prj.Nmsc.Language_Independent_Check.
623 Standalone_Library
: Boolean := False;
624 -- Indicate that this is a Standalone Library Project File.
625 -- Set by Prj.Nmsc.Check.
627 Lib_Interface_ALIs
: String_List_Id
:= Nil_String
;
628 -- For Standalone Library Project Files, indicate the list
629 -- of Interface ALI files. Set by Prj.Nmsc.Check.
631 Lib_Auto_Init
: Boolean := False;
632 -- For non static Standalone Library Project Files, indicate if
633 -- the library initialisation should be automatic.
635 Symbol_Data
: Symbol_Record
:= No_Symbols
;
636 -- Symbol file name, reference symbol file name, symbol policy
638 Ada_Sources_Present
: Boolean := True;
639 -- A flag that indicates if there are Ada sources in this project file.
640 -- There are no sources if any of the following is true:
641 -- 1) Source_Dirs is specified as an empty list
642 -- 2) Source_Files is specified as an empty list
643 -- 3) Ada is not in the list of the specified Languages
645 Other_Sources_Present
: Boolean := True;
646 -- A flag that indicates that there are non-Ada sources in this project
648 Sources
: String_List_Id
:= Nil_String
;
649 -- The list of all the source file names. Set by
650 -- Prj.Nmsc.Check_Ada_Naming_Scheme.
652 First_Other_Source
: Other_Source_Id
:= No_Other_Source
;
653 Last_Other_Source
: Other_Source_Id
:= No_Other_Source
;
654 -- Head and tail of the list of sources of languages other than Ada
656 Imported_Directories_Switches
: Argument_List_Access
:= null;
657 -- List of the -I switches to be used when compiling sources of
658 -- languages other than Ada.
660 Include_Path
: String_Access
:= null;
661 -- Value to be used as CPATH, when using a GCC, instead of a list of
664 Include_Data_Set
: Boolean := False;
665 -- Set True when Imported_Directories_Switches or Include_Path are set
667 Source_Dirs
: String_List_Id
:= Nil_String
;
668 -- The list of all the source directories.
669 -- Set by Prj.Nmsc.Language_Independent_Check.
671 Known_Order_Of_Source_Dirs
: Boolean := True;
672 -- False, if there is any /** in the Source_Dirs, because in this case
673 -- the ordering of the source subdirs depend on the OS. If True,
674 -- duplicate file names in the same project file are allowed.
676 Object_Directory
: Name_Id
:= No_Name
;
677 -- The object directory of this project file.
678 -- Set by Prj.Nmsc.Language_Independent_Check.
680 Display_Object_Dir
: Name_Id
:= No_Name
;
681 -- The name of the object directory, for display purposes.
682 -- May be different from Object_Directory for platforms where the file
683 -- names are case-insensitive.
685 Exec_Directory
: Name_Id
:= No_Name
;
686 -- The exec directory of this project file. Default is equal to
687 -- Object_Directory. Set by Prj.Nmsc.Language_Independent_Check.
689 Display_Exec_Dir
: Name_Id
:= No_Name
;
690 -- The name of the exec directory, for display purposes.
691 -- May be different from Exec_Directory for platforms where the file
692 -- names are case-insensitive.
694 Extends
: Project_Id
:= No_Project
;
695 -- The reference of the project file, if any, that this
696 -- project file extends. Set by Prj.Proc.Process.
698 Extended_By
: Project_Id
:= No_Project
;
699 -- The reference of the project file, if any, that
700 -- extends this project file. Set by Prj.Proc.Process.
702 Naming
: Naming_Data
:= Standard_Naming_Data
;
703 -- The naming scheme of this project file.
704 -- Set by Prj.Nmsc.Check_Naming_Scheme.
706 First_Language_Processing
: First_Language_Processing_Data
:=
707 Default_First_Language_Processing_Data
;
709 Supp_Language_Processing
: Supp_Language_Index
:=
710 No_Supp_Language_Index
;
712 Default_Linker
: Name_Id
:= No_Name
;
713 Default_Linker_Path
: Name_Id
:= No_Name
;
715 Decl
: Declarations
:= No_Declarations
;
716 -- The declarations (variables, attributes and packages) of this
717 -- project file. Set by Prj.Proc.Process.
719 Imported_Projects
: Project_List
:= Empty_Project_List
;
720 -- The list of all directly imported projects, if any.
721 -- Set by Prj.Proc.Process.
723 Ada_Include_Path
: String_Access
:= null;
724 -- The cached value of ADA_INCLUDE_PATH for this project file.
725 -- Do not use this field directly outside of the compiler, use
726 -- Prj.Env.Ada_Include_Path instead. Set by Prj.Env.Ada_Include_Path.
728 Ada_Objects_Path
: String_Access
:= null;
729 -- The cached value of ADA_OBJECTS_PATH for this project file.
730 -- Do not use this field directly outside of the compiler, use
731 -- Prj.Env.Ada_Objects_Path instead. Set by Prj.Env.Ada_Objects_Path
733 Include_Path_File
: Name_Id
:= No_Name
;
734 -- The cached value of the source path temp file for this project file.
735 -- Set by gnatmake (Prj.Env.Set_Ada_Paths).
737 Objects_Path_File_With_Libs
: Name_Id
:= No_Name
;
738 -- The cached value of the object path temp file (including library
739 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
741 Objects_Path_File_Without_Libs
: Name_Id
:= No_Name
;
742 -- The cached value of the object path temp file (excluding library
743 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
745 Config_File_Name
: Name_Id
:= No_Name
;
746 -- The name of the configuration pragmas file, if any.
747 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
749 Config_File_Temp
: Boolean := False;
750 -- An indication that the configuration pragmas file is
751 -- a temporary file that must be deleted at the end.
752 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
754 Config_Checked
: Boolean := False;
755 -- A flag to avoid checking repetitively the configuration pragmas file.
756 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
758 Language_Independent_Checked
: Boolean := False;
759 -- A flag that indicates that the project file has been checked
760 -- for language independent features: Object_Directory,
761 -- Source_Directories, Library, non empty Naming Suffixes.
763 Checked
: Boolean := False;
764 -- A flag to avoid checking repetitively the naming scheme of
765 -- this project file. Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
767 Seen
: Boolean := False;
768 -- A flag to mark a project as "visited" to avoid processing the same
769 -- project several time.
771 Need_To_Build_Lib
: Boolean := False;
772 -- Indicates that the library of a Library Project needs to be built or
775 Depth
: Natural := 0;
776 -- The maximum depth of a project in the project graph.
777 -- Depth of main project is 0.
779 Unkept_Comments
: Boolean := False;
780 -- True if there are comments in the project sources that cannot
781 -- be kept in the project tree.
786 (Language
: Language_Index
;
787 In_Project
: Project_Data
) return Boolean;
788 -- Return True when Language is one of the languages used in
792 (Language
: Language_Index
;
794 In_Project
: in out Project_Data
);
795 -- Indicate if Language is or not a language used in project Project
797 function Language_Processing_Data_Of
798 (Language
: Language_Index
;
799 In_Project
: Project_Data
) return Language_Processing_Data
;
800 -- Return the Language_Processing_Data for language Language in project
801 -- In_Project. Return the default when no Language_Processing_Data are
802 -- defined for the language.
805 (Language_Processing
: Language_Processing_Data
;
806 For_Language
: Language_Index
;
807 In_Project
: in out Project_Data
);
808 -- Set the Language_Processing_Data for language Language in project
812 (Language
: Language_Index
;
813 In_Project
: Project_Data
) return Name_Id
;
814 -- Return the suffix for language Language in project In_Project. Return
815 -- No_Name when no suffix is defined for the language.
819 For_Language
: Language_Index
;
820 In_Project
: in out Project_Data
);
821 -- Set the suffix for language Language in project In_Project
823 Project_Error
: exception;
824 -- Raised by some subprograms in Prj.Attr.
826 function Empty_Project
return Project_Data
;
827 -- Return the representation of an empty project
829 package Projects
is new Table
.Table
(
830 Table_Component_Type
=> Project_Data
,
831 Table_Index_Type
=> Project_Id
,
832 Table_Low_Bound
=> 1,
833 Table_Initial
=> 100,
834 Table_Increment
=> 100,
835 Table_Name
=> "Prj.Projects");
836 -- The set of all project files
838 type Put_Line_Access
is access procedure
840 Project
: Project_Id
);
841 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
843 procedure Expect
(The_Token
: Token_Type
; Token_Image
: String);
844 -- Check that the current token is The_Token. If it is not, then
845 -- output an error message.
847 procedure Initialize
;
848 -- This procedure must be called before using any services from the Prj
849 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
852 -- This procedure resets all the tables that are used when processing a
853 -- project file tree. Initialize must be called before the call to Reset.
855 procedure Register_Default_Naming_Scheme
857 Default_Spec_Suffix
: Name_Id
;
858 Default_Body_Suffix
: Name_Id
);
859 -- Register the default suffixes for a given language. These extensions
860 -- will be ignored if the user has specified a new naming scheme in a
863 -- Otherwise, this information will be automatically added to Naming_Data
864 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
867 type State
is limited private;
868 with procedure Action
869 (Project
: Project_Id
;
870 With_State
: in out State
);
871 procedure For_Every_Project_Imported
873 With_State
: in out State
);
874 -- Call Action for each project imported directly or indirectly by project
875 -- By. Action is called according to the order of importation: if A
876 -- imports B, directly or indirectly, Action will be called for A before
877 -- it is called for B. With_State may be used by Action to choose a
878 -- behavior or to report some global result.
882 Initial_Buffer_Size
: constant := 100;
883 -- Initial size for extensible buffer used below
885 Buffer
: String_Access
:= new String (1 .. Initial_Buffer_Size
);
886 -- An extensible character buffer to store names. Used in Prj.Part and
889 Buffer_Last
: Natural := 0;
890 -- The index of the last character in the Buffer
892 Current_Packages_To_Check
: String_List_Access
:= All_Packages
;
893 -- Global variable, set by Prj.Part.Parse, used by Prj.Dect.
895 procedure Add_To_Buffer
(S
: String);
896 -- Append a String to the Buffer