1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2008, 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 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- The following package declares the data types for GNAT project.
27 -- These data types may be used by GNAT Project-aware tools.
29 -- Children of these package implements various services on these data types.
30 -- See in particular Prj.Pars and Prj.Env.
32 with Casing
; use Casing
;
33 with Namet
; use Namet
;
34 with 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 Subdirs_Option
: constant String := "--subdirs=";
47 -- Switch used to indicate that the real directories (object, exec,
48 -- library, ...) are subdirectories of what is indicated in the project
51 Subdirs
: String_Ptr
:= null;
52 -- The value after the equal sign in switch --subdirs=...
53 -- Contains the relative subdirectory.
55 type Library_Support
is (None
, Static_Only
, Full
);
56 -- Support for Library Project File.
57 -- - None: Library Project Files are not supported at all
58 -- - Static_Only: Library Project Files are only supported for static
60 -- - Full: Library Project Files are supported for static and dynamic
61 -- (shared) libraries.
63 type Yes_No_Unknown
is (Yes
, No
, Unknown
);
64 -- Tri-state to decide if -lgnarl is needed when linking
66 type Mode
is (Multi_Language
, Ada_Only
);
67 -- Ada_Only: mode for gnatmake, gnatname, the GNAT driver
68 -- Multi_Language: mode for gprbuild, gprclean
70 type Project_Qualifier
is
77 -- Qualifiers that can prefix the reserved word "project" in a project
79 -- Standard: standard project ...
80 -- Library: library project is ...
81 -- Dry: abstract project is
82 -- Aggregate: aggregate project is
83 -- Aggregate_Library: aggregate library project is ...
85 function Get_Mode
return Mode
;
86 pragma Inline
(Get_Mode
);
88 procedure Set_Mode
(New_Mode
: Mode
);
89 pragma Inline
(Set_Mode
);
91 Default_Language_Is_Ada
: Boolean := True;
92 -- If no language was defined in the project or the configuration file, it
93 -- is an error, unless this variable is True, in which case it defaults to
94 -- Ada. Calling Set_Mode will reset this variable, default is for Ada_Only.
96 Must_Check_Configuration
: Boolean := False;
97 -- True when the contents of the configuration file must be checked. This
98 -- is in general only needed by gprbuild itself, since other applications
99 -- can ignore such errors when they don't need to build directly. Calling
100 -- Set_Mode will reset this variable, default is for Ada_Only.
102 function In_Configuration
return Boolean;
103 pragma Inline
(In_Configuration
);
105 procedure Set_In_Configuration
(Value
: Boolean);
106 pragma Inline
(Set_In_Configuration
);
108 All_Packages
: constant String_List_Access
;
109 -- Default value of parameter Packages of procedures Parse, in Prj.Pars and
110 -- Prj.Part, indicating that all packages should be checked.
112 type Project_Tree_Data
;
113 type Project_Tree_Ref
is access all Project_Tree_Data
;
114 -- Reference to a project tree. Several project trees may exist in memory
117 No_Project_Tree
: constant Project_Tree_Ref
;
119 function Default_Ada_Spec_Suffix
return File_Name_Type
;
120 pragma Inline
(Default_Ada_Spec_Suffix
);
121 -- The name for the standard GNAT suffix for Ada spec source file name
122 -- ".ads". Initialized by Prj.Initialize.
124 function Default_Ada_Body_Suffix
return File_Name_Type
;
125 pragma Inline
(Default_Ada_Body_Suffix
);
126 -- The name for the standard GNAT suffix for Ada body source file name
127 -- ".adb". Initialized by Prj.Initialize.
129 function Slash
return Path_Name_Type
;
130 pragma Inline
(Slash
);
131 -- "/", used as the path of locally removed files
133 Config_Project_File_Extension
: String := ".cgpr";
134 Project_File_Extension
: String := ".gpr";
135 -- The standard config and user project file name extensions. They are not
136 -- constants, because Canonical_Case_File_Name is called on these variables
137 -- in the body of Prj.
139 type Error_Warning
is (Silent
, Warning
, Error
);
140 -- Severity of some situations, such as: no Ada sources in a project where
141 -- Ada is one of the language.
143 -- When the situation occurs, the behaviour depends on the setting:
145 -- - Silent: no action
146 -- - Warning: issue a warning, does not cause the tool to fail
147 -- - Error: issue an error, causes the tool to fail
149 function Empty_File
return File_Name_Type
;
150 function Empty_String
return Name_Id
;
151 -- Return the id for an empty string ""
153 type Path_Information
is record
154 Name
: Path_Name_Type
:= No_Path
;
155 Display_Name
: Path_Name_Type
:= No_Path
;
158 No_Path_Information
: constant Path_Information
:= (No_Path
, No_Path
);
160 type Project_Id
is new Nat
;
161 No_Project
: constant Project_Id
:= 0;
162 -- Id of a Project File
164 type String_List_Id
is new Nat
;
165 Nil_String
: constant String_List_Id
:= 0;
166 type String_Element
is record
167 Value
: Name_Id
:= No_Name
;
169 Display_Value
: Name_Id
:= No_Name
;
170 Location
: Source_Ptr
:= No_Location
;
171 Flag
: Boolean := False;
172 Next
: String_List_Id
:= Nil_String
;
174 -- To hold values for string list variables and array elements.
175 -- Component Flag may be used for various purposes. For source
176 -- directories, it indicates if the directory contains Ada source(s).
178 package String_Element_Table
is new GNAT
.Dynamic_Tables
179 (Table_Component_Type
=> String_Element
,
180 Table_Index_Type
=> String_List_Id
,
181 Table_Low_Bound
=> 1,
182 Table_Initial
=> 200,
183 Table_Increment
=> 100);
184 -- The table for string elements in string lists
186 type Variable_Kind
is (Undefined
, List
, Single
);
187 -- Different kinds of variables
189 subtype Defined_Variable_Kind
is Variable_Kind
range List
.. Single
;
190 -- The defined kinds of variables
192 Ignored
: constant Variable_Kind
;
193 -- Used to indicate that a package declaration must be ignored
194 -- while processing the project tree (unknown package name).
196 type Variable_Value
(Kind
: Variable_Kind
:= Undefined
) is record
197 Project
: Project_Id
:= No_Project
;
198 Location
: Source_Ptr
:= No_Location
;
199 Default
: Boolean := False;
204 Values
: String_List_Id
:= Nil_String
;
206 Value
: Name_Id
:= No_Name
;
210 -- Values for variables and array elements. Default is True if the
211 -- current value is the default one for the variable
213 Nil_Variable_Value
: constant Variable_Value
;
214 -- Value of a non existing variable or array element
216 type Variable_Id
is new Nat
;
217 No_Variable
: constant Variable_Id
:= 0;
218 type Variable
is record
219 Next
: Variable_Id
:= No_Variable
;
221 Value
: Variable_Value
;
223 -- To hold the list of variables in a project file and in packages
225 package Variable_Element_Table
is new GNAT
.Dynamic_Tables
226 (Table_Component_Type
=> Variable
,
227 Table_Index_Type
=> Variable_Id
,
228 Table_Low_Bound
=> 1,
229 Table_Initial
=> 200,
230 Table_Increment
=> 100);
231 -- The table of variable in list of variables
233 type Array_Element_Id
is new Nat
;
234 No_Array_Element
: constant Array_Element_Id
:= 0;
235 type Array_Element
is record
237 Src_Index
: Int
:= 0;
238 Index_Case_Sensitive
: Boolean := True;
239 Value
: Variable_Value
;
240 Next
: Array_Element_Id
:= No_Array_Element
;
242 -- Each Array_Element represents an array element and is linked (Next)
243 -- to the next array element, if any, in the array.
245 package Array_Element_Table
is new GNAT
.Dynamic_Tables
246 (Table_Component_Type
=> Array_Element
,
247 Table_Index_Type
=> Array_Element_Id
,
248 Table_Low_Bound
=> 1,
249 Table_Initial
=> 200,
250 Table_Increment
=> 100);
251 -- The table that contains all array elements
253 type Array_Id
is new Nat
;
254 No_Array
: constant Array_Id
:= 0;
255 type Array_Data
is record
256 Name
: Name_Id
:= No_Name
;
257 Value
: Array_Element_Id
:= No_Array_Element
;
258 Next
: Array_Id
:= No_Array
;
260 -- Each Array_Data value represents an array.
261 -- Value is the id of the first element.
262 -- Next is the id of the next array in the project file or package.
264 package Array_Table
is new GNAT
.Dynamic_Tables
265 (Table_Component_Type
=> Array_Data
,
266 Table_Index_Type
=> Array_Id
,
267 Table_Low_Bound
=> 1,
268 Table_Initial
=> 200,
269 Table_Increment
=> 100);
270 -- The table that contains all arrays
272 type Package_Id
is new Nat
;
273 No_Package
: constant Package_Id
:= 0;
274 type Declarations
is record
275 Variables
: Variable_Id
:= No_Variable
;
276 Attributes
: Variable_Id
:= No_Variable
;
277 Arrays
: Array_Id
:= No_Array
;
278 Packages
: Package_Id
:= No_Package
;
280 -- Contains the declarations (variables, single and array attributes,
281 -- packages) for a project or a package in a project.
283 No_Declarations
: constant Declarations
:=
284 (Variables
=> No_Variable
,
285 Attributes
=> No_Variable
,
287 Packages
=> No_Package
);
288 -- Default value of Declarations: indicates that there is no declarations
290 type Package_Element
is record
291 Name
: Name_Id
:= No_Name
;
292 Decl
: Declarations
:= No_Declarations
;
293 Parent
: Package_Id
:= No_Package
;
294 Next
: Package_Id
:= No_Package
;
296 -- A package (includes declarations that may include other packages)
298 package Package_Table
is new GNAT
.Dynamic_Tables
299 (Table_Component_Type
=> Package_Element
,
300 Table_Index_Type
=> Package_Id
,
301 Table_Low_Bound
=> 1,
302 Table_Initial
=> 100,
303 Table_Increment
=> 100);
304 -- The table that contains all packages
306 type Language_Index
is new Nat
;
307 -- Index of language data
309 No_Language_Index
: constant Language_Index
:= 0;
310 -- Constant indicating that there is no language data
312 procedure Display_Language_Name
313 (In_Tree
: Project_Tree_Ref
;
314 Language
: Language_Index
);
315 -- Output the name of a language
317 Max_Header_Num
: constant := 6150;
318 type Header_Num
is range 0 .. Max_Header_Num
;
319 -- Size for hash table below. The upper bound is an arbitrary value, the
320 -- value here was chosen after testing to determine a good compromise
321 -- between speed of access and memory usage.
323 function Hash
(Name
: Name_Id
) return Header_Num
;
324 function Hash
(Name
: File_Name_Type
) return Header_Num
;
325 function Hash
(Name
: Path_Name_Type
) return Header_Num
;
326 -- Used for computing hash values for names put into above hash table
328 function Hash
(Project
: Project_Id
) return Header_Num
;
329 -- Used for hash tables where Project_Id is the Key
331 type Language_Kind
is (File_Based
, Unit_Based
);
332 -- Type for the kind of language. All languages are file based, except Ada
333 -- which is unit based.
335 type Dependency_File_Kind
is (None
, Makefile
, ALI_File
);
336 -- Type of dependency to be checked: no dependency file, Makefile fragment
337 -- or ALI file (for Ada).
339 Makefile_Dependency_Suffix
: constant String := ".d";
340 ALI_Dependency_Suffix
: constant String := ".ali";
342 Switches_Dependency_Suffix
: constant String := ".cswi";
344 Binder_Exchange_Suffix
: constant String := ".bexch";
345 -- Suffix for binder exchange files
347 Library_Exchange_Suffix
: constant String := ".lexch";
348 -- Suffix for library exchange files
350 type Name_List_Index
is new Nat
;
351 No_Name_List
: constant Name_List_Index
:= 0;
353 type Name_Node
is record
354 Name
: Name_Id
:= No_Name
;
355 Next
: Name_List_Index
:= No_Name_List
;
358 package Name_List_Table
is new GNAT
.Dynamic_Tables
359 (Table_Component_Type
=> Name_Node
,
360 Table_Index_Type
=> Name_List_Index
,
361 Table_Low_Bound
=> 1,
363 Table_Increment
=> 100);
364 -- The table for lists of names used in package Language_Processing
366 package Mapping_Files_Htable
is new Simple_HTable
367 (Header_Num
=> Header_Num
,
368 Element
=> Path_Name_Type
,
369 No_Element
=> No_Path
,
370 Key
=> Path_Name_Type
,
373 -- A hash table to store the mapping files that are not used
375 type Lang_Naming_Data
is record
376 Dot_Replacement
: File_Name_Type
:= No_File
;
377 -- The string to replace '.' in the source file name (for Ada)
379 Casing
: Casing_Type
:= All_Lower_Case
;
380 -- The casing of the source file name (for Ada)
382 Separate_Suffix
: File_Name_Type
:= No_File
;
383 -- String to append to unit name for source file name of an Ada subunit
385 Spec_Suffix
: File_Name_Type
:= No_File
;
386 -- The string to append to the unit name for the
387 -- source file name of a spec.
389 Body_Suffix
: File_Name_Type
:= No_File
;
390 -- The string to append to the unit name for the
391 -- source file name of a body.
394 No_Lang_Naming_Data
: constant Lang_Naming_Data
:=
395 (Dot_Replacement
=> No_File
,
396 Casing
=> All_Lower_Case
,
397 Separate_Suffix
=> No_File
,
398 Spec_Suffix
=> No_File
,
399 Body_Suffix
=> No_File
);
401 type Source_Id
is new Nat
;
403 No_Source
: constant Source_Id
:= 0;
405 type Language_Config
is record
406 Kind
: Language_Kind
:= File_Based
;
407 -- Kind of language. All languages are file based, except Ada which is
410 Naming_Data
: Lang_Naming_Data
;
411 -- The naming data for the languages (prefixes, etc.)
413 Include_Compatible_Languages
: Name_List_Index
:= No_Name_List
;
414 -- The list of languages that are "include compatible" with this
415 -- language. A language B (for example "C") is "include compatible" with
416 -- a language A (for example "C++") if it is expected that sources of
417 -- language A may "include" header files from language B.
419 Compiler_Driver
: File_Name_Type
:= No_File
;
420 -- The name of the executable for the compiler of the language
422 Compiler_Driver_Path
: String_Access
:= null;
423 -- The path name of the executable for the compiler of the language
425 Compiler_Required_Switches
: Name_List_Index
:= No_Name_List
;
426 -- The list of switches that are required as a minimum to invoke the
429 Compilation_PIC_Option
: Name_List_Index
:= No_Name_List
;
430 -- The option(s) to compile a source in Position Independent Code for
431 -- shared libraries. Specified in the configuration. When not specified,
432 -- there is no need for such switch.
434 Object_Generated
: Boolean := True;
435 -- False in no object file is generated
437 Objects_Linked
: Boolean := True;
438 -- False if object files are not use to link executables and build
441 Runtime_Library_Dir
: Name_Id
:= No_Name
;
442 -- Path name of the runtime library directory, if any
444 Mapping_File_Switches
: Name_List_Index
:= No_Name_List
;
445 -- The option(s) to provide a mapping file to the compiler. Specified in
446 -- the configuration. When value is No_Name_List, there is no mapping
449 Mapping_Spec_Suffix
: File_Name_Type
:= No_File
;
450 -- Placeholder representing the spec suffix in a mapping file
452 Mapping_Body_Suffix
: File_Name_Type
:= No_File
;
453 -- Placeholder representing the body suffix in a mapping file
455 Config_File_Switches
: Name_List_Index
:= No_Name_List
;
456 -- The option(s) to provide a config file to the compiler. Specified in
457 -- the configuration. When value is No_Name_List, there is no config
460 Dependency_Kind
: Dependency_File_Kind
:= None
;
461 -- The kind of dependency to be checked: none, Makefile fragment or
462 -- ALI file (for Ada).
464 Dependency_Option
: Name_List_Index
:= No_Name_List
;
465 -- The option(s) to be used to create the dependency file. When value is
466 -- No_Name_List, there is not such option(s).
468 Compute_Dependency
: Name_List_Index
:= No_Name_List
;
469 -- Hold the value of attribute Dependency_Driver, if declared for the
472 Include_Option
: Name_List_Index
:= No_Name_List
;
473 -- Hold the value of attribute Include_Switches, if declared for the
476 Include_Path
: Name_Id
:= No_Name
;
477 -- Name of environment variable declared by attribute Include_Path for
480 Include_Path_File
: Name_Id
:= No_Name
;
481 -- Name of environment variable declared by attribute Include_Path_File
484 Objects_Path
: Name_Id
:= No_Name
;
485 -- Name of environment variable declared by attribute Objects_Path for
488 Objects_Path_File
: Name_Id
:= No_Name
;
489 -- Name of environment variable declared by attribute Objects_Path_File
492 Config_Body
: Name_Id
:= No_Name
;
493 -- The template for a pragma Source_File_Name(_Project) for a specific
494 -- file name of a body.
496 Config_Spec
: Name_Id
:= No_Name
;
497 -- The template for a pragma Source_File_Name(_Project) for a specific
498 -- file name of a spec.
500 Config_Body_Pattern
: Name_Id
:= No_Name
;
501 -- The template for a pragma Source_File_Name(_Project) for a naming
504 Config_Spec_Pattern
: Name_Id
:= No_Name
;
505 -- The template for a pragma Source_File_Name(_Project) for a naming
508 Config_File_Unique
: Boolean := False;
509 -- Indicate if the config file specified to the compiler needs to be
510 -- unique. If it is unique, then all config files are concatenated into
511 -- a temp config file.
513 Binder_Driver
: File_Name_Type
:= No_File
;
514 -- The name of the binder driver for the language, if any
516 Binder_Driver_Path
: Path_Name_Type
:= No_Path
;
517 -- The path name of the binder driver
519 Binder_Required_Switches
: Name_List_Index
:= No_Name_List
;
520 -- Hold the value of attribute Binder'Required_Switches for the language
522 Binder_Prefix
: Name_Id
:= No_Name
;
523 -- Hold the value of attribute Binder'Prefix for the language
525 Toolchain_Version
: Name_Id
:= No_Name
;
526 -- Hold the value of attribute Toolchain_Version for the language
528 Toolchain_Description
: Name_Id
:= No_Name
;
529 -- Hold the value of attribute Toolchain_Description for the language
531 PIC_Option
: Name_Id
:= No_Name
;
532 -- Hold the value of attribute Compiler'PIC_Option for the language
534 Objects_Generated
: Boolean := True;
535 -- Indicates if objects are generated for the language
538 -- Record describing the configuration of a language
540 No_Language_Config
: constant Language_Config
:=
542 Naming_Data
=> No_Lang_Naming_Data
,
543 Include_Compatible_Languages
=> No_Name_List
,
544 Compiler_Driver
=> No_File
,
545 Compiler_Driver_Path
=> null,
546 Compiler_Required_Switches
=> No_Name_List
,
547 Compilation_PIC_Option
=> No_Name_List
,
548 Object_Generated
=> True,
549 Objects_Linked
=> True,
550 Runtime_Library_Dir
=> No_Name
,
551 Mapping_File_Switches
=> No_Name_List
,
552 Mapping_Spec_Suffix
=> No_File
,
553 Mapping_Body_Suffix
=> No_File
,
554 Config_File_Switches
=> No_Name_List
,
555 Dependency_Kind
=> Makefile
,
556 Dependency_Option
=> No_Name_List
,
557 Compute_Dependency
=> No_Name_List
,
558 Include_Option
=> No_Name_List
,
559 Include_Path
=> No_Name
,
560 Include_Path_File
=> No_Name
,
561 Objects_Path
=> No_Name
,
562 Objects_Path_File
=> No_Name
,
563 Config_Body
=> No_Name
,
564 Config_Spec
=> No_Name
,
565 Config_Body_Pattern
=> No_Name
,
566 Config_Spec_Pattern
=> No_Name
,
567 Config_File_Unique
=> False,
568 Binder_Driver
=> No_File
,
569 Binder_Driver_Path
=> No_Path
,
570 Binder_Required_Switches
=> No_Name_List
,
571 Binder_Prefix
=> No_Name
,
572 Toolchain_Version
=> No_Name
,
573 Toolchain_Description
=> No_Name
,
574 PIC_Option
=> No_Name
,
575 Objects_Generated
=> True);
577 type Language_Data
is record
578 Name
: Name_Id
:= No_Name
;
579 Display_Name
: Name_Id
:= No_Name
;
580 Config
: Language_Config
:= No_Language_Config
;
581 First_Source
: Source_Id
:= No_Source
;
582 Mapping_Files
: Mapping_Files_Htable
.Instance
:=
583 Mapping_Files_Htable
.Nil
;
584 Next
: Language_Index
:= No_Language_Index
;
587 No_Language_Data
: constant Language_Data
:=
589 Display_Name
=> No_Name
,
590 Config
=> No_Language_Config
,
591 First_Source
=> No_Source
,
592 Mapping_Files
=> Mapping_Files_Htable
.Nil
,
593 Next
=> No_Language_Index
);
595 package Language_Data_Table
is new GNAT
.Dynamic_Tables
596 (Table_Component_Type
=> Language_Data
,
597 Table_Index_Type
=> Language_Index
,
598 Table_Low_Bound
=> 1,
600 Table_Increment
=> 100);
601 -- The table for lists of names used in package Language_Processing
603 type Alternate_Language_Id
is new Nat
;
605 No_Alternate_Language
: constant Alternate_Language_Id
:= 0;
607 type Alternate_Language_Data
is record
608 Language
: Language_Index
:= No_Language_Index
;
609 Next
: Alternate_Language_Id
:= No_Alternate_Language
;
612 package Alternate_Language_Table
is new GNAT
.Dynamic_Tables
613 (Table_Component_Type
=> Alternate_Language_Data
,
614 Table_Index_Type
=> Alternate_Language_Id
,
615 Table_Low_Bound
=> 1,
617 Table_Increment
=> 100);
618 -- The table for storing the alternate languages of a header file that
619 -- is used for several languages.
621 type Source_Kind
is (Spec
, Impl
, Sep
);
623 type Source_Data
is record
624 Project
: Project_Id
:= No_Project
;
625 -- Project of the source
627 Language_Name
: Name_Id
:= No_Name
;
628 -- Name of the language of the source
630 Language
: Language_Index
:= No_Language_Index
;
631 -- Index of the language
633 Lang_Kind
: Language_Kind
:= File_Based
;
634 -- Kind of the language
636 Compiled
: Boolean := True;
637 -- False when there is no compiler for the language
639 In_Interfaces
: Boolean := True;
640 -- False when the source is not included in interfaces, when attribute
641 -- Interfaces is declared.
643 Declared_In_Interfaces
: Boolean := False;
644 -- True when source is declared in attribute Interfaces
646 Alternate_Languages
: Alternate_Language_Id
:= No_Alternate_Language
;
647 -- List of languages a header file may also be, in addition of
648 -- language Language_Name.
650 Kind
: Source_Kind
:= Spec
;
651 -- Kind of the source: spec, body or subunit
653 Dependency
: Dependency_File_Kind
:= None
;
654 -- Kind of dependency: none, Makefile fragment or ALI file
656 Other_Part
: Source_Id
:= No_Source
;
657 -- Source ID for the other part, if any: for a spec, indicates its body;
658 -- for a body, indicates its spec.
660 Unit
: Name_Id
:= No_Name
;
661 -- Name of the unit, if language is unit based
664 -- Index of the source in a multi unit source file
666 Locally_Removed
: Boolean := False;
667 -- True if the source has been "excluded"
669 Get_Object
: Boolean := False;
670 -- Indicates that the object of the source should be put in the global
671 -- archive. This is for Ada, when only the closure of a main needs to
672 -- be compiled/recompiled.
674 Replaced_By
: Source_Id
:= No_Source
;
676 File
: File_Name_Type
:= No_File
;
677 -- Canonical file name of the source
679 Display_File
: File_Name_Type
:= No_File
;
680 -- File name of the source, for display purposes
682 Path
: Path_Information
:= No_Path_Information
;
683 -- Path name of the source
685 Source_TS
: Time_Stamp_Type
:= Empty_Time_Stamp
;
686 -- Time stamp of the source file
688 Object_Project
: Project_Id
:= No_Project
;
689 -- Project where the object file is
691 Object_Exists
: Boolean := True;
692 -- True if an object file exists
694 Object_Linked
: Boolean := True;
695 -- False if the object file is not use to link executables or included
698 Object
: File_Name_Type
:= No_File
;
699 -- File name of the object file
701 Current_Object_Path
: Path_Name_Type
:= No_Path
;
702 -- Object path of an existing object file
704 Object_Path
: Path_Name_Type
:= No_Path
;
705 -- Object path of the real object file
707 Object_TS
: Time_Stamp_Type
:= Empty_Time_Stamp
;
708 -- Object file time stamp
710 Dep_Name
: File_Name_Type
:= No_File
;
711 -- Dependency file simple name
713 Current_Dep_Path
: Path_Name_Type
:= No_Path
;
714 -- Path name of an existing dependency file
716 Dep_Path
: Path_Name_Type
:= No_Path
;
717 -- Path name of the real dependency file
719 Dep_TS
: Time_Stamp_Type
:= Empty_Time_Stamp
;
720 -- Dependency file time stamp
722 Switches
: File_Name_Type
:= No_File
;
723 -- File name of the switches file
725 Switches_Path
: Path_Name_Type
:= No_Path
;
726 -- Path name of the switches file
728 Switches_TS
: Time_Stamp_Type
:= Empty_Time_Stamp
;
729 -- Switches file time stamp
731 Naming_Exception
: Boolean := False;
732 -- True if the source has an exceptional name
734 Next_In_Sources
: Source_Id
:= No_Source
;
735 -- Link to another source in the project tree
737 Next_In_Project
: Source_Id
:= No_Source
;
738 -- Link to another source in the project
740 Next_In_Lang
: Source_Id
:= No_Source
;
741 -- Link to another source of the same language
744 No_Source_Data
: constant Source_Data
:=
745 (Project
=> No_Project
,
746 Language_Name
=> No_Name
,
747 Language
=> No_Language_Index
,
748 Lang_Kind
=> File_Based
,
750 In_Interfaces
=> True,
751 Declared_In_Interfaces
=> False,
752 Alternate_Languages
=> No_Alternate_Language
,
755 Other_Part
=> No_Source
,
758 Locally_Removed
=> False,
760 Replaced_By
=> No_Source
,
762 Display_File
=> No_File
,
763 Path
=> No_Path_Information
,
764 Source_TS
=> Empty_Time_Stamp
,
765 Object_Project
=> No_Project
,
766 Object_Exists
=> True,
767 Object_Linked
=> True,
769 Current_Object_Path
=> No_Path
,
770 Object_Path
=> No_Path
,
771 Object_TS
=> Empty_Time_Stamp
,
773 Current_Dep_Path
=> No_Path
,
775 Dep_TS
=> Empty_Time_Stamp
,
777 Switches_Path
=> No_Path
,
778 Switches_TS
=> Empty_Time_Stamp
,
779 Naming_Exception
=> False,
780 Next_In_Sources
=> No_Source
,
781 Next_In_Project
=> No_Source
,
782 Next_In_Lang
=> No_Source
);
784 package Source_Data_Table
is new GNAT
.Dynamic_Tables
785 (Table_Component_Type
=> Source_Data
,
786 Table_Index_Type
=> Source_Id
,
787 Table_Low_Bound
=> 1,
788 Table_Initial
=> 1000,
789 Table_Increment
=> 100);
790 -- The table for the sources
792 package Source_Paths_Htable
is new Simple_HTable
793 (Header_Num
=> Header_Num
,
794 Element
=> Source_Id
,
795 No_Element
=> No_Source
,
796 Key
=> Path_Name_Type
,
799 -- Mapping of source paths to source ids
801 type Verbosity
is (Default
, Medium
, High
);
802 -- Verbosity when parsing GNAT Project Files
803 -- Default is default (very quiet, if no errors).
804 -- Medium is more verbose.
805 -- High is extremely verbose.
807 Current_Verbosity
: Verbosity
:= Default
;
808 -- The current value of the verbosity the project files are parsed with
810 type Lib_Kind
is (Static
, Dynamic
, Relocatable
);
812 type Policy
is (Autonomous
, Compliant
, Controlled
, Restricted
, Direct
);
813 -- Type to specify the symbol policy, when symbol control is supported.
814 -- See full explanation about this type in package Symbols.
815 -- Autonomous: Create a symbol file without considering any reference
816 -- Compliant: Try to be as compatible as possible with an existing ref
817 -- Controlled: Fail if symbols are not the same as those in the reference
818 -- Restricted: Restrict the symbols to those in the symbol file
819 -- Direct: The symbol file is used as is
821 type Symbol_Record
is record
822 Symbol_File
: Path_Name_Type
:= No_Path
;
823 Reference
: Path_Name_Type
:= No_Path
;
824 Symbol_Policy
: Policy
:= Autonomous
;
826 -- Type to keep the symbol data to be used when building a shared library
828 No_Symbols
: constant Symbol_Record
:=
829 (Symbol_File
=> No_Path
,
830 Reference
=> No_Path
,
831 Symbol_Policy
=> Autonomous
);
832 -- The default value of the symbol data
834 function Image
(Casing
: Casing_Type
) return String;
835 -- Similar to 'Image (but avoid use of this attribute in compiler)
837 function Value
(Image
: String) return Casing_Type
;
838 -- Similar to 'Value (but avoid use of this attribute in compiler)
839 -- Raises Constraint_Error if not a Casing_Type image.
841 -- Declarations for gprmake:
843 First_Language_Index
: constant Language_Index
:= 1;
844 First_Language_Indexes_Last
: constant Language_Index
:= 5;
846 Ada_Language_Index
: constant Language_Index
:=
847 First_Language_Index
;
848 C_Language_Index
: constant Language_Index
:=
849 Ada_Language_Index
+ 1;
850 C_Plus_Plus_Language_Index
: constant Language_Index
:=
851 C_Language_Index
+ 1;
853 Last_Language_Index
: Language_Index
:= No_Language_Index
;
855 subtype First_Language_Indexes
is Language_Index
856 range First_Language_Index
.. First_Language_Indexes_Last
;
858 package Language_Indexes
is new System
.HTable
.Simple_HTable
859 (Header_Num
=> Header_Num
,
860 Element
=> Language_Index
,
861 No_Element
=> No_Language_Index
,
865 -- Mapping of language names to language indexes
867 package Language_Names
is new Table
.Table
868 (Table_Component_Type
=> Name_Id
,
869 Table_Index_Type
=> Language_Index
,
870 Table_Low_Bound
=> 1,
872 Table_Increment
=> 100,
873 Table_Name
=> "Prj.Language_Names");
874 -- The table for the name of programming languages
876 procedure Add_Language_Name
(Name
: Name_Id
);
878 procedure Display_Language_Name
(Language
: Language_Index
);
880 type Languages_In_Project
is array (First_Language_Indexes
) of Boolean;
881 -- Set of supported languages used in a project
883 No_Languages
: constant Languages_In_Project
:= (others => False);
884 -- No supported languages are used
886 type Supp_Language_Index
is new Nat
;
887 No_Supp_Language_Index
: constant Supp_Language_Index
:= 0;
889 type Supp_Language
is record
890 Index
: Language_Index
:= No_Language_Index
;
891 Present
: Boolean := False;
892 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
895 package Present_Language_Table
is new GNAT
.Dynamic_Tables
896 (Table_Component_Type
=> Supp_Language
,
897 Table_Index_Type
=> Supp_Language_Index
,
898 Table_Low_Bound
=> 1,
900 Table_Increment
=> 100);
901 -- The table for the presence of languages with an index that is outside
902 -- of First_Language_Indexes.
904 type Impl_Suffix_Array
is array (First_Language_Indexes
) of File_Name_Type
;
905 -- Suffixes for the non spec sources of the different supported languages
908 No_Impl_Suffixes
: constant Impl_Suffix_Array
:= (others => No_File
);
909 -- A default value for the non spec source suffixes
911 type Supp_Suffix
is record
912 Index
: Language_Index
:= No_Language_Index
;
913 Suffix
: File_Name_Type
:= No_File
;
914 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
917 package Supp_Suffix_Table
is new GNAT
.Dynamic_Tables
918 (Table_Component_Type
=> Supp_Suffix
,
919 Table_Index_Type
=> Supp_Language_Index
,
920 Table_Low_Bound
=> 1,
922 Table_Increment
=> 100);
923 -- The table for the presence of languages with an index that is outside
924 -- of First_Language_Indexes.
926 type Lang_Kind
is (GNU
, Other
);
928 type Language_Processing_Data
is record
929 Compiler_Drivers
: Name_List_Index
:= No_Name_List
;
930 Compiler_Paths
: Name_Id
:= No_Name
;
931 Compiler_Kinds
: Lang_Kind
:= GNU
;
932 Dependency_Options
: Name_List_Index
:= No_Name_List
;
933 Compute_Dependencies
: Name_List_Index
:= No_Name_List
;
934 Include_Options
: Name_List_Index
:= No_Name_List
;
935 Binder_Drivers
: Name_Id
:= No_Name
;
936 Binder_Driver_Paths
: Name_Id
:= No_Name
;
939 Default_Language_Processing_Data
:
940 constant Language_Processing_Data
:=
941 (Compiler_Drivers
=> No_Name_List
,
942 Compiler_Paths
=> No_Name
,
943 Compiler_Kinds
=> GNU
,
944 Dependency_Options
=> No_Name_List
,
945 Compute_Dependencies
=> No_Name_List
,
946 Include_Options
=> No_Name_List
,
947 Binder_Drivers
=> No_Name
,
948 Binder_Driver_Paths
=> No_Name
);
950 type First_Language_Processing_Data
is
951 array (First_Language_Indexes
) of Language_Processing_Data
;
953 Default_First_Language_Processing_Data
:
954 constant First_Language_Processing_Data
:=
955 (others => Default_Language_Processing_Data
);
957 type Supp_Language_Data
is record
958 Index
: Language_Index
:= No_Language_Index
;
959 Data
: Language_Processing_Data
:= Default_Language_Processing_Data
;
960 Next
: Supp_Language_Index
:= No_Supp_Language_Index
;
963 package Supp_Language_Table
is new GNAT
.Dynamic_Tables
964 (Table_Component_Type
=> Supp_Language_Data
,
965 Table_Index_Type
=> Supp_Language_Index
,
966 Table_Low_Bound
=> 1,
968 Table_Increment
=> 100);
969 -- The table for language data when there are more languages than
970 -- in First_Language_Indexes.
972 type Other_Source_Id
is new Nat
;
973 No_Other_Source
: constant Other_Source_Id
:= 0;
975 type Other_Source
is record
976 Language
: Language_Index
; -- language of the source
977 File_Name
: File_Name_Type
; -- source file simple name
978 Path_Name
: Path_Name_Type
; -- source full path name
979 Source_TS
: Time_Stamp_Type
; -- source file time stamp
980 Object_Name
: File_Name_Type
; -- object file simple name
981 Object_Path
: Path_Name_Type
; -- object full path name
982 Object_TS
: Time_Stamp_Type
; -- object file time stamp
983 Dep_Name
: File_Name_Type
; -- dependency file simple name
984 Dep_Path
: Path_Name_Type
; -- dependency full path name
985 Dep_TS
: Time_Stamp_Type
; -- dependency file time stamp
986 Naming_Exception
: Boolean := False; -- True if a naming exception
987 Next
: Other_Source_Id
:= No_Other_Source
;
989 -- Data for a source in a language other than Ada
991 package Other_Source_Table
is new GNAT
.Dynamic_Tables
992 (Table_Component_Type
=> Other_Source
,
993 Table_Index_Type
=> Other_Source_Id
,
994 Table_Low_Bound
=> 1,
995 Table_Initial
=> 200,
996 Table_Increment
=> 100);
997 -- The table for sources of languages other than Ada
999 -- The following record contains data for a naming scheme
1001 type Naming_Data
is record
1003 Dot_Replacement
: File_Name_Type
:= No_File
;
1004 -- The string to replace '.' in the source file name (for Ada)
1006 Dot_Repl_Loc
: Source_Ptr
:= No_Location
;
1008 Casing
: Casing_Type
:= All_Lower_Case
;
1009 -- The casing of the source file name (for Ada)
1011 Spec_Suffix
: Array_Element_Id
:= No_Array_Element
;
1012 -- The string to append to the unit name for the
1013 -- source file name of a spec.
1014 -- Indexed by the programming language.
1016 Ada_Spec_Suffix_Loc
: Source_Ptr
:= No_Location
;
1018 Body_Suffix
: Array_Element_Id
:= No_Array_Element
;
1019 -- The string to append to the unit name for the
1020 -- source file name of a body.
1021 -- Indexed by the programming language.
1023 Ada_Body_Suffix_Loc
: Source_Ptr
:= No_Location
;
1025 Separate_Suffix
: File_Name_Type
:= No_File
;
1026 -- String to append to unit name for source file name of an Ada subunit
1028 Sep_Suffix_Loc
: Source_Ptr
:= No_Location
;
1029 -- Position in the project file source where Separate_Suffix is defined
1031 Specs
: Array_Element_Id
:= No_Array_Element
;
1032 -- An associative array mapping individual specs to source file names
1033 -- This is specific to Ada.
1035 Bodies
: Array_Element_Id
:= No_Array_Element
;
1036 -- An associative array mapping individual bodies to source file names
1037 -- This is specific to Ada.
1039 Specification_Exceptions
: Array_Element_Id
:= No_Array_Element
;
1040 -- An associative array listing spec file names that do not have the
1041 -- spec suffix. Not used by Ada. Indexed by programming language name.
1043 Implementation_Exceptions
: Array_Element_Id
:= No_Array_Element
;
1044 -- An associative array listing body file names that do not have the
1045 -- body suffix. Not used by Ada. Indexed by programming language name.
1049 Impl_Suffixes
: Impl_Suffix_Array
:= No_Impl_Suffixes
;
1050 Supp_Suffixes
: Supp_Language_Index
:= No_Supp_Language_Index
;
1053 function Spec_Suffix_Of
1054 (In_Tree
: Project_Tree_Ref
;
1056 Naming
: Naming_Data
) return String;
1058 function Spec_Suffix_Id_Of
1059 (In_Tree
: Project_Tree_Ref
;
1061 Naming
: Naming_Data
) return File_Name_Type
;
1063 function Spec_Suffix_Id_Of
1064 (In_Tree
: Project_Tree_Ref
;
1065 Language_Id
: Name_Id
;
1066 Naming
: Naming_Data
) return File_Name_Type
;
1068 procedure Set_Spec_Suffix
1069 (In_Tree
: Project_Tree_Ref
;
1071 Naming
: in out Naming_Data
;
1072 Suffix
: File_Name_Type
);
1074 function Body_Suffix_Id_Of
1075 (In_Tree
: Project_Tree_Ref
;
1077 Naming
: Naming_Data
) return File_Name_Type
;
1079 function Body_Suffix_Id_Of
1080 (In_Tree
: Project_Tree_Ref
;
1081 Language_Id
: Name_Id
;
1082 Naming
: Naming_Data
) return File_Name_Type
;
1084 function Body_Suffix_Of
1085 (In_Tree
: Project_Tree_Ref
;
1087 Naming
: Naming_Data
) return String;
1089 procedure Set_Body_Suffix
1090 (In_Tree
: Project_Tree_Ref
;
1092 Naming
: in out Naming_Data
;
1093 Suffix
: File_Name_Type
);
1095 function Objects_Exist_For
1097 In_Tree
: Project_Tree_Ref
) return Boolean;
1099 function Standard_Naming_Data
1100 (Tree
: Project_Tree_Ref
:= No_Project_Tree
) return Naming_Data
;
1101 pragma Inline
(Standard_Naming_Data
);
1102 -- The standard GNAT naming scheme when Tree is No_Project_Tree.
1103 -- Otherwise, return the default naming scheme for the project tree Tree,
1104 -- which must have been Initialized.
1106 function Same_Naming_Scheme
1107 (Left
, Right
: Naming_Data
) return Boolean;
1108 -- Returns True if Left and Right are the same naming scheme
1109 -- not considering Specs and Bodies.
1111 type Project_List
is new Nat
;
1112 Empty_Project_List
: constant Project_List
:= 0;
1113 -- A list of project files
1115 type Project_Element
is record
1116 Project
: Project_Id
:= No_Project
;
1117 Next
: Project_List
:= Empty_Project_List
;
1119 -- Element in a list of project files. Next is the id of the next
1120 -- project file in the list.
1122 package Project_List_Table
is new GNAT
.Dynamic_Tables
1123 (Table_Component_Type
=> Project_Element
,
1124 Table_Index_Type
=> Project_List
,
1125 Table_Low_Bound
=> 1,
1126 Table_Initial
=> 100,
1127 Table_Increment
=> 100);
1128 -- The table that contains the lists of project files
1130 type Project_Configuration
is record
1131 Run_Path_Option
: Name_List_Index
:= No_Name_List
;
1132 -- The option to use when linking to specify the path where to look for
1135 Executable_Suffix
: Name_Id
:= No_Name
;
1136 -- The suffix of executables, when specified in the configuration or in
1137 -- package Builder of the main project. When this is not specified, the
1138 -- executable suffix is the default for the platform.
1142 Linker
: Path_Name_Type
:= No_Path
;
1143 -- Path name of the linker driver. Specified in the configuration or in
1144 -- the package Builder of the main project.
1146 Map_File_Option
: Name_Id
:= No_Name
;
1147 -- Option to use when invoking the linker to build a map file
1149 Minimum_Linker_Options
: Name_List_Index
:= No_Name_List
;
1150 -- The minimum options for the linker driver. Specified in the
1153 Linker_Executable_Option
: Name_List_Index
:= No_Name_List
;
1154 -- The option(s) to indicate the name of the executable in the linker
1155 -- command. Specified in the configuration. When not specified, default
1156 -- to -o <executable name>.
1158 Linker_Lib_Dir_Option
: Name_Id
:= No_Name
;
1159 -- The option to specify where to find a library for linking. Specified
1160 -- in the configuration. When not specified, defaults to "-L".
1162 Linker_Lib_Name_Option
: Name_Id
:= No_Name
;
1163 -- The option to specify the name of a library for linking. Specified in
1164 -- the configuration. When not specified, defaults to "-l".
1168 Library_Builder
: Path_Name_Type
:= No_Path
;
1169 -- The executable to build library (specified in the configuration)
1171 Lib_Support
: Library_Support
:= None
;
1172 -- The level of library support. Specified in the configuration. Support
1173 -- is none, static libraries only or both static and shared libraries.
1175 Archive_Builder
: Name_List_Index
:= No_Name_List
;
1176 -- The name of the executable to build archives, with the minimum
1177 -- switches. Specified in the configuration.
1179 Archive_Builder_Append_Option
: Name_List_Index
:= No_Name_List
;
1180 -- The options to append object files to an archive
1182 Archive_Indexer
: Name_List_Index
:= No_Name_List
;
1183 -- The name of the executable to index archives, with the minimum
1184 -- switches. Specified in the configuration.
1186 Archive_Suffix
: File_Name_Type
:= No_File
;
1187 -- The suffix of archives. Specified in the configuration. When not
1188 -- specified, defaults to ".a".
1190 Lib_Partial_Linker
: Name_List_Index
:= No_Name_List
;
1194 Shared_Lib_Driver
: File_Name_Type
:= No_File
;
1195 -- The driver to link shared libraries. Set with attribute Library_GCC.
1198 Shared_Lib_Prefix
: File_Name_Type
:= No_File
;
1199 -- Part of a shared library file name that precedes the name of the
1200 -- library. Specified in the configuration. When not specified, defaults
1203 Shared_Lib_Suffix
: File_Name_Type
:= No_File
;
1204 -- Suffix of shared libraries, after the library name in the shared
1205 -- library name. Specified in the configuration. When not specified,
1206 -- default to ".so".
1208 Shared_Lib_Min_Options
: Name_List_Index
:= No_Name_List
;
1209 -- The minimum options to use when building a shared library
1211 Lib_Version_Options
: Name_List_Index
:= No_Name_List
;
1212 -- The options to use to specify a library version
1214 Symbolic_Link_Supported
: Boolean := False;
1215 -- True if the platform supports symbolic link files
1217 Lib_Maj_Min_Id_Supported
: Boolean := False;
1218 -- True if platform supports library major and minor options, such as
1219 -- libname.so -> libname.so.2 -> libname.so.2.4
1221 Auto_Init_Supported
: Boolean := False;
1222 -- True if automatic initialisation is supported for shared stand-alone
1226 Default_Project_Config
: constant Project_Configuration
:=
1227 (Run_Path_Option
=> No_Name_List
,
1228 Executable_Suffix
=> No_Name
,
1230 Map_File_Option
=> No_Name
,
1231 Minimum_Linker_Options
=> No_Name_List
,
1232 Linker_Executable_Option
=> No_Name_List
,
1233 Linker_Lib_Dir_Option
=> No_Name
,
1234 Linker_Lib_Name_Option
=> No_Name
,
1235 Library_Builder
=> No_Path
,
1236 Lib_Support
=> None
,
1237 Archive_Builder
=> No_Name_List
,
1238 Archive_Builder_Append_Option
=> No_Name_List
,
1239 Archive_Indexer
=> No_Name_List
,
1240 Archive_Suffix
=> No_File
,
1241 Lib_Partial_Linker
=> No_Name_List
,
1242 Shared_Lib_Driver
=> No_File
,
1243 Shared_Lib_Prefix
=> No_File
,
1244 Shared_Lib_Suffix
=> No_File
,
1245 Shared_Lib_Min_Options
=> No_Name_List
,
1246 Lib_Version_Options
=> No_Name_List
,
1247 Symbolic_Link_Supported
=> False,
1248 Lib_Maj_Min_Id_Supported
=> False,
1249 Auto_Init_Supported
=> False);
1251 -- The following record describes a project file representation
1253 -- Note that it is not specified if the path names of directories (source,
1254 -- object, library or exec directories) end with or without a directory
1257 type Project_Data
is record
1263 Name
: Name_Id
:= No_Name
;
1264 -- The name of the project
1266 Display_Name
: Name_Id
:= No_Name
;
1267 -- The name of the project with the spelling of its declaration
1269 Qualifier
: Project_Qualifier
:= Unspecified
;
1270 -- The eventual qualifier for this project
1272 Externally_Built
: Boolean := False;
1273 -- True if the project is externally built. In such case, the Project
1274 -- Manager will not modify anything in this project.
1276 Config
: Project_Configuration
;
1278 Path
: Path_Information
:= No_Path_Information
;
1279 -- The path name of the project file
1281 Virtual
: Boolean := False;
1282 -- True for virtual extending projects
1284 Location
: Source_Ptr
:= No_Location
;
1285 -- The location in the project file source of the reserved word project
1287 Naming
: Naming_Data
:= Standard_Naming_Data
;
1288 -- The naming scheme of this project file
1294 Languages
: Name_List_Index
:= No_Name_List
;
1295 -- The list of languages of the sources of this project
1297 Include_Language
: Language_Index
:= No_Language_Index
;
1299 First_Language_Processing
: Language_Index
:= No_Language_Index
;
1300 -- First index of the language data in the project
1302 Unit_Based_Language_Name
: Name_Id
:= No_Name
;
1303 Unit_Based_Language_Index
: Language_Index
:= No_Language_Index
;
1304 -- The name and index, if any, of the unit-based language of some
1305 -- sources of the project. There may be only one unit-based language
1312 First_Referred_By
: Project_Id
:= No_Project
;
1313 -- The project, if any, that was the first to be known as importing or
1314 -- extending this project
1316 Mains
: String_List_Id
:= Nil_String
;
1317 -- List of mains specified by attribute Main
1319 Extends
: Project_Id
:= No_Project
;
1320 -- The reference of the project file, if any, that this project file
1323 Extended_By
: Project_Id
:= No_Project
;
1324 -- The reference of the project file, if any, that extends this project
1327 Decl
: Declarations
:= No_Declarations
;
1328 -- The declarations (variables, attributes and packages) of this project
1331 Imported_Projects
: Project_List
:= Empty_Project_List
;
1332 -- The list of all directly imported projects, if any
1334 All_Imported_Projects
: Project_List
:= Empty_Project_List
;
1335 -- The list of all projects imported directly or indirectly, if any
1341 Directory
: Path_Information
:= No_Path_Information
;
1342 -- Path name of the directory where the project file resides
1344 Dir_Path
: String_Access
;
1345 -- Same as Directory.Name, but as an access to String
1347 Object_Directory
: Path_Information
:= No_Path_Information
;
1348 -- The path name of the object directory of this project file
1350 Exec_Directory
: Path_Information
:= No_Path_Information
;
1351 -- The path name of the exec directory of this project file. Default is
1352 -- equal to Object_Directory.
1358 Library
: Boolean := False;
1359 -- True if this is a library project
1361 Library_Name
: Name_Id
:= No_Name
;
1362 -- If a library project, name of the library
1364 Library_Kind
: Lib_Kind
:= Static
;
1365 -- If a library project, kind of library
1367 Library_Dir
: Path_Information
:= No_Path_Information
;
1368 -- If a library project, path name of the directory where the library
1371 Library_TS
: Time_Stamp_Type
:= Empty_Time_Stamp
;
1372 -- The timestamp of a library file in a library project
1374 Library_Src_Dir
: Path_Information
:= No_Path_Information
;
1375 -- If a Stand-Alone Library project, path name of the directory where
1376 -- the sources of the interfaces of the library are copied. By default,
1377 -- if attribute Library_Src_Dir is not specified, sources of the
1378 -- interfaces are not copied anywhere.
1380 Library_ALI_Dir
: Path_Information
:= No_Path_Information
;
1381 -- In a library project, path name of the directory where the ALI files
1382 -- are copied. If attribute Library_ALI_Dir is not specified, ALI files
1383 -- are copied in the Library_Dir.
1385 Lib_Internal_Name
: Name_Id
:= No_Name
;
1386 -- If a library project, internal name store inside the library
1388 Standalone_Library
: Boolean := False;
1389 -- Indicate that this is a Standalone Library Project File
1391 Lib_Interface_ALIs
: String_List_Id
:= Nil_String
;
1392 -- For Standalone Library Project Files, indicate the list of Interface
1395 Lib_Auto_Init
: Boolean := False;
1396 -- For non static Stand-Alone Library Project Files, indicate if
1397 -- the library initialisation should be automatic.
1399 Symbol_Data
: Symbol_Record
:= No_Symbols
;
1400 -- Symbol file name, reference symbol file name, symbol policy
1402 Need_To_Build_Lib
: Boolean := False;
1403 -- Indicates that the library of a Library Project needs to be built or
1410 Ada_Sources
: String_List_Id
:= Nil_String
;
1411 -- The list of all the Ada source file names (gnatmake only)
1413 Sources
: String_List_Id
:= Nil_String
;
1414 -- Identical to Ada_Sources (for upward compatibility with GPS)
1416 First_Source
: Source_Id
:= No_Source
;
1417 Last_Source
: Source_Id
:= No_Source
;
1418 -- Head and tail of the list of sources
1420 Interfaces_Defined
: Boolean := False;
1421 -- True if attribute Interfaces is declared for the project or any
1422 -- project it extends.
1424 Imported_Directories_Switches
: Argument_List_Access
:= null;
1425 -- List of the source search switches (-I<source dir>) to be used when
1428 Include_Path
: String_Access
:= null;
1429 -- The search source path for the project. Used as the value for an
1430 -- environment variable, specified by attribute Include_Path
1431 -- (<language>). The names of the environment variables are in component
1432 -- Include_Path of the records Language_Config.
1434 Include_Path_File
: Path_Name_Type
:= No_Path
;
1435 -- The path name of the of the source search directory file
1437 Include_Data_Set
: Boolean := False;
1438 -- Set True when Imported_Directories_Switches or Include_Path are set
1440 Source_Dirs
: String_List_Id
:= Nil_String
;
1441 -- The list of all the source directories
1443 Known_Order_Of_Source_Dirs
: Boolean := True;
1444 -- False, if there is any /** in the Source_Dirs, because in this case
1445 -- the ordering of the source subdirs depend on the OS. If True,
1446 -- duplicate file names in the same project file are allowed.
1448 Ada_Include_Path
: String_Access
:= null;
1449 -- The cached value of source search path for this project file. Set by
1450 -- the first call to Prj.Env.Ada_Include_Path for the project. Do not
1451 -- use this field directly outside of the project manager, use
1452 -- Prj.Env.Ada_Include_Path instead.
1458 Linker_Name
: File_Name_Type
:= No_File
;
1459 -- Value of attribute Language_Processing'Linker in the project file
1461 Linker_Path
: Path_Name_Type
:= No_Path
;
1462 -- Path of linker when attribute Language_Processing'Linker is specified
1464 Minimum_Linker_Options
: Name_List_Index
:= No_Name_List
;
1465 -- List of options specified in attribute
1466 -- Language_Processing'Minimum_Linker_Options.
1472 Ada_Objects_Path
: String_Access
:= null;
1473 -- The cached value of ADA_OBJECTS_PATH for this project file. Do not
1474 -- use this field directly outside of the compiler, use
1475 -- Prj.Env.Ada_Objects_Path instead.
1477 Libgnarl_Needed
: Yes_No_Unknown
:= Unknown
;
1478 -- Set to True when libgnarl is needed to link
1480 Objects_Path
: String_Access
:= null;
1481 -- The cached value of the object dir path, used during the binding
1482 -- phase of gprbuild.
1484 Objects_Path_File_With_Libs
: Path_Name_Type
:= No_Path
;
1485 -- The cached value of the object path temp file (including library
1486 -- dirs) for this project file.
1488 Objects_Path_File_Without_Libs
: Path_Name_Type
:= No_Path
;
1489 -- The cached value of the object path temp file (excluding library
1490 -- dirs) for this project file.
1492 Config_File_Name
: Path_Name_Type
:= No_Path
;
1493 -- The path name of the configuration pragmas file, if any
1495 Config_File_Temp
: Boolean := False;
1496 -- An indication that the configuration pragmas file is a temporary file
1497 -- that must be deleted at the end.
1499 Config_Checked
: Boolean := False;
1500 -- A flag to avoid checking repetitively the configuration pragmas file
1502 Checked
: Boolean := False;
1503 -- A flag to avoid checking repetitively the naming scheme of this
1506 Seen
: Boolean := False;
1507 -- A flag to mark a project as "visited" to avoid processing the same
1508 -- project several time.
1510 Depth
: Natural := 0;
1511 -- The maximum depth of a project in the project graph. Depth of main
1514 Unkept_Comments
: Boolean := False;
1515 -- True if there are comments in the project sources that cannot be kept
1516 -- in the project tree.
1522 Langs
: Languages_In_Project
:= No_Languages
;
1523 Supp_Languages
: Supp_Language_Index
:= No_Supp_Language_Index
;
1524 -- Indicate the different languages of the source of this project
1526 Ada_Sources_Present
: Boolean := True;
1527 -- True if there are Ada sources in the project
1529 Other_Sources_Present
: Boolean := True;
1530 -- True if there are sources from languages other than Ada in the
1533 First_Other_Source
: Other_Source_Id
:= No_Other_Source
;
1534 -- First source of a language other than Ada
1536 Last_Other_Source
: Other_Source_Id
:= No_Other_Source
;
1537 -- Last source of a language other than Ada
1539 First_Lang_Processing
: First_Language_Processing_Data
:=
1540 Default_First_Language_Processing_Data
;
1541 Supp_Language_Processing
: Supp_Language_Index
:=
1542 No_Supp_Language_Index
;
1543 -- Language configurations
1546 function Empty_Project
(Tree
: Project_Tree_Ref
) return Project_Data
;
1547 -- Return the representation of an empty project in project Tree tree.
1548 -- The project tree Tree must have been Initialized and/or Reset.
1550 function Is_Extending
1551 (Extending
: Project_Id
;
1552 Extended
: Project_Id
;
1553 In_Tree
: Project_Tree_Ref
) return Boolean;
1554 -- ??? needs comment
1556 function Is_A_Language
1557 (Tree
: Project_Tree_Ref
;
1558 Data
: Project_Data
;
1559 Language_Name
: Name_Id
) return Boolean;
1560 -- Return True when Language_Name (which must be lower case) is one of the
1561 -- languages used for the project.
1563 function There_Are_Ada_Sources
1564 (In_Tree
: Project_Tree_Ref
;
1565 Project
: Project_Id
) return Boolean;
1566 -- ??? needs comment
1567 -- ??? Name sounds strange, suggested replacement: Ada_Sources_Present
1569 Project_Error
: exception;
1570 -- Raised by some subprograms in Prj.Attr
1572 package Project_Table
is new GNAT
.Dynamic_Tables
(
1573 Table_Component_Type
=> Project_Data
,
1574 Table_Index_Type
=> Project_Id
,
1575 Table_Low_Bound
=> 1,
1576 Table_Initial
=> 100,
1577 Table_Increment
=> 100);
1578 -- The set of all project files
1580 type Spec_Or_Body
is (Specification
, Body_Part
);
1582 type File_Name_Data
is record
1583 Name
: File_Name_Type
:= No_File
;
1585 Display_Name
: File_Name_Type
:= No_File
;
1586 Path
: Path_Information
:= No_Path_Information
;
1587 Project
: Project_Id
:= No_Project
;
1588 Needs_Pragma
: Boolean := False;
1590 -- File and Path name of a spec or body
1592 type File_Names_Data
is array (Spec_Or_Body
) of File_Name_Data
;
1594 type Unit_Index
is new Nat
;
1595 No_Unit_Index
: constant Unit_Index
:= 0;
1596 type Unit_Data
is record
1597 Name
: Name_Id
:= No_Name
;
1598 File_Names
: File_Names_Data
;
1600 -- Name and File and Path names of a unit, with a reference to its
1601 -- GNAT Project File(s).
1603 package Unit_Table
is new GNAT
.Dynamic_Tables
1604 (Table_Component_Type
=> Unit_Data
,
1605 Table_Index_Type
=> Unit_Index
,
1606 Table_Low_Bound
=> 1,
1607 Table_Initial
=> 100,
1608 Table_Increment
=> 100);
1609 -- Table of all units in a project tree
1611 package Units_Htable
is new Simple_HTable
1612 (Header_Num
=> Header_Num
,
1613 Element
=> Unit_Index
,
1614 No_Element
=> No_Unit_Index
,
1618 -- Mapping of unit names to indexes in the Units table
1620 type Unit_Project
is record
1621 Unit
: Unit_Index
:= No_Unit_Index
;
1622 Project
: Project_Id
:= No_Project
;
1625 No_Unit_Project
: constant Unit_Project
:= (No_Unit_Index
, No_Project
);
1627 package Files_Htable
is new Simple_HTable
1628 (Header_Num
=> Header_Num
,
1629 Element
=> Unit_Project
,
1630 No_Element
=> No_Unit_Project
,
1631 Key
=> File_Name_Type
,
1634 -- Mapping of file names to indexes in the Units table
1636 type Private_Project_Tree_Data
is private;
1637 -- Data for a project tree that is used only by the Project Manager
1639 type Project_Tree_Data
is
1641 -- Languages and sources of the project
1643 First_Language
: Language_Index
:= No_Language_Index
;
1646 First_Source
: Source_Id
:= No_Source
;
1651 Languages_Data
: Language_Data_Table
.Instance
;
1652 Name_Lists
: Name_List_Table
.Instance
;
1653 String_Elements
: String_Element_Table
.Instance
;
1654 Variable_Elements
: Variable_Element_Table
.Instance
;
1655 Array_Elements
: Array_Element_Table
.Instance
;
1656 Arrays
: Array_Table
.Instance
;
1657 Packages
: Package_Table
.Instance
;
1658 Project_Lists
: Project_List_Table
.Instance
;
1659 Projects
: Project_Table
.Instance
;
1660 Sources
: Source_Data_Table
.Instance
;
1661 Alt_Langs
: Alternate_Language_Table
.Instance
;
1662 Units
: Unit_Table
.Instance
;
1663 Units_HT
: Units_Htable
.Instance
;
1664 Files_HT
: Files_Htable
.Instance
;
1665 Source_Paths_HT
: Source_Paths_Htable
.Instance
;
1669 Present_Languages
: Present_Language_Table
.Instance
;
1670 Supp_Suffixes
: Supp_Suffix_Table
.Instance
;
1671 Supp_Languages
: Supp_Language_Table
.Instance
;
1672 Other_Sources
: Other_Source_Table
.Instance
;
1676 Private_Part
: Private_Project_Tree_Data
;
1678 -- Data for a project tree
1680 type Put_Line_Access
is access procedure
1682 Project
: Project_Id
;
1683 In_Tree
: Project_Tree_Ref
);
1684 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
1686 procedure Expect
(The_Token
: Token_Type
; Token_Image
: String);
1687 -- Check that the current token is The_Token. If it is not, then output
1688 -- an error message.
1690 procedure Initialize
(Tree
: Project_Tree_Ref
);
1691 -- This procedure must be called before using any services from the Prj
1692 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
1694 procedure Reset
(Tree
: Project_Tree_Ref
);
1695 -- This procedure resets all the tables that are used when processing a
1696 -- project file tree. Initialize must be called before the call to Reset.
1698 procedure Register_Default_Naming_Scheme
1699 (Language
: Name_Id
;
1700 Default_Spec_Suffix
: File_Name_Type
;
1701 Default_Body_Suffix
: File_Name_Type
;
1702 In_Tree
: Project_Tree_Ref
);
1703 -- Register the default suffixes for a given language. These extensions
1704 -- will be ignored if the user has specified a new naming scheme in a
1707 -- Otherwise, this information will be automatically added to Naming_Data
1708 -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
1711 type State
is limited private;
1712 with procedure Action
1713 (Project
: Project_Id
;
1714 With_State
: in out State
);
1715 procedure For_Every_Project_Imported
1717 In_Tree
: Project_Tree_Ref
;
1718 With_State
: in out State
);
1719 -- Call Action for each project imported directly or indirectly by project
1720 -- By. Action is called according to the order of importation: if A
1721 -- imports B, directly or indirectly, Action will be called for A before
1722 -- it is called for B. If two projects import each other directly or
1723 -- indirectly (using at least one "limited with"), it is not specified
1724 -- for which of these two projects Action will be called first. Projects
1725 -- that are extended by other projects are not considered. With_State may
1726 -- be used by Action to choose a behavior or to report some global result.
1728 function Extend_Name
1729 (File
: File_Name_Type
;
1730 With_Suffix
: String) return File_Name_Type
;
1731 -- Replace the extension of File with With_Suffix
1733 function Object_Name
1734 (Source_File_Name
: File_Name_Type
) return File_Name_Type
;
1735 -- Returns the object file name corresponding to a source file name
1737 function Dependency_Name
1738 (Source_File_Name
: File_Name_Type
;
1739 Dependency
: Dependency_File_Kind
) return File_Name_Type
;
1740 -- Returns the dependency file name corresponding to a source file name
1742 function Switches_Name
1743 (Source_File_Name
: File_Name_Type
) return File_Name_Type
;
1744 -- Returns the switches file name corresponding to a source file name
1748 function Body_Suffix_Of
1749 (Language
: Language_Index
;
1750 In_Project
: Project_Data
;
1751 In_Tree
: Project_Tree_Ref
) return String;
1752 -- Returns the suffix of sources of language Language in project In_Project
1753 -- in project tree In_Tree.
1756 (Language
: Language_Index
;
1757 In_Project
: Project_Data
;
1758 In_Tree
: Project_Tree_Ref
) return Boolean;
1759 -- Return True when Language is one of the languages used in
1760 -- project In_Project.
1763 (Language
: Language_Index
;
1765 In_Project
: in out Project_Data
;
1766 In_Tree
: Project_Tree_Ref
);
1767 -- Indicate if Language is or not a language used in project In_Project
1769 function Language_Processing_Data_Of
1770 (Language
: Language_Index
;
1771 In_Project
: Project_Data
;
1772 In_Tree
: Project_Tree_Ref
) return Language_Processing_Data
;
1773 -- Return the Language_Processing_Data for language Language in project
1774 -- In_Project. Return the default when no Language_Processing_Data are
1775 -- defined for the language.
1778 (Language_Processing
: Language_Processing_Data
;
1779 For_Language
: Language_Index
;
1780 In_Project
: in out Project_Data
;
1781 In_Tree
: Project_Tree_Ref
);
1782 -- Set the Language_Processing_Data for language Language in project
1786 (Language
: Language_Index
;
1787 In_Project
: Project_Data
;
1788 In_Tree
: Project_Tree_Ref
) return File_Name_Type
;
1789 -- Return the suffix for language Language in project In_Project. Return
1790 -- No_Name when no suffix is defined for the language.
1793 (Suffix
: File_Name_Type
;
1794 For_Language
: Language_Index
;
1795 In_Project
: in out Project_Data
;
1796 In_Tree
: Project_Tree_Ref
);
1797 -- Set the suffix for language Language in project In_Project
1803 procedure Record_Temp_File
(Path
: Path_Name_Type
);
1804 -- Record the path of a newly created temporary file, so that it can be
1807 procedure Delete_All_Temp_Files
;
1808 -- Delete all recorded temporary files
1812 All_Packages
: constant String_List_Access
:= null;
1814 No_Project_Tree
: constant Project_Tree_Ref
:= null;
1816 Ignored
: constant Variable_Kind
:= Single
;
1818 Nil_Variable_Value
: constant Variable_Value
:=
1819 (Project
=> No_Project
,
1821 Location
=> No_Location
,
1824 Virtual_Prefix
: constant String := "v$";
1825 -- The prefix for virtual extending projects. Because of the '$', which is
1826 -- normally forbidden for project names, there cannot be any name clash.
1828 Empty_Name
: Name_Id
;
1829 -- Name_Id for an empty name (no characters). Initialized in procedure
1832 Empty_File_Name
: File_Name_Type
;
1833 -- Empty File_Name_Type (no characters). Initialized in procedure
1836 procedure Add_To_Buffer
1838 To
: in out String_Access
;
1839 Last
: in out Natural);
1840 -- Append a String to the Buffer
1842 type Naming_Id
is new Nat
;
1844 package Naming_Table
is new GNAT
.Dynamic_Tables
1845 (Table_Component_Type
=> Naming_Data
,
1846 Table_Index_Type
=> Naming_Id
,
1847 Table_Low_Bound
=> 1,
1849 Table_Increment
=> 100);
1850 -- Table storing the naming data for gnatmake/gprmake
1852 package Path_File_Table
is new GNAT
.Dynamic_Tables
1853 (Table_Component_Type
=> Path_Name_Type
,
1854 Table_Index_Type
=> Natural,
1855 Table_Low_Bound
=> 1,
1856 Table_Initial
=> 50,
1857 Table_Increment
=> 100);
1858 -- Table storing all the temp path file names.
1859 -- Used by Delete_All_Path_Files.
1861 package Source_Path_Table
is new GNAT
.Dynamic_Tables
1862 (Table_Component_Type
=> Name_Id
,
1863 Table_Index_Type
=> Natural,
1864 Table_Low_Bound
=> 1,
1865 Table_Initial
=> 50,
1866 Table_Increment
=> 100);
1867 -- A table to store the source dirs before creating the source path file
1869 package Object_Path_Table
is new GNAT
.Dynamic_Tables
1870 (Table_Component_Type
=> Path_Name_Type
,
1871 Table_Index_Type
=> Natural,
1872 Table_Low_Bound
=> 1,
1873 Table_Initial
=> 50,
1874 Table_Increment
=> 100);
1875 -- A table to store the object dirs, before creating the object path file
1877 type Private_Project_Tree_Data
is record
1878 Namings
: Naming_Table
.Instance
;
1879 Path_Files
: Path_File_Table
.Instance
;
1880 Source_Paths
: Source_Path_Table
.Instance
;
1881 Object_Paths
: Object_Path_Table
.Instance
;
1882 Default_Naming
: Naming_Data
;
1884 -- Type to represent the part of a project tree which is private to the