* loop-invariant.c (invariant_for_use, check_dependencies): Fail for
[official-gcc.git] / gcc / ada / prj.ads
blob474920460e11d99fb79cbadb12d9dbec6ee362ca
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2005, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 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. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
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;
35 with Table;
36 with Types; use Types;
38 with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
39 with GNAT.Dynamic_Tables;
40 with GNAT.OS_Lib; use GNAT.OS_Lib;
42 with System.HTable;
44 package Prj is
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 type Error_Warning is (Silent, Warning, Error);
76 -- Severity of some situations, such as: no Ada sources in a project where
77 -- Ada is one of the language.
79 -- When the situation occurs, the behaviour depends on the setting:
81 -- - Silent: no action
82 -- - Warning: issue a warning, does not cause the tool to fail
83 -- - Error: issue an error, causes the tool to fail
85 -----------------------------------------------------
86 -- Multi-language Stuff That Will be Modified Soon --
87 -----------------------------------------------------
89 -- Still should be properly commented ???
91 type Language_Index is new Nat;
93 No_Language_Index : constant Language_Index := 0;
94 First_Language_Index : constant Language_Index := 1;
95 First_Language_Indexes_Last : constant Language_Index := 5;
97 Ada_Language_Index : constant Language_Index :=
98 First_Language_Index;
99 C_Language_Index : constant Language_Index :=
100 Ada_Language_Index + 1;
101 C_Plus_Plus_Language_Index : constant Language_Index :=
102 C_Language_Index + 1;
104 Last_Language_Index : Language_Index := No_Language_Index;
106 subtype First_Language_Indexes is Language_Index
107 range First_Language_Index .. First_Language_Indexes_Last;
109 type Header_Num is range 0 .. 2047;
111 function Hash is new System.HTable.Hash (Header_Num => Header_Num);
113 function Hash (Name : Name_Id) return Header_Num;
115 package Language_Indexes is new System.HTable.Simple_HTable
116 (Header_Num => Header_Num,
117 Element => Language_Index,
118 No_Element => No_Language_Index,
119 Key => Name_Id,
120 Hash => Hash,
121 Equal => "=");
122 -- Mapping of language names to language indexes
124 package Language_Names is new Table.Table
125 (Table_Component_Type => Name_Id,
126 Table_Index_Type => Language_Index,
127 Table_Low_Bound => 1,
128 Table_Initial => 4,
129 Table_Increment => 100,
130 Table_Name => "Prj.Language_Names");
131 -- The table for the name of programming languages
133 procedure Add_Language_Name (Name : Name_Id);
135 procedure Display_Language_Name (Language : Language_Index);
137 type Languages_In_Project is array (First_Language_Indexes) of Boolean;
138 -- Set of supported languages used in a project
140 No_Languages : constant Languages_In_Project := (others => False);
141 -- No supported languages are used
143 type Supp_Language_Index is new Nat;
144 No_Supp_Language_Index : constant Supp_Language_Index := 0;
146 type Supp_Language is record
147 Index : Language_Index := No_Language_Index;
148 Present : Boolean := False;
149 Next : Supp_Language_Index := No_Supp_Language_Index;
150 end record;
152 package Present_Language_Table is new GNAT.Dynamic_Tables
153 (Table_Component_Type => Supp_Language,
154 Table_Index_Type => Supp_Language_Index,
155 Table_Low_Bound => 1,
156 Table_Initial => 4,
157 Table_Increment => 100);
158 -- The table for the presence of languages with an index that is outside
159 -- of First_Language_Indexes.
161 type Impl_Suffix_Array is array (First_Language_Indexes) of Name_Id;
162 -- Suffixes for the non spec sources of the different supported languages
163 -- in a project.
165 No_Impl_Suffixes : constant Impl_Suffix_Array := (others => No_Name);
166 -- A default value for the non spec source suffixes
168 type Supp_Suffix is record
169 Index : Language_Index := No_Language_Index;
170 Suffix : Name_Id := No_Name;
171 Next : Supp_Language_Index := No_Supp_Language_Index;
172 end record;
174 package Supp_Suffix_Table is new GNAT.Dynamic_Tables
175 (Table_Component_Type => Supp_Suffix,
176 Table_Index_Type => Supp_Language_Index,
177 Table_Low_Bound => 1,
178 Table_Initial => 4,
179 Table_Increment => 100);
180 -- The table for the presence of languages with an index that is outside
181 -- of First_Language_Indexes.
183 type Language_Kind is (GNU, other);
185 type Name_List_Index is new Nat;
186 No_Name_List : constant Name_List_Index := 0;
188 type Name_Node is record
189 Name : Name_Id := No_Name;
190 Next : Name_List_Index := No_Name_List;
191 end record;
193 package Name_List_Table is new GNAT.Dynamic_Tables
194 (Table_Component_Type => Name_Node,
195 Table_Index_Type => Name_List_Index,
196 Table_Low_Bound => 1,
197 Table_Initial => 10,
198 Table_Increment => 100);
199 -- The table for lists of names used in package Language_Processing
201 type Language_Processing_Data is record
202 Compiler_Drivers : Name_List_Index := No_Name_List;
203 Compiler_Paths : Name_Id := No_Name;
204 Compiler_Kinds : Language_Kind := GNU;
205 Dependency_Options : Name_List_Index := No_Name_List;
206 Compute_Dependencies : Name_List_Index := No_Name_List;
207 Include_Options : Name_List_Index := No_Name_List;
208 Binder_Drivers : Name_Id := No_Name;
209 Binder_Driver_Paths : Name_Id := No_Name;
210 end record;
212 Default_Language_Processing_Data :
213 constant Language_Processing_Data :=
214 (Compiler_Drivers => No_Name_List,
215 Compiler_Paths => No_Name,
216 Compiler_Kinds => GNU,
217 Dependency_Options => No_Name_List,
218 Compute_Dependencies => No_Name_List,
219 Include_Options => No_Name_List,
220 Binder_Drivers => No_Name,
221 Binder_Driver_Paths => No_Name);
223 type First_Language_Processing_Data is
224 array (First_Language_Indexes) of Language_Processing_Data;
226 Default_First_Language_Processing_Data :
227 constant First_Language_Processing_Data :=
228 (others => Default_Language_Processing_Data);
230 type Supp_Language_Data is record
231 Index : Language_Index := No_Language_Index;
232 Data : Language_Processing_Data := Default_Language_Processing_Data;
233 Next : Supp_Language_Index := No_Supp_Language_Index;
234 end record;
236 package Supp_Language_Table is new GNAT.Dynamic_Tables
237 (Table_Component_Type => Supp_Language_Data,
238 Table_Index_Type => Supp_Language_Index,
239 Table_Low_Bound => 1,
240 Table_Initial => 4,
241 Table_Increment => 100);
242 -- The table for language data when there are more languages than
243 -- in First_Language_Indexes.
245 type Other_Source_Id is new Nat;
246 No_Other_Source : constant Other_Source_Id := 0;
248 type Other_Source is record
249 Language : Language_Index; -- language of the source
250 File_Name : Name_Id; -- source file simple name
251 Path_Name : Name_Id; -- source full path name
252 Source_TS : Time_Stamp_Type; -- source file time stamp
253 Object_Name : Name_Id; -- object file simple name
254 Object_Path : Name_Id; -- object full path name
255 Object_TS : Time_Stamp_Type; -- object file time stamp
256 Dep_Name : Name_Id; -- dependency file simple name
257 Dep_Path : Name_Id; -- dependency full path name
258 Dep_TS : Time_Stamp_Type; -- dependency file time stamp
259 Naming_Exception : Boolean := False; -- True if a naming exception
260 Next : Other_Source_Id := No_Other_Source;
261 end record;
262 -- Data for a source in a language other than Ada
264 package Other_Source_Table is new GNAT.Dynamic_Tables
265 (Table_Component_Type => Other_Source,
266 Table_Index_Type => Other_Source_Id,
267 Table_Low_Bound => 1,
268 Table_Initial => 200,
269 Table_Increment => 100);
270 -- The table for sources of languages other than Ada
272 ----------------------------------
273 -- End of multi-language stuff --
274 ----------------------------------
276 type Verbosity is (Default, Medium, High);
277 -- Verbosity when parsing GNAT Project Files
278 -- Default is default (very quiet, if no errors).
279 -- Medium is more verbose.
280 -- High is extremely verbose.
282 Current_Verbosity : Verbosity := Default;
283 -- The current value of the verbosity the project files are parsed with
285 type Lib_Kind is (Static, Dynamic, Relocatable);
286 type Policy is (Autonomous, Compliant, Controlled, Restricted);
287 -- Type to specify the symbol policy, when symbol control is supported.
288 -- See full explanation about this type in package Symbols.
289 -- Autonomous: Create a symbol file without considering any reference
290 -- Compliant: Try to be as compatible as possible with an existing ref
291 -- Controlled: Fail if symbols are not the same as those in the reference
292 -- Restricted: Restrict the symbols to those in the symbol file
294 type Symbol_Record is record
295 Symbol_File : Name_Id := No_Name;
296 Reference : Name_Id := No_Name;
297 Symbol_Policy : Policy := Autonomous;
298 end record;
299 -- Type to keep the symbol data to be used when building a shared library
301 No_Symbols : constant Symbol_Record :=
302 (Symbol_File => No_Name,
303 Reference => No_Name,
304 Symbol_Policy => Autonomous);
305 -- The default value of the symbol data
307 function Empty_String return Name_Id;
308 -- Return the Name_Id for an empty string ""
310 type Project_Id is new Nat;
311 No_Project : constant Project_Id := 0;
312 -- Id of a Project File
314 type String_List_Id is new Nat;
315 Nil_String : constant String_List_Id := 0;
316 type String_Element is record
317 Value : Name_Id := No_Name;
318 Index : Int := 0;
319 Display_Value : Name_Id := No_Name;
320 Location : Source_Ptr := No_Location;
321 Flag : Boolean := False;
322 Next : String_List_Id := Nil_String;
323 end record;
324 -- To hold values for string list variables and array elements.
325 -- Component Flag may be used for various purposes. For source
326 -- directories, it indicates if the directory contains Ada source(s).
328 package String_Element_Table is new GNAT.Dynamic_Tables
329 (Table_Component_Type => String_Element,
330 Table_Index_Type => String_List_Id,
331 Table_Low_Bound => 1,
332 Table_Initial => 200,
333 Table_Increment => 100);
334 -- The table for string elements in string lists
336 type Variable_Kind is (Undefined, List, Single);
337 -- Different kinds of variables
339 subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
340 -- The defined kinds of variables
342 Ignored : constant Variable_Kind;
343 -- Used to indicate that a package declaration must be ignored
344 -- while processing the project tree (unknown package name).
346 type Variable_Value (Kind : Variable_Kind := Undefined) is record
347 Project : Project_Id := No_Project;
348 Location : Source_Ptr := No_Location;
349 Default : Boolean := False;
350 case Kind is
351 when Undefined =>
352 null;
353 when List =>
354 Values : String_List_Id := Nil_String;
355 when Single =>
356 Value : Name_Id := No_Name;
357 Index : Int := 0;
358 end case;
359 end record;
360 -- Values for variables and array elements. Default is True if the
361 -- current value is the default one for the variable
363 Nil_Variable_Value : constant Variable_Value;
364 -- Value of a non existing variable or array element
366 type Variable_Id is new Nat;
367 No_Variable : constant Variable_Id := 0;
368 type Variable is record
369 Next : Variable_Id := No_Variable;
370 Name : Name_Id;
371 Value : Variable_Value;
372 end record;
373 -- To hold the list of variables in a project file and in packages
375 package Variable_Element_Table is new GNAT.Dynamic_Tables
376 (Table_Component_Type => Variable,
377 Table_Index_Type => Variable_Id,
378 Table_Low_Bound => 1,
379 Table_Initial => 200,
380 Table_Increment => 100);
381 -- The table of variable in list of variables
383 type Array_Element_Id is new Nat;
384 No_Array_Element : constant Array_Element_Id := 0;
385 type Array_Element is record
386 Index : Name_Id;
387 Src_Index : Int := 0;
388 Index_Case_Sensitive : Boolean := True;
389 Value : Variable_Value;
390 Next : Array_Element_Id := No_Array_Element;
391 end record;
392 -- Each Array_Element represents an array element and is linked (Next)
393 -- to the next array element, if any, in the array.
395 package Array_Element_Table is new GNAT.Dynamic_Tables
396 (Table_Component_Type => Array_Element,
397 Table_Index_Type => Array_Element_Id,
398 Table_Low_Bound => 1,
399 Table_Initial => 200,
400 Table_Increment => 100);
401 -- The table that contains all array elements
403 type Array_Id is new Nat;
404 No_Array : constant Array_Id := 0;
405 type Array_Data is record
406 Name : Name_Id := No_Name;
407 Value : Array_Element_Id := No_Array_Element;
408 Next : Array_Id := No_Array;
409 end record;
410 -- Each Array_Data value represents an array.
411 -- Value is the id of the first element.
412 -- Next is the id of the next array in the project file or package.
414 package Array_Table is new GNAT.Dynamic_Tables
415 (Table_Component_Type => Array_Data,
416 Table_Index_Type => Array_Id,
417 Table_Low_Bound => 1,
418 Table_Initial => 200,
419 Table_Increment => 100);
420 -- The table that contains all arrays
422 type Package_Id is new Nat;
423 No_Package : constant Package_Id := 0;
424 type Declarations is record
425 Variables : Variable_Id := No_Variable;
426 Attributes : Variable_Id := No_Variable;
427 Arrays : Array_Id := No_Array;
428 Packages : Package_Id := No_Package;
429 end record;
430 -- Contains the declarations (variables, single and array attributes,
431 -- packages) for a project or a package in a project.
433 No_Declarations : constant Declarations :=
434 (Variables => No_Variable,
435 Attributes => No_Variable,
436 Arrays => No_Array,
437 Packages => No_Package);
438 -- Default value of Declarations: indicates that there is no declarations
440 type Package_Element is record
441 Name : Name_Id := No_Name;
442 Decl : Declarations := No_Declarations;
443 Parent : Package_Id := No_Package;
444 Next : Package_Id := No_Package;
445 end record;
446 -- A package (includes declarations that may include other packages)
448 package Package_Table is new GNAT.Dynamic_Tables
449 (Table_Component_Type => Package_Element,
450 Table_Index_Type => Package_Id,
451 Table_Low_Bound => 1,
452 Table_Initial => 100,
453 Table_Increment => 100);
454 -- The table that contains all packages
456 function Image (Casing : Casing_Type) return String;
457 -- Similar to 'Image (but avoid use of this attribute in compiler)
459 function Value (Image : String) return Casing_Type;
460 -- Similar to 'Value (but avoid use of this attribute in compiler)
461 -- Raises Constraint_Error if not a Casing_Type image.
463 -- The following record contains data for a naming scheme
465 type Naming_Data is record
467 Dot_Replacement : Name_Id := No_Name;
468 -- The string to replace '.' in the source file name (for Ada)
470 Dot_Repl_Loc : Source_Ptr := No_Location;
471 -- The position in the project file source where Dot_Replacement is
472 -- defined.
474 Casing : Casing_Type := All_Lower_Case;
475 -- The casing of the source file name (for Ada)
477 Spec_Suffix : Array_Element_Id := No_Array_Element;
478 -- The string to append to the unit name for the
479 -- source file name of a spec.
480 -- Indexed by the programming language.
482 Ada_Spec_Suffix : Name_Id := No_Name;
483 -- The suffix of the Ada spec sources
485 Spec_Suffix_Loc : Source_Ptr := No_Location;
486 -- The position in the project file source where
487 -- Ada_Spec_Suffix is defined.
489 Impl_Suffixes : Impl_Suffix_Array := No_Impl_Suffixes;
490 Supp_Suffixes : Supp_Language_Index := No_Supp_Language_Index;
491 -- The source suffixes of the different languages
493 Body_Suffix : Array_Element_Id := No_Array_Element;
494 -- The string to append to the unit name for the
495 -- source file name of a body.
496 -- Indexed by the programming language.
498 Ada_Body_Suffix : Name_Id := No_Name;
499 -- The suffix of the Ada body sources
501 Body_Suffix_Loc : Source_Ptr := No_Location;
502 -- The position in the project file source where
503 -- Ada_Body_Suffix is defined.
505 Separate_Suffix : Name_Id := No_Name;
506 -- String to append to unit name for source file name of an Ada subunit
508 Sep_Suffix_Loc : Source_Ptr := No_Location;
509 -- Position in the project file source where Separate_Suffix is defined
511 Specs : Array_Element_Id := No_Array_Element;
512 -- An associative array mapping individual specs to source file names
513 -- This is specific to Ada.
515 Bodies : Array_Element_Id := No_Array_Element;
516 -- An associative array mapping individual bodies to source file names
517 -- This is specific to Ada.
519 Specification_Exceptions : Array_Element_Id := No_Array_Element;
520 -- An associative array listing spec file names that do not have the
521 -- spec suffix. Not used by Ada. Indexed by programming language name.
523 Implementation_Exceptions : Array_Element_Id := No_Array_Element;
524 -- An associative array listing body file names that do not have the
525 -- body suffix. Not used by Ada. Indexed by programming language name.
527 end record;
529 function Standard_Naming_Data
530 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
531 pragma Inline (Standard_Naming_Data);
532 -- The standard GNAT naming scheme when Tree is No_Project_Tree.
533 -- Otherwise, return the default naming scheme for the project tree Tree,
534 -- which must have been Initialized.
536 function Same_Naming_Scheme
537 (Left, Right : Naming_Data) return Boolean;
538 -- Returns True if Left and Right are the same naming scheme
539 -- not considering Specs and Bodies.
541 type Project_List is new Nat;
542 Empty_Project_List : constant Project_List := 0;
543 -- A list of project files
545 type Project_Element is record
546 Project : Project_Id := No_Project;
547 Next : Project_List := Empty_Project_List;
548 end record;
549 -- Element in a list of project files. Next is the id of the next
550 -- project file in the list.
552 package Project_List_Table is new GNAT.Dynamic_Tables
553 (Table_Component_Type => Project_Element,
554 Table_Index_Type => Project_List,
555 Table_Low_Bound => 1,
556 Table_Initial => 100,
557 Table_Increment => 100);
558 -- The table that contains the lists of project files
560 -- The following record describes a project file representation
562 type Project_Data is record
563 Externally_Built : Boolean := False;
565 Languages : Languages_In_Project := No_Languages;
566 Supp_Languages : Supp_Language_Index := No_Supp_Language_Index;
567 -- Indicate the different languages of the source of this project
569 First_Referred_By : Project_Id := No_Project;
570 -- The project, if any, that was the first to be known as importing or
571 -- extending this project. Set by Prj.Proc.Process.
573 Name : Name_Id := No_Name;
574 -- The name of the project. Set by Prj.Proc.Process
576 Display_Name : Name_Id := No_Name;
577 -- The name of the project with the spelling of its declaration.
578 -- Set by Prj.Proc.Process.
580 Path_Name : Name_Id := No_Name;
581 -- The path name of the project file. Set by Prj.Proc.Process
583 Display_Path_Name : Name_Id := No_Name;
584 -- The path name used for display purposes. May be different from
585 -- Path_Name for platforms where the file names are case-insensitive.
587 Virtual : Boolean := False;
588 -- True for virtual extending projects
590 Location : Source_Ptr := No_Location;
591 -- The location in the project file source of the reserved word
592 -- project. Set by Prj.Proc.Process.
594 Mains : String_List_Id := Nil_String;
595 -- List of mains specified by attribute Main. Set by Prj.Nmsc.Check
597 Directory : Name_Id := No_Name;
598 -- Directory where the project file resides. Set by Prj.Proc.Process
600 Display_Directory : Name_Id := No_Name;
601 -- comment ???
603 Dir_Path : String_Access;
604 -- Same as Directory, but as an access to String. Set by
605 -- Make.Compile_Sources.Collect_Arguments_And_Compile.
607 Library : Boolean := False;
608 -- True if this is a library project. Set by
609 -- Prj.Nmsc.Language_Independent_Check.
611 Library_Dir : Name_Id := No_Name;
612 -- If a library project, directory where resides the library Set by
613 -- Prj.Nmsc.Language_Independent_Check.
615 Display_Library_Dir : Name_Id := No_Name;
616 -- The name of the library directory, for display purposes. May be
617 -- different from Library_Dir for platforms where the file names are
618 -- case-insensitive.
620 Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
621 -- The timestamp of a library file in a library project.
622 -- Set by MLib.Prj.Check_Library.
624 Library_Src_Dir : Name_Id := No_Name;
625 -- If a Stand-Alone Library project, directory where the sources
626 -- of the interfaces of the library are copied. By default, if
627 -- attribute Library_Src_Dir is not specified, sources of the interfaces
628 -- are not copied anywhere. Set by Prj.Nmsc.Check_Stand_Alone_Library.
630 Display_Library_Src_Dir : Name_Id := No_Name;
631 -- The name of the library source directory, for display purposes.
632 -- May be different from Library_Src_Dir for platforms where the file
633 -- names are case-insensitive.
635 Library_ALI_Dir : Name_Id := No_Name;
636 -- In a library project, directory where the ALI files are copied.
637 -- If attribute Library_ALI_Dir is not specified, ALI files are
638 -- copied in the Library_Dir. Set by Prj.Nmsc.Check_Library_Attributes.
640 Display_Library_ALI_Dir : Name_Id := No_Name;
641 -- The name of the library ALI directory, for display purposes. May be
642 -- different from Library_ALI_Dir for platforms where the file names are
643 -- case-insensitive.
645 Library_Name : Name_Id := No_Name;
646 -- If a library project, name of the library
647 -- Set by Prj.Nmsc.Language_Independent_Check.
649 Library_Kind : Lib_Kind := Static;
650 -- If a library project, kind of library
651 -- Set by Prj.Nmsc.Language_Independent_Check.
653 Lib_Internal_Name : Name_Id := No_Name;
654 -- If a library project, internal name store inside the library Set by
655 -- Prj.Nmsc.Language_Independent_Check.
657 Standalone_Library : Boolean := False;
658 -- Indicate that this is a Standalone Library Project File. Set by
659 -- Prj.Nmsc.Check.
661 Lib_Interface_ALIs : String_List_Id := Nil_String;
662 -- For Standalone Library Project Files, indicate the list of Interface
663 -- ALI files. Set by Prj.Nmsc.Check.
665 Lib_Auto_Init : Boolean := False;
666 -- For non static Standalone Library Project Files, indicate if
667 -- the library initialisation should be automatic.
669 Symbol_Data : Symbol_Record := No_Symbols;
670 -- Symbol file name, reference symbol file name, symbol policy
672 Ada_Sources_Present : Boolean := True;
673 -- A flag that indicates if there are Ada sources in this project file.
674 -- There are no sources if any of the following is true:
675 -- 1) Source_Dirs is specified as an empty list
676 -- 2) Source_Files is specified as an empty list
677 -- 3) Ada is not in the list of the specified Languages
679 Other_Sources_Present : Boolean := True;
680 -- A flag that indicates that there are non-Ada sources in this project
682 Sources : String_List_Id := Nil_String;
683 -- The list of all the source file names.
684 -- Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
686 First_Other_Source : Other_Source_Id := No_Other_Source;
687 Last_Other_Source : Other_Source_Id := No_Other_Source;
688 -- Head and tail of the list of sources of languages other than Ada
690 Imported_Directories_Switches : Argument_List_Access := null;
691 -- List of the -I switches to be used when compiling sources of
692 -- languages other than Ada.
694 Include_Path : String_Access := null;
695 -- Value to be used as CPATH, when using a GCC, instead of a list of
696 -- -I switches.
698 Include_Data_Set : Boolean := False;
699 -- Set True when Imported_Directories_Switches or Include_Path are set
701 Source_Dirs : String_List_Id := Nil_String;
702 -- The list of all the source directories.
703 -- Set by Prj.Nmsc.Language_Independent_Check.
705 Known_Order_Of_Source_Dirs : Boolean := True;
706 -- False, if there is any /** in the Source_Dirs, because in this case
707 -- the ordering of the source subdirs depend on the OS. If True,
708 -- duplicate file names in the same project file are allowed.
710 Object_Directory : Name_Id := No_Name;
711 -- The object directory of this project file.
712 -- Set by Prj.Nmsc.Language_Independent_Check.
714 Display_Object_Dir : Name_Id := No_Name;
715 -- The name of the object directory, for display purposes.
716 -- May be different from Object_Directory for platforms where the file
717 -- names are case-insensitive.
719 Exec_Directory : Name_Id := No_Name;
720 -- The exec directory of this project file. Default is equal to
721 -- Object_Directory. Set by Prj.Nmsc.Language_Independent_Check.
723 Display_Exec_Dir : Name_Id := No_Name;
724 -- The name of the exec directory, for display purposes. May be
725 -- different from Exec_Directory for platforms where the file names are
726 -- case-insensitive.
728 Extends : Project_Id := No_Project;
729 -- The reference of the project file, if any, that this project file
730 -- extends. Set by Prj.Proc.Process.
732 Extended_By : Project_Id := No_Project;
733 -- The reference of the project file, if any, that extends this project
734 -- file. Set by Prj.Proc.Process.
736 Naming : Naming_Data := Standard_Naming_Data;
737 -- The naming scheme of this project file.
738 -- Set by Prj.Nmsc.Check_Naming_Scheme.
740 First_Language_Processing : First_Language_Processing_Data :=
741 Default_First_Language_Processing_Data;
742 -- Comment needed ???
744 Supp_Language_Processing : Supp_Language_Index := No_Supp_Language_Index;
745 -- Comment needed
747 Default_Linker : Name_Id := No_Name;
748 Default_Linker_Path : Name_Id := No_Name;
750 Decl : Declarations := No_Declarations;
751 -- The declarations (variables, attributes and packages) of this
752 -- project file. Set by Prj.Proc.Process.
754 Imported_Projects : Project_List := Empty_Project_List;
755 -- The list of all directly imported projects, if any. Set by
756 -- Prj.Proc.Process.
758 All_Imported_Projects : Project_List := Empty_Project_List;
759 -- The list of all projects imported directly or indirectly, if any.
760 -- Set by Make.Initialize.
762 Ada_Include_Path : String_Access := null;
763 -- The cached value of ADA_INCLUDE_PATH for this project file. Do not
764 -- use this field directly outside of the compiler, use
765 -- Prj.Env.Ada_Include_Path instead. Set by Prj.Env.Ada_Include_Path.
767 Ada_Objects_Path : String_Access := null;
768 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
769 -- use this field directly outside of the compiler, use
770 -- Prj.Env.Ada_Objects_Path instead. Set by Prj.Env.Ada_Objects_Path
772 Include_Path_File : Name_Id := No_Name;
773 -- The cached value of the source path temp file for this project file.
774 -- Set by gnatmake (Prj.Env.Set_Ada_Paths).
776 Objects_Path_File_With_Libs : Name_Id := No_Name;
777 -- The cached value of the object path temp file (including library
778 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
780 Objects_Path_File_Without_Libs : Name_Id := No_Name;
781 -- The cached value of the object path temp file (excluding library
782 -- dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
784 Config_File_Name : Name_Id := No_Name;
785 -- The name of the configuration pragmas file, if any.
786 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
788 Config_File_Temp : Boolean := False;
789 -- An indication that the configuration pragmas file is
790 -- a temporary file that must be deleted at the end.
791 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
793 Config_Checked : Boolean := False;
794 -- A flag to avoid checking repetitively the configuration pragmas file.
795 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
797 Language_Independent_Checked : Boolean := False;
798 -- A flag that indicates that the project file has been checked
799 -- for language independent features: Object_Directory,
800 -- Source_Directories, Library, non empty Naming Suffixes.
802 Checked : Boolean := False;
803 -- A flag to avoid checking repetitively the naming scheme of
804 -- this project file. Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
806 Seen : Boolean := False;
807 -- A flag to mark a project as "visited" to avoid processing the same
808 -- project several time.
810 Need_To_Build_Lib : Boolean := False;
811 -- Indicates that the library of a Library Project needs to be built or
812 -- rebuilt.
814 Depth : Natural := 0;
815 -- The maximum depth of a project in the project graph.
816 -- Depth of main project is 0.
818 Unkept_Comments : Boolean := False;
819 -- True if there are comments in the project sources that cannot
820 -- be kept in the project tree.
822 end record;
824 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
825 -- Return the representation of an empty project in project Tree tree.
826 -- The project tree Tree must have been Initialized and/or Reset.
828 Project_Error : exception;
829 -- Raised by some subprograms in Prj.Attr
831 package Project_Table is new GNAT.Dynamic_Tables (
832 Table_Component_Type => Project_Data,
833 Table_Index_Type => Project_Id,
834 Table_Low_Bound => 1,
835 Table_Initial => 100,
836 Table_Increment => 100);
837 -- The set of all project files
839 type Spec_Or_Body is
840 (Specification, Body_Part);
842 type File_Name_Data is record
843 Name : Name_Id := No_Name;
844 Index : Int := 0;
845 Display_Name : Name_Id := No_Name;
846 Path : Name_Id := No_Name;
847 Display_Path : Name_Id := No_Name;
848 Project : Project_Id := No_Project;
849 Needs_Pragma : Boolean := False;
850 end record;
851 -- File and Path name of a spec or body
853 type File_Names_Data is array (Spec_Or_Body) of File_Name_Data;
855 type Unit_Id is new Nat;
856 No_Unit : constant Unit_Id := 0;
857 type Unit_Data is record
858 Name : Name_Id := No_Name;
859 File_Names : File_Names_Data;
860 end record;
861 -- Name and File and Path names of a unit, with a reference to its
862 -- GNAT Project File(s).
864 package Unit_Table is new GNAT.Dynamic_Tables
865 (Table_Component_Type => Unit_Data,
866 Table_Index_Type => Unit_Id,
867 Table_Low_Bound => 1,
868 Table_Initial => 100,
869 Table_Increment => 100);
870 -- Table of all units in a project tree
872 package Units_Htable is new Simple_HTable
873 (Header_Num => Header_Num,
874 Element => Unit_Id,
875 No_Element => No_Unit,
876 Key => Name_Id,
877 Hash => Hash,
878 Equal => "=");
879 -- Mapping of unit names to indexes in the Units table
881 type Unit_Project is record
882 Unit : Unit_Id := No_Unit;
883 Project : Project_Id := No_Project;
884 end record;
886 No_Unit_Project : constant Unit_Project := (No_Unit, No_Project);
888 package Files_Htable is new Simple_HTable
889 (Header_Num => Header_Num,
890 Element => Unit_Project,
891 No_Element => No_Unit_Project,
892 Key => Name_Id,
893 Hash => Hash,
894 Equal => "=");
895 -- Mapping of file names to indexes in the Units table
897 type Private_Project_Tree_Data is private;
898 -- Data for a project tree that is used only by the Project Manager
900 type Project_Tree_Data is
901 record
902 Present_Languages : Present_Language_Table.Instance;
903 Supp_Suffixes : Supp_Suffix_Table.Instance;
904 Name_Lists : Name_List_Table.Instance;
905 Supp_Languages : Supp_Language_Table.Instance;
906 Other_Sources : Other_Source_Table.Instance;
907 String_Elements : String_Element_Table.Instance;
908 Variable_Elements : Variable_Element_Table.Instance;
909 Array_Elements : Array_Element_Table.Instance;
910 Arrays : Array_Table.Instance;
911 Packages : Package_Table.Instance;
912 Project_Lists : Project_List_Table.Instance;
913 Projects : Project_Table.Instance;
914 Units : Unit_Table.Instance;
915 Units_HT : Units_Htable.Instance;
916 Files_HT : Files_Htable.Instance;
917 Private_Part : Private_Project_Tree_Data;
918 end record;
919 -- Data for a project tree
921 type Put_Line_Access is access procedure
922 (Line : String;
923 Project : Project_Id;
924 In_Tree : Project_Tree_Ref);
925 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
927 procedure Expect (The_Token : Token_Type; Token_Image : String);
928 -- Check that the current token is The_Token. If it is not, then
929 -- output an error message.
931 procedure Initialize (Tree : Project_Tree_Ref);
932 -- This procedure must be called before using any services from the Prj
933 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
935 procedure Reset (Tree : Project_Tree_Ref);
936 -- This procedure resets all the tables that are used when processing a
937 -- project file tree. Initialize must be called before the call to Reset.
939 procedure Register_Default_Naming_Scheme
940 (Language : Name_Id;
941 Default_Spec_Suffix : Name_Id;
942 Default_Body_Suffix : Name_Id;
943 In_Tree : Project_Tree_Ref);
944 -- Register the default suffixes for a given language. These extensions
945 -- will be ignored if the user has specified a new naming scheme in a
946 -- project file.
948 -- Otherwise, this information will be automatically added to Naming_Data
949 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
951 generic
952 type State is limited private;
953 with procedure Action
954 (Project : Project_Id;
955 With_State : in out State);
956 procedure For_Every_Project_Imported
957 (By : Project_Id;
958 In_Tree : Project_Tree_Ref;
959 With_State : in out State);
960 -- Call Action for each project imported directly or indirectly by project
961 -- By. Action is called according to the order of importation: if A
962 -- imports B, directly or indirectly, Action will be called for A before
963 -- it is called for B. If two projects import each other directly or
964 -- indirectly (using at least one "limited with"), it is not specified
965 -- for which of these two projects Action will be called first. Projects
966 -- that are extended by other projects are not considered. With_State may
967 -- be used by Action to choose a behavior or to report some global result.
969 ----------------------------------------------------------
970 -- Other multi-language stuff that may be modified soon --
971 ----------------------------------------------------------
973 function Is_Present
974 (Language : Language_Index;
975 In_Project : Project_Data;
976 In_Tree : Project_Tree_Ref) return Boolean;
977 -- Return True when Language is one of the languages used in
978 -- project In_Project.
980 procedure Set
981 (Language : Language_Index;
982 Present : Boolean;
983 In_Project : in out Project_Data;
984 In_Tree : Project_Tree_Ref);
985 -- Indicate if Language is or not a language used in project In_Project
987 function Language_Processing_Data_Of
988 (Language : Language_Index;
989 In_Project : Project_Data;
990 In_Tree : Project_Tree_Ref) return Language_Processing_Data;
991 -- Return the Language_Processing_Data for language Language in project
992 -- In_Project. Return the default when no Language_Processing_Data are
993 -- defined for the language.
995 procedure Set
996 (Language_Processing : Language_Processing_Data;
997 For_Language : Language_Index;
998 In_Project : in out Project_Data;
999 In_Tree : Project_Tree_Ref);
1000 -- Set the Language_Processing_Data for language Language in project
1001 -- In_Project.
1003 function Suffix_Of
1004 (Language : Language_Index;
1005 In_Project : Project_Data;
1006 In_Tree : Project_Tree_Ref) return Name_Id;
1007 -- Return the suffix for language Language in project In_Project. Return
1008 -- No_Name when no suffix is defined for the language.
1010 procedure Set
1011 (Suffix : Name_Id;
1012 For_Language : Language_Index;
1013 In_Project : in out Project_Data;
1014 In_Tree : Project_Tree_Ref);
1015 -- Set the suffix for language Language in project In_Project
1017 private
1019 All_Packages : constant String_List_Access := null;
1021 No_Project_Tree : constant Project_Tree_Ref := null;
1023 Ignored : constant Variable_Kind := Single;
1025 Nil_Variable_Value : constant Variable_Value :=
1026 (Project => No_Project,
1027 Kind => Undefined,
1028 Location => No_Location,
1029 Default => False);
1031 Virtual_Prefix : constant String := "v$";
1032 -- The prefix for virtual extending projects. Because of the '$', which is
1033 -- normally forbidden for project names, there cannot be any name clash.
1035 Empty_Name : Name_Id;
1036 -- Name_Id for an empty name (no characters). Initialized by the call
1037 -- to procedure Initialize.
1039 procedure Add_To_Buffer
1040 (S : String;
1041 To : in out String_Access;
1042 Last : in out Natural);
1043 -- Append a String to the Buffer
1045 type Naming_Id is new Nat;
1047 package Naming_Table is new GNAT.Dynamic_Tables
1048 (Table_Component_Type => Naming_Data,
1049 Table_Index_Type => Naming_Id,
1050 Table_Low_Bound => 1,
1051 Table_Initial => 5,
1052 Table_Increment => 100);
1053 -- Comment ???
1055 package Path_File_Table is new GNAT.Dynamic_Tables
1056 (Table_Component_Type => Name_Id,
1057 Table_Index_Type => Natural,
1058 Table_Low_Bound => 1,
1059 Table_Initial => 50,
1060 Table_Increment => 50);
1061 -- Table storing all the temp path file names.
1062 -- Used by Delete_All_Path_Files.
1064 package Source_Path_Table is new GNAT.Dynamic_Tables
1065 (Table_Component_Type => Name_Id,
1066 Table_Index_Type => Natural,
1067 Table_Low_Bound => 1,
1068 Table_Initial => 50,
1069 Table_Increment => 50);
1070 -- A table to store the source dirs before creating the source path file
1072 package Object_Path_Table is new GNAT.Dynamic_Tables
1073 (Table_Component_Type => Name_Id,
1074 Table_Index_Type => Natural,
1075 Table_Low_Bound => 1,
1076 Table_Initial => 50,
1077 Table_Increment => 50);
1078 -- A table to store the object dirs, before creating the object path file
1080 type Private_Project_Tree_Data is record
1081 Namings : Naming_Table.Instance;
1082 Path_Files : Path_File_Table.Instance;
1083 Source_Paths : Source_Path_Table.Instance;
1084 Object_Paths : Object_Path_Table.Instance;
1085 Default_Naming : Naming_Data;
1086 end record;
1087 -- Comment ???
1088 end Prj;