1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2000-2004 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Err_Vars
; use Err_Vars
;
31 with Namet
; use Namet
;
32 with Osint
; use Osint
;
33 with Output
; use Output
;
34 with MLib
.Tgt
; use MLib
.Tgt
;
35 with Prj
.Com
; use Prj
.Com
;
36 with Prj
.Env
; use Prj
.Env
;
38 with Prj
.Util
; use Prj
.Util
;
40 with Snames
; use Snames
;
41 with Table
; use Table
;
42 with Types
; use Types
;
44 with Ada
.Characters
.Handling
; use Ada
.Characters
.Handling
;
45 with Ada
.Strings
; use Ada
.Strings
;
46 with Ada
.Strings
.Fixed
; use Ada
.Strings
.Fixed
;
47 with Ada
.Strings
.Maps
.Constants
; use Ada
.Strings
.Maps
.Constants
;
49 with GNAT
.Case_Util
; use GNAT
.Case_Util
;
50 with GNAT
.Directory_Operations
; use GNAT
.Directory_Operations
;
51 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
54 package body Prj
.Nmsc
is
56 Error_Report
: Put_Line_Access
:= null;
57 -- Set to point to error reporting procedure
59 ALI_Suffix
: constant String := ".ali";
60 -- File suffix for ali files
62 Object_Suffix
: constant String := Get_Object_Suffix
.all;
63 -- File suffix for object files
65 type Name_Location
is record
67 Location
: Source_Ptr
;
68 Found
: Boolean := False;
70 -- Information about file names found in string list attribute
71 -- Source_Files or in a source list file, stored in hash table
72 -- Source_Names, used by procedure Get_Path_Names_And_Record_Sources.
74 No_Name_Location
: constant Name_Location
:=
75 (Name
=> No_Name
, Location
=> No_Location
, Found
=> False);
77 package Source_Names
is new GNAT
.HTable
.Simple_HTable
78 (Header_Num
=> Header_Num
,
79 Element
=> Name_Location
,
80 No_Element
=> No_Name_Location
,
84 -- Hash table to store file names found in string list attribute
85 -- Source_Files or in a source list file, stored in hash table
86 -- Source_Names, used by procedure Get_Path_Names_And_Record_Sources.
88 package Recursive_Dirs
is new GNAT
.HTable
.Simple_HTable
89 (Header_Num
=> Header_Num
,
95 -- Hash table to store recursive source directories, to avoid looking
96 -- several times, and to avoid cycles that may be introduced by symbolic
99 type Ada_Naming_Exception_Id
is new Nat
;
100 No_Ada_Naming_Exception
: constant Ada_Naming_Exception_Id
:= 0;
102 type Unit_Info
is record
105 Next
: Ada_Naming_Exception_Id
:= No_Ada_Naming_Exception
;
107 -- No_Unit : constant Unit_Info :=
108 -- (Specification, No_Name, No_Ada_Naming_Exception);
110 package Ada_Naming_Exception_Table
is new Table
.Table
111 (Table_Component_Type
=> Unit_Info
,
112 Table_Index_Type
=> Ada_Naming_Exception_Id
,
113 Table_Low_Bound
=> 1,
115 Table_Increment
=> 100,
116 Table_Name
=> "Prj.Nmsc.Ada_Naming_Exception_Table");
118 package Ada_Naming_Exceptions
is new GNAT
.HTable
.Simple_HTable
119 (Header_Num
=> Header_Num
,
120 Element
=> Ada_Naming_Exception_Id
,
121 No_Element
=> No_Ada_Naming_Exception
,
125 -- A hash table to store naming exceptions for Ada. For each file name
126 -- there is one or several unit in table Ada_Naming_Exception_Table.
128 function Hash
(Unit
: Unit_Info
) return Header_Num
;
130 type Name_And_Index
is record
131 Name
: Name_Id
:= No_Name
;
134 No_Name_And_Index
: constant Name_And_Index
:=
135 (Name
=> No_Name
, Index
=> 0);
137 package Reverse_Ada_Naming_Exceptions
is new GNAT
.HTable
.Simple_HTable
138 (Header_Num
=> Header_Num
,
139 Element
=> Name_And_Index
,
140 No_Element
=> No_Name_And_Index
,
144 -- A table to check if a unit with an exceptional name will hide
145 -- a source with a file name following the naming convention.
147 function ALI_File_Name
(Source
: String) return String;
148 -- Return the ALI file name corresponding to a source
150 procedure Check_Ada_Name
153 -- Check that a name is a valid Ada unit name
155 procedure Check_Naming_Scheme
156 (Data
: in out Project_Data
;
157 Project
: Project_Id
);
158 -- Check the naming scheme part of Data
160 procedure Check_Ada_Naming_Scheme_Validity
161 (Project
: Project_Id
;
162 Naming
: Naming_Data
);
163 -- Check that the package Naming is correct
165 procedure Check_For_Source
166 (File_Name
: Name_Id
;
168 Project
: Project_Id
;
169 Data
: in out Project_Data
;
170 Location
: Source_Ptr
;
171 Language
: Language_Index
;
173 Naming_Exception
: Boolean);
174 -- Check if a file in a source directory is a source for a specific
175 -- language other than Ada. Comments required for parameters ???
177 procedure Check_If_Externally_Built
178 (Project
: Project_Id
;
179 Data
: in out Project_Data
);
180 -- ??? comment required
182 procedure Check_Library_Attributes
183 (Project
: Project_Id
;
184 Data
: in out Project_Data
);
185 -- ??? comment required
187 procedure Check_Package_Naming
188 (Project
: Project_Id
;
189 Data
: in out Project_Data
);
190 -- ??? comment required
192 procedure Check_Programming_Languages
(Data
: in out Project_Data
);
193 -- ??? comment required
195 function Check_Project
197 Root_Project
: Project_Id
;
198 Extending
: Boolean) return Boolean;
199 -- Returns True if P is Root_Project or, if Extending is True, a project
200 -- extended by Root_Project.
202 procedure Check_Stand_Alone_Library
203 (Project
: Project_Id
;
204 Data
: in out Project_Data
;
205 Extending
: Boolean);
207 function Compute_Directory_Last
(Dir
: String) return Natural;
208 -- Return the index of the last significant character in Dir. This is used
209 -- to avoid duplicates '/' at the end of directory names
211 function Body_Suffix_Of
212 (Language
: Language_Index
; In_Project
: Project_Data
)
216 (Project
: Project_Id
;
218 Flag_Location
: Source_Ptr
);
219 -- Output an error message. If Error_Report is null, simply call
220 -- Prj.Err.Error_Msg. Otherwise, disregard Flag_Location and use
223 procedure Find_Sources
224 (Project
: Project_Id
;
225 Data
: in out Project_Data
;
226 For_Language
: Language_Index
;
227 Follow_Links
: Boolean := False);
228 -- Find all the sources in all of the source directories of a project for
229 -- a specified language.
231 procedure Free_Ada_Naming_Exceptions
;
232 -- Free the internal hash tables used for checking naming exceptions
234 procedure Get_Directories
235 (Project
: Project_Id
;
236 Data
: in out Project_Data
);
237 -- Get the object directory, the exec directory and the source directories
240 procedure Get_Mains
(Project
: Project_Id
; Data
: in out Project_Data
);
241 -- Get the mains of a project from attribute Main, if it exists, and put
242 -- them in the project data.
244 procedure Get_Sources_From_File
246 Location
: Source_Ptr
;
247 Project
: Project_Id
);
248 -- Get the list of sources from a text file and put them in hash table
252 (Canonical_File_Name
: Name_Id
;
253 Naming
: Naming_Data
;
254 Exception_Id
: out Ada_Naming_Exception_Id
;
255 Unit_Name
: out Name_Id
;
256 Unit_Kind
: out Spec_Or_Body
;
257 Needs_Pragma
: out Boolean);
258 -- Find out, from a file name, the unit name, the unit kind and if a
259 -- specific SFN pragma is needed. If the file name corresponds to no
260 -- unit, then Unit_Name will be No_Name. If the file is a multi-unit source
261 -- or an exception to the naming scheme, then Exception_Id is set to
262 -- the unit or units that the source contains.
264 function Is_Illegal_Suffix
266 Dot_Replacement_Is_A_Single_Dot
: Boolean) return Boolean;
267 -- Returns True if the string Suffix cannot be used as
268 -- a spec suffix, a body suffix or a separate suffix.
270 procedure Locate_Directory
274 Display
: out Name_Id
);
275 -- Locate a directory (returns No_Name for Dir and Display if directory
276 -- does not exist). Name is the directory name. Parent is the root
277 -- directory, if Name is a relative path name. Dir is the canonical case
278 -- path name of the directory, Display is the directory path name for
281 procedure Look_For_Sources
282 (Project
: Project_Id
;
283 Data
: in out Project_Data
;
284 Follow_Links
: Boolean);
285 -- Comment required ???
287 function Path_Name_Of
288 (File_Name
: Name_Id
;
289 Directory
: Name_Id
) return String;
290 -- Returns the path name of a (non project) file.
291 -- Returns an empty string if file cannot be found.
293 procedure Prepare_Ada_Naming_Exceptions
294 (List
: Array_Element_Id
;
295 Kind
: Spec_Or_Body
);
296 -- Prepare the internal hash tables used for checking naming exceptions
297 -- for Ada. Insert all elements of List in the tables.
299 function Project_Extends
300 (Extending
: Project_Id
;
301 Extended
: Project_Id
) return Boolean;
302 -- Returns True if Extending is extending Extended either directly or
305 procedure Record_Ada_Source
306 (File_Name
: Name_Id
;
308 Project
: Project_Id
;
309 Data
: in out Project_Data
;
310 Location
: Source_Ptr
;
311 Current_Source
: in out String_List_Id
;
312 Source_Recorded
: in out Boolean;
313 Follow_Links
: Boolean);
314 -- Put a unit in the list of units of a project, if the file name
315 -- corresponds to a valid unit name.
317 procedure Record_Other_Sources
318 (Project
: Project_Id
;
319 Data
: in out Project_Data
;
320 Language
: Language_Index
;
321 Naming_Exceptions
: Boolean);
322 -- Record the sources of a language in a project.
323 -- When Naming_Exceptions is True, mark the found sources as such, to
324 -- later remove those that are not named in a list of sources.
326 procedure Show_Source_Dirs
(Project
: Project_Id
);
327 -- List all the source directories of a project
330 (Language
: Language_Index
;
331 Naming
: Naming_Data
) return Name_Id
;
332 -- Get the suffix for the source of a language from a package naming.
333 -- If not specified, return the default for the language.
335 procedure Warn_If_Not_Sources
336 (Project
: Project_Id
;
337 Conventions
: Array_Element_Id
;
339 Extending
: Boolean);
340 -- Check that individual naming conventions apply to immediate
341 -- sources of the project; if not, issue a warning.
347 function ALI_File_Name
(Source
: String) return String is
349 -- If the source name has an extension, then replace it with
352 for Index
in reverse Source
'First + 1 .. Source
'Last loop
353 if Source
(Index
) = '.' then
354 return Source
(Source
'First .. Index
- 1) & ALI_Suffix
;
358 -- If there is no dot, or if it is the first character, just add the
361 return Source
& ALI_Suffix
;
369 (Project
: Project_Id
;
370 Report_Error
: Put_Line_Access
;
371 Follow_Links
: Boolean)
373 Data
: Project_Data
:= Projects
.Table
(Project
);
375 Extending
: Boolean := False;
378 Error_Report
:= Report_Error
;
380 Recursive_Dirs
.Reset
;
382 -- Object, exec and source directories
384 Get_Directories
(Project
, Data
);
386 -- Get the programming languages
388 Check_Programming_Languages
(Data
);
390 -- Library attributes
392 Check_Library_Attributes
(Project
, Data
);
394 Check_If_Externally_Built
(Project
, Data
);
396 if Current_Verbosity
= High
then
397 Show_Source_Dirs
(Project
);
400 Check_Package_Naming
(Project
, Data
);
402 Extending
:= Data
.Extends
/= No_Project
;
404 Check_Naming_Scheme
(Data
, Project
);
406 Prepare_Ada_Naming_Exceptions
(Data
.Naming
.Bodies
, Body_Part
);
407 Prepare_Ada_Naming_Exceptions
(Data
.Naming
.Specs
, Specification
);
411 if Data
.Source_Dirs
/= Nil_String
then
412 Look_For_Sources
(Project
, Data
, Follow_Links
);
415 if Data
.Ada_Sources_Present
then
417 -- Check that all individual naming conventions apply to sources of
418 -- this project file.
421 (Project
, Data
.Naming
.Bodies
,
423 Extending
=> Extending
);
425 (Project
, Data
.Naming
.Specs
,
427 Extending
=> Extending
);
431 -- If it is a library project file, check if it is a standalone library
434 Check_Stand_Alone_Library
(Project
, Data
, Extending
);
437 -- Put the list of Mains, if any, in the project data
439 Get_Mains
(Project
, Data
);
441 -- Update the project data in the Projects table
443 Projects
.Table
(Project
) := Data
;
445 Free_Ada_Naming_Exceptions
;
452 procedure Check_Ada_Name
456 The_Name
: String := Name
;
458 Need_Letter
: Boolean := True;
459 Last_Underscore
: Boolean := False;
460 OK
: Boolean := The_Name
'Length > 0;
465 Name_Len
:= The_Name
'Length;
466 Name_Buffer
(1 .. Name_Len
) := The_Name
;
467 Real_Name
:= Name_Find
;
469 -- Check first that the given name is not an Ada reserved word
471 if Get_Name_Table_Byte
(Real_Name
) /= 0
472 and then Real_Name
/= Name_Project
473 and then Real_Name
/= Name_Extends
474 and then Real_Name
/= Name_External
478 if Current_Verbosity
= High
then
479 Write_Str
(The_Name
);
480 Write_Line
(" is an Ada reserved word.");
486 for Index
in The_Name
'Range loop
489 -- We need a letter (at the beginning, and following a dot),
490 -- but we don't have one.
492 if Is_Letter
(The_Name
(Index
)) then
493 Need_Letter
:= False;
498 if Current_Verbosity
= High
then
499 Write_Int
(Types
.Int
(Index
));
501 Write_Char
(The_Name
(Index
));
502 Write_Line
("' is not a letter.");
508 elsif Last_Underscore
509 and then (The_Name
(Index
) = '_' or else The_Name
(Index
) = '.')
511 -- Two underscores are illegal, and a dot cannot follow
516 if Current_Verbosity
= High
then
517 Write_Int
(Types
.Int
(Index
));
519 Write_Char
(The_Name
(Index
));
520 Write_Line
("' is illegal here.");
525 elsif The_Name
(Index
) = '.' then
527 -- We need a letter after a dot
531 elsif The_Name
(Index
) = '_' then
532 Last_Underscore
:= True;
535 -- We need an letter or a digit
537 Last_Underscore
:= False;
539 if not Is_Alphanumeric
(The_Name
(Index
)) then
542 if Current_Verbosity
= High
then
543 Write_Int
(Types
.Int
(Index
));
545 Write_Char
(The_Name
(Index
));
546 Write_Line
("' is not alphanumeric.");
554 -- Cannot end with an underscore or a dot
556 OK
:= OK
and then not Need_Letter
and then not Last_Underscore
;
562 -- Signal a problem with No_Name
568 --------------------------------------
569 -- Check_Ada_Naming_Scheme_Validity --
570 --------------------------------------
572 procedure Check_Ada_Naming_Scheme_Validity
573 (Project
: Project_Id
;
574 Naming
: Naming_Data
)
577 -- Only check if we are not using the standard naming scheme
579 if Naming
/= Standard_Naming_Data
then
581 Dot_Replacement
: constant String :=
583 (Naming
.Dot_Replacement
);
585 Spec_Suffix
: constant String :=
587 (Naming
.Ada_Spec_Suffix
);
589 Body_Suffix
: constant String :=
591 (Naming
.Ada_Body_Suffix
);
593 Separate_Suffix
: constant String :=
595 (Naming
.Separate_Suffix
);
598 -- Dot_Replacement cannot
600 -- - start or end with an alphanumeric
602 -- - start with an '_' followed by an alphanumeric
603 -- - contain a '.' except if it is "."
605 if Dot_Replacement
'Length = 0
606 or else Is_Alphanumeric
607 (Dot_Replacement
(Dot_Replacement
'First))
608 or else Is_Alphanumeric
609 (Dot_Replacement
(Dot_Replacement
'Last))
610 or else (Dot_Replacement
(Dot_Replacement
'First) = '_'
612 (Dot_Replacement
'Length = 1
615 (Dot_Replacement
(Dot_Replacement
'First + 1))))
616 or else (Dot_Replacement
'Length > 1
618 Index
(Source
=> Dot_Replacement
,
619 Pattern
=> ".") /= 0)
623 '"' & Dot_Replacement
&
624 """ is illegal for Dot_Replacement.",
625 Naming
.Dot_Repl_Loc
);
632 (Spec_Suffix
, Dot_Replacement
= ".")
634 Err_Vars
.Error_Msg_Name_1
:= Naming
.Ada_Spec_Suffix
;
637 "{ is illegal for Spec_Suffix",
638 Naming
.Spec_Suffix_Loc
);
642 (Body_Suffix
, Dot_Replacement
= ".")
644 Err_Vars
.Error_Msg_Name_1
:= Naming
.Ada_Body_Suffix
;
647 "{ is illegal for Body_Suffix",
648 Naming
.Body_Suffix_Loc
);
651 if Body_Suffix
/= Separate_Suffix
then
653 (Separate_Suffix
, Dot_Replacement
= ".")
655 Err_Vars
.Error_Msg_Name_1
:= Naming
.Separate_Suffix
;
658 "{ is illegal for Separate_Suffix",
659 Naming
.Sep_Suffix_Loc
);
663 -- Spec_Suffix cannot have the same termination as
664 -- Body_Suffix or Separate_Suffix
666 if Spec_Suffix
'Length <= Body_Suffix
'Length
668 Body_Suffix
(Body_Suffix
'Last -
669 Spec_Suffix
'Length + 1 ..
670 Body_Suffix
'Last) = Spec_Suffix
676 """) cannot end with" &
678 Spec_Suffix
& """).",
679 Naming
.Body_Suffix_Loc
);
682 if Body_Suffix
/= Separate_Suffix
683 and then Spec_Suffix
'Length <= Separate_Suffix
'Length
686 (Separate_Suffix
'Last - Spec_Suffix
'Length + 1
688 Separate_Suffix
'Last) = Spec_Suffix
692 "Separate_Suffix (""" &
694 """) cannot end with" &
696 Spec_Suffix
& """).",
697 Naming
.Sep_Suffix_Loc
);
701 end Check_Ada_Naming_Scheme_Validity
;
703 ----------------------
704 -- Check_For_Source --
705 ----------------------
707 procedure Check_For_Source
708 (File_Name
: Name_Id
;
710 Project
: Project_Id
;
711 Data
: in out Project_Data
;
712 Location
: Source_Ptr
;
713 Language
: Language_Index
;
715 Naming_Exception
: Boolean)
717 Name
: String := Get_Name_String
(File_Name
);
718 Real_Location
: Source_Ptr
:= Location
;
721 Canonical_Case_File_Name
(Name
);
723 -- A file is a source of a language if Naming_Exception is True (case
724 -- of naming exceptions) or if its file name ends with the suffix.
726 if Naming_Exception
or else
727 (Name
'Length > Suffix
'Length and then
728 Name
(Name
'Last - Suffix
'Length + 1 .. Name
'Last) = Suffix
)
730 if Real_Location
= No_Location
then
731 Real_Location
:= Data
.Location
;
735 Path
: String := Get_Name_String
(Path_Name
);
738 -- The path name id (in canonical case)
741 -- The file name id (in canonical case)
744 -- The object file name
746 Obj_Path_Id
: Name_Id
;
747 -- The object path name
750 -- The dependency file name
752 Dep_Path_Id
: Name_Id
;
753 -- The dependency path name
755 Dot_Pos
: Natural := 0;
756 -- Position of the last dot in Name
758 Source
: Other_Source
;
759 Source_Id
: Other_Source_Id
:= Data
.First_Other_Source
;
762 Canonical_Case_File_Name
(Path
);
764 -- Get the file name id
766 Name_Len
:= Name
'Length;
767 Name_Buffer
(1 .. Name_Len
) := Name
;
768 File_Id
:= Name_Find
;
770 -- Get the path name id
772 Name_Len
:= Path
'Length;
773 Name_Buffer
(1 .. Name_Len
) := Path
;
774 Path_Id
:= Name_Find
;
776 -- Find the position of the last dot
778 for J
in reverse Name
'Range loop
779 if Name
(J
) = '.' then
785 if Dot_Pos
<= Name
'First then
786 Dot_Pos
:= Name
'Last + 1;
789 -- Compute the object file name
791 Get_Name_String
(File_Id
);
792 Name_Len
:= Dot_Pos
- Name
'First;
794 for J
in Object_Suffix
'Range loop
795 Name_Len
:= Name_Len
+ 1;
796 Name_Buffer
(Name_Len
) := Object_Suffix
(J
);
801 -- Compute the object path name
803 Get_Name_String
(Data
.Object_Directory
);
805 if Name_Buffer
(Name_Len
) /= Directory_Separator
and then
806 Name_Buffer
(Name_Len
) /= '/'
808 Name_Len
:= Name_Len
+ 1;
809 Name_Buffer
(Name_Len
) := Directory_Separator
;
812 Add_Str_To_Name_Buffer
(Get_Name_String
(Obj_Id
));
813 Obj_Path_Id
:= Name_Find
;
815 -- Compute the dependency file name
817 Get_Name_String
(File_Id
);
818 Name_Len
:= Dot_Pos
- Name
'First + 1;
819 Name_Buffer
(Name_Len
) := '.';
820 Name_Len
:= Name_Len
+ 1;
821 Name_Buffer
(Name_Len
) := 'd';
824 -- Compute the dependency path name
826 Get_Name_String
(Data
.Object_Directory
);
828 if Name_Buffer
(Name_Len
) /= Directory_Separator
and then
829 Name_Buffer
(Name_Len
) /= '/'
831 Name_Len
:= Name_Len
+ 1;
832 Name_Buffer
(Name_Len
) := Directory_Separator
;
835 Add_Str_To_Name_Buffer
(Get_Name_String
(Dep_Id
));
836 Dep_Path_Id
:= Name_Find
;
838 -- Check if source is already in the list of source for this
839 -- project: it may have already been specified as a naming
840 -- exception for the same language or an other language, or
841 -- they may be two identical file names in different source
844 while Source_Id
/= No_Other_Source
loop
845 Source
:= Other_Sources
.Table
(Source_Id
);
846 Source_Id
:= Source
.Next
;
848 if Source
.File_Name
= File_Id
then
850 -- Two sources of different languages cannot have the same
853 if Source
.Language
/= Language
then
854 Error_Msg_Name_1
:= File_Name
;
857 "{ cannot be a source of several languages",
861 -- No problem if a file has already been specified as
862 -- a naming exception of this language.
864 elsif Source
.Path_Name
= Path_Id
then
866 -- Reset the naming exception flag, if this is not a
869 if not Naming_Exception
then
870 Other_Sources
.Table
(Source_Id
).Naming_Exception
:=
876 -- There are several files with the same names, but the
877 -- order of the source directories is known (no /**):
878 -- only the first one encountered is kept, the other ones
881 elsif Data
.Known_Order_Of_Source_Dirs
then
884 -- But it is an error if the order of the source directories
888 Error_Msg_Name_1
:= File_Name
;
891 "{ is found in several source directories",
896 -- Two sources with different file names cannot have the same
899 elsif Source
.Object_Name
= Obj_Id
then
900 Error_Msg_Name_1
:= File_Id
;
901 Error_Msg_Name_2
:= Source
.File_Name
;
902 Error_Msg_Name_3
:= Obj_Id
;
905 "{ and { have the same object file {",
911 if Current_Verbosity
= High
then
912 Write_Str
(" found ");
913 Display_Language_Name
(Language
);
914 Write_Str
(" source """);
915 Write_Str
(Get_Name_String
(File_Name
));
917 Write_Str
(" object path = ");
918 Write_Line
(Get_Name_String
(Obj_Path_Id
));
921 -- Create the Other_Source record
924 (Language
=> Language
,
925 File_Name
=> File_Id
,
926 Path_Name
=> Path_Id
,
927 Source_TS
=> File_Stamp
(Path_Id
),
928 Object_Name
=> Obj_Id
,
929 Object_Path
=> Obj_Path_Id
,
930 Object_TS
=> File_Stamp
(Obj_Path_Id
),
932 Dep_Path
=> Dep_Path_Id
,
933 Dep_TS
=> File_Stamp
(Dep_Path_Id
),
934 Naming_Exception
=> Naming_Exception
,
935 Next
=> No_Other_Source
);
937 -- And add it to the Other_Sources table
939 Other_Sources
.Increment_Last
;
940 Other_Sources
.Table
(Other_Sources
.Last
) := Source
;
942 -- There are sources of languages other than Ada in this project
944 Data
.Other_Sources_Present
:= True;
946 -- And there are sources of this language in this project
948 Set
(Language
, True, Data
);
950 -- Add this source to the list of sources of languages other than
951 -- Ada of the project.
953 if Data
.First_Other_Source
= No_Other_Source
then
954 Data
.First_Other_Source
:= Other_Sources
.Last
;
957 Other_Sources
.Table
(Data
.Last_Other_Source
).Next
:=
961 Data
.Last_Other_Source
:= Other_Sources
.Last
;
964 end Check_For_Source
;
966 -------------------------------
967 -- Check_If_Externally_Built --
968 -------------------------------
970 procedure Check_If_Externally_Built
971 (Project
: Project_Id
; Data
: in out Project_Data
)
973 Externally_Built
: constant Variable_Value
:=
975 (Name_Externally_Built
, Data
.Decl
.Attributes
);
978 if not Externally_Built
.Default
then
979 Get_Name_String
(Externally_Built
.Value
);
980 To_Lower
(Name_Buffer
(1 .. Name_Len
));
982 if Name_Buffer
(1 .. Name_Len
) = "true" then
983 Data
.Externally_Built
:= True;
985 elsif Name_Buffer
(1 .. Name_Len
) /= "false" then
987 "Externally_Built may only be true or false",
988 Externally_Built
.Location
);
992 if Current_Verbosity
= High
then
993 Write_Str
("Project is ");
995 if not Data
.Externally_Built
then
999 Write_Line
("externally built.");
1001 end Check_If_Externally_Built
;
1003 -----------------------------
1004 -- Check_Naming_Scheme --
1005 -----------------------------
1007 procedure Check_Naming_Scheme
1008 (Data
: in out Project_Data
;
1009 Project
: Project_Id
)
1011 Naming_Id
: constant Package_Id
:=
1012 Util
.Value_Of
(Name_Naming
, Data
.Decl
.Packages
);
1014 Naming
: Package_Element
;
1016 procedure Check_Unit_Names
(List
: Array_Element_Id
);
1017 -- Check that a list of unit names contains only valid names
1019 ----------------------
1020 -- Check_Unit_Names --
1021 ----------------------
1023 procedure Check_Unit_Names
(List
: Array_Element_Id
) is
1024 Current
: Array_Element_Id
:= List
;
1025 Element
: Array_Element
;
1026 Unit_Name
: Name_Id
;
1029 -- Loop through elements of the string list
1031 while Current
/= No_Array_Element
loop
1032 Element
:= Array_Elements
.Table
(Current
);
1034 -- Put file name in canonical case
1036 Get_Name_String
(Element
.Value
.Value
);
1037 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
1038 Element
.Value
.Value
:= Name_Find
;
1040 -- Check that it contains a valid unit name
1042 Get_Name_String
(Element
.Index
);
1043 Check_Ada_Name
(Name_Buffer
(1 .. Name_Len
), Unit_Name
);
1045 if Unit_Name
= No_Name
then
1046 Err_Vars
.Error_Msg_Name_1
:= Element
.Index
;
1049 "{ is not a valid unit name.",
1050 Element
.Value
.Location
);
1053 if Current_Verbosity
= High
then
1054 Write_Str
(" Unit (""");
1055 Write_Str
(Get_Name_String
(Unit_Name
));
1059 Element
.Index
:= Unit_Name
;
1060 Array_Elements
.Table
(Current
) := Element
;
1063 Current
:= Element
.Next
;
1065 end Check_Unit_Names
;
1067 -- Start of processing for Check_Naming_Scheme
1070 -- If there is a package Naming, we will put in Data.Naming what is in
1071 -- this package Naming.
1073 if Naming_Id
/= No_Package
then
1074 Naming
:= Packages
.Table
(Naming_Id
);
1076 if Current_Verbosity
= High
then
1077 Write_Line
("Checking ""Naming"" for Ada.");
1081 Bodies
: constant Array_Element_Id
:=
1082 Util
.Value_Of
(Name_Body
, Naming
.Decl
.Arrays
);
1084 Specs
: constant Array_Element_Id
:=
1085 Util
.Value_Of
(Name_Spec
, Naming
.Decl
.Arrays
);
1088 if Bodies
/= No_Array_Element
then
1090 -- We have elements in the array Body_Part
1092 if Current_Verbosity
= High
then
1093 Write_Line
("Found Bodies.");
1096 Data
.Naming
.Bodies
:= Bodies
;
1097 Check_Unit_Names
(Bodies
);
1100 if Current_Verbosity
= High
then
1101 Write_Line
("No Bodies.");
1105 if Specs
/= No_Array_Element
then
1107 -- We have elements in the array Specs
1109 if Current_Verbosity
= High
then
1110 Write_Line
("Found Specs.");
1113 Data
.Naming
.Specs
:= Specs
;
1114 Check_Unit_Names
(Specs
);
1117 if Current_Verbosity
= High
then
1118 Write_Line
("No Specs.");
1123 -- We are now checking if variables Dot_Replacement, Casing,
1124 -- Spec_Suffix, Body_Suffix and/or Separate_Suffix
1127 -- For each variable, if it does not exist, we do nothing,
1128 -- because we already have the default.
1130 -- Check Dot_Replacement
1133 Dot_Replacement
: constant Variable_Value
:=
1135 (Name_Dot_Replacement
,
1136 Naming
.Decl
.Attributes
);
1139 pragma Assert
(Dot_Replacement
.Kind
= Single
,
1140 "Dot_Replacement is not a single string");
1142 if not Dot_Replacement
.Default
then
1143 Get_Name_String
(Dot_Replacement
.Value
);
1145 if Name_Len
= 0 then
1148 "Dot_Replacement cannot be empty",
1149 Dot_Replacement
.Location
);
1152 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
1153 Data
.Naming
.Dot_Replacement
:= Name_Find
;
1154 Data
.Naming
.Dot_Repl_Loc
:= Dot_Replacement
.Location
;
1159 if Current_Verbosity
= High
then
1160 Write_Str
(" Dot_Replacement = """);
1161 Write_Str
(Get_Name_String
(Data
.Naming
.Dot_Replacement
));
1169 Casing_String
: constant Variable_Value
:=
1171 (Name_Casing
, Naming
.Decl
.Attributes
);
1174 pragma Assert
(Casing_String
.Kind
= Single
,
1175 "Casing is not a single string");
1177 if not Casing_String
.Default
then
1179 Casing_Image
: constant String :=
1180 Get_Name_String
(Casing_String
.Value
);
1183 Casing_Value
: constant Casing_Type
:=
1184 Value
(Casing_Image
);
1186 -- Ignore Casing on platforms where file names are
1187 -- case-insensitive.
1189 if not File_Names_Case_Sensitive
then
1190 Data
.Naming
.Casing
:= All_Lower_Case
;
1193 Data
.Naming
.Casing
:= Casing_Value
;
1198 when Constraint_Error
=>
1199 if Casing_Image
'Length = 0 then
1202 "Casing cannot be an empty string",
1203 Casing_String
.Location
);
1206 Name_Len
:= Casing_Image
'Length;
1207 Name_Buffer
(1 .. Name_Len
) := Casing_Image
;
1208 Err_Vars
.Error_Msg_Name_1
:= Name_Find
;
1211 "{ is not a correct Casing",
1212 Casing_String
.Location
);
1218 if Current_Verbosity
= High
then
1219 Write_Str
(" Casing = ");
1220 Write_Str
(Image
(Data
.Naming
.Casing
));
1225 -- Check Spec_Suffix
1228 Ada_Spec_Suffix
: constant Variable_Value
:=
1232 In_Array
=> Data
.Naming
.Spec_Suffix
);
1235 if Ada_Spec_Suffix
.Kind
= Single
1236 and then Get_Name_String
(Ada_Spec_Suffix
.Value
) /= ""
1238 Get_Name_String
(Ada_Spec_Suffix
.Value
);
1239 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
1240 Data
.Naming
.Ada_Spec_Suffix
:= Name_Find
;
1241 Data
.Naming
.Spec_Suffix_Loc
:= Ada_Spec_Suffix
.Location
;
1244 Data
.Naming
.Ada_Spec_Suffix
:= Default_Ada_Spec_Suffix
;
1248 if Current_Verbosity
= High
then
1249 Write_Str
(" Spec_Suffix = """);
1250 Write_Str
(Get_Name_String
(Data
.Naming
.Ada_Spec_Suffix
));
1255 -- Check Body_Suffix
1258 Ada_Body_Suffix
: constant Variable_Value
:=
1262 In_Array
=> Data
.Naming
.Body_Suffix
);
1265 if Ada_Body_Suffix
.Kind
= Single
1266 and then Get_Name_String
(Ada_Body_Suffix
.Value
) /= ""
1268 Get_Name_String
(Ada_Body_Suffix
.Value
);
1269 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
1270 Data
.Naming
.Ada_Body_Suffix
:= Name_Find
;
1271 Data
.Naming
.Body_Suffix_Loc
:= Ada_Body_Suffix
.Location
;
1274 Data
.Naming
.Ada_Body_Suffix
:= Default_Ada_Body_Suffix
;
1278 if Current_Verbosity
= High
then
1279 Write_Str
(" Body_Suffix = """);
1280 Write_Str
(Get_Name_String
(Data
.Naming
.Ada_Body_Suffix
));
1285 -- Check Separate_Suffix
1288 Ada_Sep_Suffix
: constant Variable_Value
:=
1290 (Variable_Name
=> Name_Separate_Suffix
,
1291 In_Variables
=> Naming
.Decl
.Attributes
);
1294 if Ada_Sep_Suffix
.Default
then
1295 Data
.Naming
.Separate_Suffix
:=
1296 Data
.Naming
.Ada_Body_Suffix
;
1299 Get_Name_String
(Ada_Sep_Suffix
.Value
);
1301 if Name_Len
= 0 then
1304 "Separate_Suffix cannot be empty",
1305 Ada_Sep_Suffix
.Location
);
1308 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
1309 Data
.Naming
.Separate_Suffix
:= Name_Find
;
1310 Data
.Naming
.Sep_Suffix_Loc
:= Ada_Sep_Suffix
.Location
;
1315 if Current_Verbosity
= High
then
1316 Write_Str
(" Separate_Suffix = """);
1317 Write_Str
(Get_Name_String
(Data
.Naming
.Separate_Suffix
));
1322 -- Check if Data.Naming is valid
1324 Check_Ada_Naming_Scheme_Validity
(Project
, Data
.Naming
);
1327 Data
.Naming
.Ada_Spec_Suffix
:= Default_Ada_Spec_Suffix
;
1328 Data
.Naming
.Ada_Body_Suffix
:= Default_Ada_Body_Suffix
;
1329 Data
.Naming
.Separate_Suffix
:= Default_Ada_Body_Suffix
;
1331 end Check_Naming_Scheme
;
1333 ------------------------------
1334 -- Check_Library_Attributes --
1335 ------------------------------
1337 procedure Check_Library_Attributes
1338 (Project
: Project_Id
; Data
: in out Project_Data
)
1340 Attributes
: constant Prj
.Variable_Id
:= Data
.Decl
.Attributes
;
1342 Lib_Dir
: constant Prj
.Variable_Value
:=
1343 Prj
.Util
.Value_Of
(Snames
.Name_Library_Dir
, Attributes
);
1345 Lib_Name
: constant Prj
.Variable_Value
:=
1346 Prj
.Util
.Value_Of
(Snames
.Name_Library_Name
, Attributes
);
1348 Lib_Version
: constant Prj
.Variable_Value
:=
1350 (Snames
.Name_Library_Version
, Attributes
);
1352 The_Lib_Kind
: constant Prj
.Variable_Value
:=
1354 (Snames
.Name_Library_Kind
, Attributes
);
1357 -- Special case of extending project
1359 if Data
.Extends
/= No_Project
then
1361 Extended_Data
: constant Project_Data
:=
1362 Projects
.Table
(Data
.Extends
);
1365 -- If the project extended is a library project, we inherit
1366 -- the library name, if it is not redefined; we check that
1367 -- the library directory is specified; and we reset the
1368 -- library flag for the extended project.
1370 if Extended_Data
.Library
then
1371 if Lib_Name
.Default
then
1372 Data
.Library_Name
:= Extended_Data
.Library_Name
;
1375 if Lib_Dir
.Default
then
1376 if not Data
.Virtual
then
1379 "a project extending a library project must " &
1380 "specify an attribute Library_Dir",
1385 Projects
.Table
(Data
.Extends
).Library
:= False;
1390 pragma Assert
(Lib_Dir
.Kind
= Single
);
1392 if Lib_Dir
.Value
= Empty_String
then
1393 if Current_Verbosity
= High
then
1394 Write_Line
("No library directory");
1398 -- Find path name, check that it is a directory
1401 (Lib_Dir
.Value
, Data
.Display_Directory
,
1402 Data
.Library_Dir
, Data
.Display_Library_Dir
);
1404 if Data
.Library_Dir
= No_Name
then
1406 -- Get the absolute name of the library directory that
1407 -- does not exist, to report an error.
1410 Dir_Name
: constant String := Get_Name_String
(Lib_Dir
.Value
);
1413 if Is_Absolute_Path
(Dir_Name
) then
1414 Err_Vars
.Error_Msg_Name_1
:= Lib_Dir
.Value
;
1417 Get_Name_String
(Data
.Display_Directory
);
1419 if Name_Buffer
(Name_Len
) /= Directory_Separator
then
1420 Name_Len
:= Name_Len
+ 1;
1421 Name_Buffer
(Name_Len
) := Directory_Separator
;
1425 (Name_Len
+ 1 .. Name_Len
+ Dir_Name
'Length) :=
1427 Name_Len
:= Name_Len
+ Dir_Name
'Length;
1428 Err_Vars
.Error_Msg_Name_1
:= Name_Find
;
1435 "library directory { does not exist",
1441 elsif Data
.Library_Dir
= Data
.Object_Directory
then
1444 "library directory cannot be the same " &
1445 "as object directory",
1447 Data
.Library_Dir
:= No_Name
;
1448 Data
.Display_Library_Dir
:= No_Name
;
1453 if Current_Verbosity
= High
then
1454 Write_Str
("Library directory =""");
1455 Write_Str
(Get_Name_String
(Data
.Display_Library_Dir
));
1461 pragma Assert
(Lib_Name
.Kind
= Single
);
1463 if Lib_Name
.Value
= Empty_String
then
1464 if Current_Verbosity
= High
1465 and then Data
.Library_Name
= No_Name
1467 Write_Line
("No library name");
1471 -- There is no restriction on the syntax of library names
1473 Data
.Library_Name
:= Lib_Name
.Value
;
1476 if Data
.Library_Name
/= No_Name
1477 and then Current_Verbosity
= High
1479 Write_Str
("Library name = """);
1480 Write_Str
(Get_Name_String
(Data
.Library_Name
));
1485 Data
.Library_Dir
/= No_Name
1487 Data
.Library_Name
/= No_Name
;
1489 if Data
.Library
then
1490 if MLib
.Tgt
.Support_For_Libraries
= MLib
.Tgt
.None
then
1493 "?libraries are not supported on this platform",
1495 Data
.Library
:= False;
1498 pragma Assert
(Lib_Version
.Kind
= Single
);
1500 if Lib_Version
.Value
= Empty_String
then
1501 if Current_Verbosity
= High
then
1502 Write_Line
("No library version specified");
1506 Data
.Lib_Internal_Name
:= Lib_Version
.Value
;
1509 pragma Assert
(The_Lib_Kind
.Kind
= Single
);
1511 if The_Lib_Kind
.Value
= Empty_String
then
1512 if Current_Verbosity
= High
then
1513 Write_Line
("No library kind specified");
1517 Get_Name_String
(The_Lib_Kind
.Value
);
1520 Kind_Name
: constant String :=
1521 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1523 OK
: Boolean := True;
1526 if Kind_Name
= "static" then
1527 Data
.Library_Kind
:= Static
;
1529 elsif Kind_Name
= "dynamic" then
1530 Data
.Library_Kind
:= Dynamic
;
1532 elsif Kind_Name
= "relocatable" then
1533 Data
.Library_Kind
:= Relocatable
;
1538 "illegal value for Library_Kind",
1539 The_Lib_Kind
.Location
);
1543 if Current_Verbosity
= High
and then OK
then
1544 Write_Str
("Library kind = ");
1545 Write_Line
(Kind_Name
);
1548 if Data
.Library_Kind
/= Static
and then
1549 MLib
.Tgt
.Support_For_Libraries
= MLib
.Tgt
.Static_Only
1553 "only static libraries are supported " &
1555 The_Lib_Kind
.Location
);
1556 Data
.Library
:= False;
1561 if Data
.Library
and then Current_Verbosity
= High
then
1562 Write_Line
("This is a library project file");
1567 end Check_Library_Attributes
;
1569 --------------------------
1570 -- Check_Package_Naming --
1571 --------------------------
1573 procedure Check_Package_Naming
1574 (Project
: Project_Id
; Data
: in out Project_Data
)
1576 Naming_Id
: constant Package_Id
:=
1577 Util
.Value_Of
(Name_Naming
, Data
.Decl
.Packages
);
1579 Naming
: Package_Element
;
1582 -- If there is a package Naming, we will put in Data.Naming
1583 -- what is in this package Naming.
1585 if Naming_Id
/= No_Package
then
1586 Naming
:= Packages
.Table
(Naming_Id
);
1588 if Current_Verbosity
= High
then
1589 Write_Line
("Checking ""Naming"".");
1592 -- Check Spec_Suffix
1595 Spec_Suffixs
: Array_Element_Id
:=
1598 Naming
.Decl
.Arrays
);
1600 Suffix
: Array_Element_Id
;
1601 Element
: Array_Element
;
1602 Suffix2
: Array_Element_Id
;
1605 -- If some suffixs have been specified, we make sure that
1606 -- for each language for which a default suffix has been
1607 -- specified, there is a suffix specified, either the one
1608 -- in the project file or if there were none, the default.
1610 if Spec_Suffixs
/= No_Array_Element
then
1611 Suffix
:= Data
.Naming
.Spec_Suffix
;
1613 while Suffix
/= No_Array_Element
loop
1614 Element
:= Array_Elements
.Table
(Suffix
);
1615 Suffix2
:= Spec_Suffixs
;
1617 while Suffix2
/= No_Array_Element
loop
1618 exit when Array_Elements
.Table
(Suffix2
).Index
=
1620 Suffix2
:= Array_Elements
.Table
(Suffix2
).Next
;
1623 -- There is a registered default suffix, but no
1624 -- suffix specified in the project file.
1625 -- Add the default to the array.
1627 if Suffix2
= No_Array_Element
then
1628 Array_Elements
.Increment_Last
;
1629 Array_Elements
.Table
(Array_Elements
.Last
) :=
1630 (Index
=> Element
.Index
,
1631 Src_Index
=> Element
.Src_Index
,
1632 Index_Case_Sensitive
=> False,
1633 Value
=> Element
.Value
,
1634 Next
=> Spec_Suffixs
);
1635 Spec_Suffixs
:= Array_Elements
.Last
;
1638 Suffix
:= Element
.Next
;
1641 -- Put the resulting array as the specification suffixs
1643 Data
.Naming
.Spec_Suffix
:= Spec_Suffixs
;
1648 Current
: Array_Element_Id
:= Data
.Naming
.Spec_Suffix
;
1649 Element
: Array_Element
;
1652 while Current
/= No_Array_Element
loop
1653 Element
:= Array_Elements
.Table
(Current
);
1654 Get_Name_String
(Element
.Value
.Value
);
1656 if Name_Len
= 0 then
1659 "Spec_Suffix cannot be empty",
1660 Element
.Value
.Location
);
1663 Array_Elements
.Table
(Current
) := Element
;
1664 Current
:= Element
.Next
;
1668 -- Check Body_Suffix
1671 Impl_Suffixs
: Array_Element_Id
:=
1674 Naming
.Decl
.Arrays
);
1676 Suffix
: Array_Element_Id
;
1677 Element
: Array_Element
;
1678 Suffix2
: Array_Element_Id
;
1681 -- If some suffixes have been specified, we make sure that
1682 -- for each language for which a default suffix has been
1683 -- specified, there is a suffix specified, either the one
1684 -- in the project file or if there were noe, the default.
1686 if Impl_Suffixs
/= No_Array_Element
then
1687 Suffix
:= Data
.Naming
.Body_Suffix
;
1689 while Suffix
/= No_Array_Element
loop
1690 Element
:= Array_Elements
.Table
(Suffix
);
1691 Suffix2
:= Impl_Suffixs
;
1693 while Suffix2
/= No_Array_Element
loop
1694 exit when Array_Elements
.Table
(Suffix2
).Index
=
1696 Suffix2
:= Array_Elements
.Table
(Suffix2
).Next
;
1699 -- There is a registered default suffix, but no suffix was
1700 -- specified in the project file. Add the default to the
1703 if Suffix2
= No_Array_Element
then
1704 Array_Elements
.Increment_Last
;
1705 Array_Elements
.Table
(Array_Elements
.Last
) :=
1706 (Index
=> Element
.Index
,
1707 Src_Index
=> Element
.Src_Index
,
1708 Index_Case_Sensitive
=> False,
1709 Value
=> Element
.Value
,
1710 Next
=> Impl_Suffixs
);
1711 Impl_Suffixs
:= Array_Elements
.Last
;
1714 Suffix
:= Element
.Next
;
1717 -- Put the resulting array as the implementation suffixs
1719 Data
.Naming
.Body_Suffix
:= Impl_Suffixs
;
1724 Current
: Array_Element_Id
:= Data
.Naming
.Body_Suffix
;
1725 Element
: Array_Element
;
1728 while Current
/= No_Array_Element
loop
1729 Element
:= Array_Elements
.Table
(Current
);
1730 Get_Name_String
(Element
.Value
.Value
);
1732 if Name_Len
= 0 then
1735 "Body_Suffix cannot be empty",
1736 Element
.Value
.Location
);
1739 Array_Elements
.Table
(Current
) := Element
;
1740 Current
:= Element
.Next
;
1744 -- Get the exceptions, if any
1746 Data
.Naming
.Specification_Exceptions
:=
1748 (Name_Specification_Exceptions
,
1749 In_Arrays
=> Naming
.Decl
.Arrays
);
1751 Data
.Naming
.Implementation_Exceptions
:=
1753 (Name_Implementation_Exceptions
,
1754 In_Arrays
=> Naming
.Decl
.Arrays
);
1756 end Check_Package_Naming
;
1758 ---------------------------------
1759 -- Check_Programming_Languages --
1760 ---------------------------------
1762 procedure Check_Programming_Languages
(Data
: in out Project_Data
) is
1763 Languages
: Variable_Value
:= Nil_Variable_Value
;
1766 Languages
:= Prj
.Util
.Value_Of
(Name_Languages
, Data
.Decl
.Attributes
);
1767 Data
.Ada_Sources_Present
:= Data
.Source_Dirs
/= Nil_String
;
1768 Data
.Other_Sources_Present
:= Data
.Source_Dirs
/= Nil_String
;
1770 if Data
.Source_Dirs
/= Nil_String
then
1772 -- Check if languages are specified in this project
1774 if Languages
.Default
then
1776 -- Attribute Languages is not specified. So, it defaults to
1777 -- a project of language Ada only.
1779 Data
.Languages
(Ada_Language_Index
) := True;
1781 -- No sources of languages other than Ada
1783 Data
.Other_Sources_Present
:= False;
1787 Current
: String_List_Id
:= Languages
.Values
;
1788 Element
: String_Element
;
1789 Lang_Name
: Name_Id
;
1790 Index
: Language_Index
;
1793 -- Assume that there is no language specified yet
1795 Data
.Other_Sources_Present
:= False;
1796 Data
.Ada_Sources_Present
:= False;
1798 -- Look through all the languages specified in attribute
1799 -- Languages, if any
1801 while Current
/= Nil_String
loop
1802 Element
:= String_Elements
.Table
(Current
);
1803 Get_Name_String
(Element
.Value
);
1804 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1805 Lang_Name
:= Name_Find
;
1806 Index
:= Language_Indexes
.Get
(Lang_Name
);
1808 if Index
= No_Language_Index
then
1809 Add_Language_Name
(Lang_Name
);
1810 Index
:= Last_Language_Index
;
1813 Set
(Index
, True, Data
);
1814 Set
(Language_Processing
=> Default_Language_Processing_Data
,
1815 For_Language
=> Index
,
1816 In_Project
=> Data
);
1818 if Index
= Ada_Language_Index
then
1819 Data
.Ada_Sources_Present
:= True;
1822 Data
.Other_Sources_Present
:= True;
1825 Current
:= Element
.Next
;
1830 end Check_Programming_Languages
;
1836 function Check_Project
1838 Root_Project
: Project_Id
;
1839 Extending
: Boolean) return Boolean
1842 if P
= Root_Project
then
1845 elsif Extending
then
1847 Data
: Project_Data
:= Projects
.Table
(Root_Project
);
1850 while Data
.Extends
/= No_Project
loop
1851 if P
= Data
.Extends
then
1855 Data
:= Projects
.Table
(Data
.Extends
);
1863 -------------------------------
1864 -- Check_Stand_Alone_Library --
1865 -------------------------------
1867 procedure Check_Stand_Alone_Library
1868 (Project
: Project_Id
;
1869 Data
: in out Project_Data
;
1870 Extending
: Boolean)
1872 Lib_Interfaces
: constant Prj
.Variable_Value
:=
1874 (Snames
.Name_Library_Interface
,
1875 Data
.Decl
.Attributes
);
1877 Lib_Auto_Init
: constant Prj
.Variable_Value
:=
1879 (Snames
.Name_Library_Auto_Init
,
1880 Data
.Decl
.Attributes
);
1882 Lib_Src_Dir
: constant Prj
.Variable_Value
:=
1884 (Snames
.Name_Library_Src_Dir
,
1885 Data
.Decl
.Attributes
);
1887 Lib_Symbol_File
: constant Prj
.Variable_Value
:=
1889 (Snames
.Name_Library_Symbol_File
,
1890 Data
.Decl
.Attributes
);
1892 Lib_Symbol_Policy
: constant Prj
.Variable_Value
:=
1894 (Snames
.Name_Library_Symbol_Policy
,
1895 Data
.Decl
.Attributes
);
1897 Lib_Ref_Symbol_File
: constant Prj
.Variable_Value
:=
1899 (Snames
.Name_Library_Reference_Symbol_File
,
1900 Data
.Decl
.Attributes
);
1902 Auto_Init_Supported
: constant Boolean :=
1904 Standalone_Library_Auto_Init_Is_Supported
;
1906 OK
: Boolean := True;
1909 pragma Assert
(Lib_Interfaces
.Kind
= List
);
1911 -- It is a stand-alone library project file if attribute
1912 -- Library_Interface is defined.
1914 if not Lib_Interfaces
.Default
then
1915 SAL_Library
: declare
1916 Interfaces
: String_List_Id
:= Lib_Interfaces
.Values
;
1917 Interface_ALIs
: String_List_Id
:= Nil_String
;
1919 The_Unit_Id
: Unit_Id
;
1920 The_Unit_Data
: Unit_Data
;
1922 procedure Add_ALI_For
(Source
: Name_Id
);
1923 -- Add an ALI file name to the list of Interface ALIs
1929 procedure Add_ALI_For
(Source
: Name_Id
) is
1931 Get_Name_String
(Source
);
1934 ALI
: constant String :=
1935 ALI_File_Name
(Name_Buffer
(1 .. Name_Len
));
1936 ALI_Name_Id
: Name_Id
;
1938 Name_Len
:= ALI
'Length;
1939 Name_Buffer
(1 .. Name_Len
) := ALI
;
1940 ALI_Name_Id
:= Name_Find
;
1942 String_Elements
.Increment_Last
;
1943 String_Elements
.Table
(String_Elements
.Last
) :=
1944 (Value
=> ALI_Name_Id
,
1946 Display_Value
=> ALI_Name_Id
,
1947 Location
=> String_Elements
.Table
1948 (Interfaces
).Location
,
1950 Next
=> Interface_ALIs
);
1951 Interface_ALIs
:= String_Elements
.Last
;
1955 -- Start of processing for SAL_Library
1958 Data
.Standalone_Library
:= True;
1960 -- Library_Interface cannot be an empty list
1962 if Interfaces
= Nil_String
then
1965 "Library_Interface cannot be an empty list",
1966 Lib_Interfaces
.Location
);
1969 -- Process each unit name specified in the attribute
1970 -- Library_Interface.
1972 while Interfaces
/= Nil_String
loop
1974 (String_Elements
.Table
(Interfaces
).Value
);
1975 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1977 if Name_Len
= 0 then
1980 "an interface cannot be an empty string",
1981 String_Elements
.Table
(Interfaces
).Location
);
1985 Error_Msg_Name_1
:= Unit
;
1986 The_Unit_Id
:= Units_Htable
.Get
(Unit
);
1988 if The_Unit_Id
= Prj
.Com
.No_Unit
then
1992 String_Elements
.Table
(Interfaces
).Location
);
1995 -- Check that the unit is part of the project
1997 The_Unit_Data
:= Units
.Table
(The_Unit_Id
);
1999 if The_Unit_Data
.File_Names
2000 (Com
.Body_Part
).Name
/= No_Name
2001 and then The_Unit_Data
.File_Names
2002 (Com
.Body_Part
).Path
/= Slash
2005 (The_Unit_Data
.File_Names
(Body_Part
).Project
,
2008 -- There is a body for this unit.
2009 -- If there is no spec, we need to check
2010 -- that it is not a subunit.
2012 if The_Unit_Data
.File_Names
2013 (Specification
).Name
= No_Name
2016 Src_Ind
: Source_File_Index
;
2019 Src_Ind
:= Sinput
.P
.Load_Project_File
2021 (The_Unit_Data
.File_Names
2024 if Sinput
.P
.Source_File_Is_Subunit
2029 "{ is a subunit; " &
2030 "it cannot be an interface",
2031 String_Elements
.Table
2032 (Interfaces
).Location
);
2037 -- The unit is not a subunit, so we add
2038 -- to the Interface ALIs the ALI file
2039 -- corresponding to the body.
2042 (The_Unit_Data
.File_Names
(Body_Part
).Name
);
2047 "{ is not an unit of this project",
2048 String_Elements
.Table
2049 (Interfaces
).Location
);
2052 elsif The_Unit_Data
.File_Names
2053 (Com
.Specification
).Name
/= No_Name
2054 and then The_Unit_Data
.File_Names
2055 (Com
.Specification
).Path
/= Slash
2056 and then Check_Project
2057 (The_Unit_Data
.File_Names
2058 (Specification
).Project
,
2062 -- The unit is part of the project, it has
2063 -- a spec, but no body. We add to the Interface
2064 -- ALIs the ALI file corresponding to the spec.
2067 (The_Unit_Data
.File_Names
(Specification
).Name
);
2072 "{ is not an unit of this project",
2073 String_Elements
.Table
(Interfaces
).Location
);
2079 Interfaces
:= String_Elements
.Table
(Interfaces
).Next
;
2082 -- Put the list of Interface ALIs in the project data
2084 Data
.Lib_Interface_ALIs
:= Interface_ALIs
;
2086 -- Check value of attribute Library_Auto_Init and set
2087 -- Lib_Auto_Init accordingly.
2089 if Lib_Auto_Init
.Default
then
2091 -- If no attribute Library_Auto_Init is declared, then
2092 -- set auto init only if it is supported.
2094 Data
.Lib_Auto_Init
:= Auto_Init_Supported
;
2097 Get_Name_String
(Lib_Auto_Init
.Value
);
2098 To_Lower
(Name_Buffer
(1 .. Name_Len
));
2100 if Name_Buffer
(1 .. Name_Len
) = "false" then
2101 Data
.Lib_Auto_Init
:= False;
2103 elsif Name_Buffer
(1 .. Name_Len
) = "true" then
2104 if Auto_Init_Supported
then
2105 Data
.Lib_Auto_Init
:= True;
2108 -- Library_Auto_Init cannot be "true" if auto init
2113 "library auto init not supported " &
2115 Lib_Auto_Init
.Location
);
2121 "invalid value for attribute Library_Auto_Init",
2122 Lib_Auto_Init
.Location
);
2127 -- If attribute Library_Src_Dir is defined and not the
2128 -- empty string, check if the directory exist and is not
2129 -- the object directory or one of the source directories.
2130 -- This is the directory where copies of the interface
2131 -- sources will be copied. Note that this directory may be
2132 -- the library directory.
2134 if Lib_Src_Dir
.Value
/= Empty_String
then
2136 Dir_Id
: constant Name_Id
:= Lib_Src_Dir
.Value
;
2140 (Dir_Id
, Data
.Display_Directory
,
2141 Data
.Library_Src_Dir
,
2142 Data
.Display_Library_Src_Dir
);
2144 -- If directory does not exist, report an error
2146 if Data
.Library_Src_Dir
= No_Name
then
2148 -- Get the absolute name of the library directory
2149 -- that does not exist, to report an error.
2152 Dir_Name
: constant String :=
2153 Get_Name_String
(Dir_Id
);
2156 if Is_Absolute_Path
(Dir_Name
) then
2157 Err_Vars
.Error_Msg_Name_1
:= Dir_Id
;
2160 Get_Name_String
(Data
.Directory
);
2162 if Name_Buffer
(Name_Len
) /=
2165 Name_Len
:= Name_Len
+ 1;
2166 Name_Buffer
(Name_Len
) :=
2167 Directory_Separator
;
2172 Name_Len
+ Dir_Name
'Length) :=
2174 Name_Len
:= Name_Len
+ Dir_Name
'Length;
2175 Err_Vars
.Error_Msg_Name_1
:= Name_Find
;
2182 "Directory { does not exist",
2183 Lib_Src_Dir
.Location
);
2186 -- Report an error if it is the same as the object
2189 elsif Data
.Library_Src_Dir
= Data
.Object_Directory
then
2192 "directory to copy interfaces cannot be " &
2193 "the object directory",
2194 Lib_Src_Dir
.Location
);
2195 Data
.Library_Src_Dir
:= No_Name
;
2197 -- Check if it is same as one of the source directories
2201 Src_Dirs
: String_List_Id
:= Data
.Source_Dirs
;
2202 Src_Dir
: String_Element
;
2205 while Src_Dirs
/= Nil_String
loop
2206 Src_Dir
:= String_Elements
.Table
(Src_Dirs
);
2207 Src_Dirs
:= Src_Dir
.Next
;
2209 -- Report error if it is one of the source directories
2211 if Data
.Library_Src_Dir
= Src_Dir
.Value
then
2214 "directory to copy interfaces cannot " &
2215 "be one of the source directories",
2216 Lib_Src_Dir
.Location
);
2217 Data
.Library_Src_Dir
:= No_Name
;
2223 -- pages of code follow here with no comments at all ???
2225 if Data
.Library_Src_Dir
/= No_Name
2226 and then Current_Verbosity
= High
2228 Write_Str
("Directory to copy interfaces =""");
2229 Write_Str
(Get_Name_String
(Data
.Library_Dir
));
2236 if not Lib_Symbol_Policy
.Default
then
2238 Value
: constant String :=
2240 (Get_Name_String
(Lib_Symbol_Policy
.Value
));
2243 if Value
= "autonomous" or else Value
= "default" then
2244 Data
.Symbol_Data
.Symbol_Policy
:= Autonomous
;
2246 elsif Value
= "compliant" then
2247 Data
.Symbol_Data
.Symbol_Policy
:= Compliant
;
2249 elsif Value
= "controlled" then
2250 Data
.Symbol_Data
.Symbol_Policy
:= Controlled
;
2252 elsif Value
= "restricted" then
2253 Data
.Symbol_Data
.Symbol_Policy
:= Restricted
;
2258 "illegal value for Library_Symbol_Policy",
2259 Lib_Symbol_Policy
.Location
);
2264 if Lib_Symbol_File
.Default
then
2265 if Data
.Symbol_Data
.Symbol_Policy
= Restricted
then
2268 "Library_Symbol_File needs to be defined when " &
2269 "symbol policy is Restricted",
2270 Lib_Symbol_Policy
.Location
);
2274 Data
.Symbol_Data
.Symbol_File
:= Lib_Symbol_File
.Value
;
2276 Get_Name_String
(Lib_Symbol_File
.Value
);
2278 if Name_Len
= 0 then
2281 "symbol file name cannot be an empty string",
2282 Lib_Symbol_File
.Location
);
2285 OK
:= not Is_Absolute_Path
(Name_Buffer
(1 .. Name_Len
));
2288 for J
in 1 .. Name_Len
loop
2289 if Name_Buffer
(J
) = '/'
2290 or else Name_Buffer
(J
) = Directory_Separator
2299 Error_Msg_Name_1
:= Lib_Symbol_File
.Value
;
2302 "symbol file name { is illegal. " &
2303 "Name canot include directory info.",
2304 Lib_Symbol_File
.Location
);
2309 if Lib_Ref_Symbol_File
.Default
then
2310 if Data
.Symbol_Data
.Symbol_Policy
= Compliant
2311 or else Data
.Symbol_Data
.Symbol_Policy
= Controlled
2315 "a reference symbol file need to be defined",
2316 Lib_Symbol_Policy
.Location
);
2320 Data
.Symbol_Data
.Reference
:= Lib_Ref_Symbol_File
.Value
;
2322 Get_Name_String
(Lib_Ref_Symbol_File
.Value
);
2324 if Name_Len
= 0 then
2327 "reference symbol file name cannot be an empty string",
2328 Lib_Symbol_File
.Location
);
2331 OK
:= not Is_Absolute_Path
(Name_Buffer
(1 .. Name_Len
));
2334 for J
in 1 .. Name_Len
loop
2335 if Name_Buffer
(J
) = '/'
2336 or else Name_Buffer
(J
) = Directory_Separator
2345 Error_Msg_Name_1
:= Lib_Ref_Symbol_File
.Value
;
2348 "reference symbol file { name is illegal. " &
2349 "Name canot include directory info.",
2350 Lib_Ref_Symbol_File
.Location
);
2353 if not Is_Regular_File
2354 (Get_Name_String
(Data
.Object_Directory
) &
2355 Directory_Separator
&
2356 Get_Name_String
(Lib_Ref_Symbol_File
.Value
))
2358 Error_Msg_Name_1
:= Lib_Ref_Symbol_File
.Value
;
2361 "library reference symbol file { does not exist",
2362 Lib_Ref_Symbol_File
.Location
);
2365 if Data
.Symbol_Data
.Symbol_File
/= No_Name
then
2369 (Data
.Symbol_Data
.Symbol_File
);
2371 Reference
: String :=
2373 (Data
.Symbol_Data
.Reference
);
2376 Canonical_Case_File_Name
(Symbol
);
2377 Canonical_Case_File_Name
(Reference
);
2379 if Symbol
= Reference
then
2382 "reference symbol file and symbol file " &
2383 "cannot be the same file",
2384 Lib_Ref_Symbol_File
.Location
);
2391 end Check_Stand_Alone_Library
;
2393 ----------------------------
2394 -- Compute_Directory_Last --
2395 ----------------------------
2397 function Compute_Directory_Last
(Dir
: String) return Natural is
2400 and then (Dir
(Dir
'Last - 1) = Directory_Separator
2401 or else Dir
(Dir
'Last - 1) = '/')
2403 return Dir
'Last - 1;
2407 end Compute_Directory_Last
;
2409 --------------------
2410 -- Body_Suffix_Of --
2411 --------------------
2413 function Body_Suffix_Of
2414 (Language
: Language_Index
;
2415 In_Project
: Project_Data
) return String
2417 Suffix_Id
: constant Name_Id
:= Suffix_Of
(Language
, In_Project
);
2419 if Suffix_Id
/= No_Name
then
2420 return Get_Name_String
(Suffix_Id
);
2422 return "." & Get_Name_String
(Language_Names
.Table
(Language
));
2431 (Project
: Project_Id
;
2433 Flag_Location
: Source_Ptr
)
2435 Error_Buffer
: String (1 .. 5_000
);
2436 Error_Last
: Natural := 0;
2437 Msg_Name
: Natural := 0;
2438 First
: Positive := Msg
'First;
2440 procedure Add
(C
: Character);
2441 -- Add a character to the buffer
2443 procedure Add
(S
: String);
2444 -- Add a string to the buffer
2446 procedure Add
(Id
: Name_Id
);
2447 -- Add a name to the buffer
2453 procedure Add
(C
: Character) is
2455 Error_Last
:= Error_Last
+ 1;
2456 Error_Buffer
(Error_Last
) := C
;
2459 procedure Add
(S
: String) is
2461 Error_Buffer
(Error_Last
+ 1 .. Error_Last
+ S
'Length) := S
;
2462 Error_Last
:= Error_Last
+ S
'Length;
2465 procedure Add
(Id
: Name_Id
) is
2467 Get_Name_String
(Id
);
2468 Add
(Name_Buffer
(1 .. Name_Len
));
2471 -- Start of processing for Error_Msg
2474 if Error_Report
= null then
2475 Prj
.Err
.Error_Msg
(Msg
, Flag_Location
);
2479 -- Ignore continuation character
2481 if Msg
(First
) = '\' then
2484 -- Warniung character is always the first one in this package
2486 elsif Msg
(First
) = '?' then
2491 for Index
in First
.. Msg
'Last loop
2492 if Msg
(Index
) = '{' or else Msg
(Index
) = '%' then
2494 -- Include a name between double quotes
2496 Msg_Name
:= Msg_Name
+ 1;
2500 when 1 => Add
(Err_Vars
.Error_Msg_Name_1
);
2501 when 2 => Add
(Err_Vars
.Error_Msg_Name_2
);
2502 when 3 => Add
(Err_Vars
.Error_Msg_Name_3
);
2504 when others => null;
2515 Error_Report
(Error_Buffer
(1 .. Error_Last
), Project
);
2522 procedure Find_Sources
2523 (Project
: Project_Id
;
2524 Data
: in out Project_Data
;
2525 For_Language
: Language_Index
;
2526 Follow_Links
: Boolean := False)
2528 Source_Dir
: String_List_Id
:= Data
.Source_Dirs
;
2529 Element
: String_Element
;
2531 Current_Source
: String_List_Id
:= Nil_String
;
2532 Source_Recorded
: Boolean := False;
2535 if Current_Verbosity
= High
then
2536 Write_Line
("Looking for sources:");
2539 -- For each subdirectory
2541 while Source_Dir
/= Nil_String
loop
2543 Source_Recorded
:= False;
2544 Element
:= String_Elements
.Table
(Source_Dir
);
2545 if Element
.Value
/= No_Name
then
2546 Get_Name_String
(Element
.Display_Value
);
2549 Source_Directory
: constant String :=
2550 Name_Buffer
(1 .. Name_Len
) & Directory_Separator
;
2551 Dir_Last
: constant Natural :=
2552 Compute_Directory_Last
(Source_Directory
);
2555 if Current_Verbosity
= High
then
2556 Write_Str
("Source_Dir = ");
2557 Write_Line
(Source_Directory
);
2560 -- We look to every entry in the source directory
2562 Open
(Dir
, Source_Directory
2563 (Source_Directory
'First .. Dir_Last
));
2566 Read
(Dir
, Name_Buffer
, Name_Len
);
2568 if Current_Verbosity
= High
then
2569 Write_Str
(" Checking ");
2570 Write_Line
(Name_Buffer
(1 .. Name_Len
));
2573 exit when Name_Len
= 0;
2576 File_Name
: constant Name_Id
:= Name_Find
;
2577 Path
: constant String :=
2579 (Name
=> Name_Buffer
(1 .. Name_Len
),
2580 Directory
=> Source_Directory
2581 (Source_Directory
'First .. Dir_Last
),
2582 Resolve_Links
=> Follow_Links
,
2583 Case_Sensitive
=> True);
2584 Path_Name
: Name_Id
;
2587 Name_Len
:= Path
'Length;
2588 Name_Buffer
(1 .. Name_Len
) := Path
;
2589 Path_Name
:= Name_Find
;
2591 if For_Language
= Ada_Language_Index
then
2593 -- We attempt to register it as a source. However,
2594 -- there is no error if the file does not contain
2595 -- a valid source. But there is an error if we have
2596 -- a duplicate unit name.
2599 (File_Name
=> File_Name
,
2600 Path_Name
=> Path_Name
,
2603 Location
=> No_Location
,
2604 Current_Source
=> Current_Source
,
2605 Source_Recorded
=> Source_Recorded
,
2606 Follow_Links
=> Follow_Links
);
2610 (File_Name
=> File_Name
,
2611 Path_Name
=> Path_Name
,
2614 Location
=> No_Location
,
2615 Language
=> For_Language
,
2617 Body_Suffix_Of
(For_Language
, Data
),
2618 Naming_Exception
=> False);
2628 when Directory_Error
=>
2632 if Source_Recorded
then
2633 String_Elements
.Table
(Source_Dir
).Flag
:= True;
2636 Source_Dir
:= Element
.Next
;
2639 if Current_Verbosity
= High
then
2640 Write_Line
("end Looking for sources.");
2643 if For_Language
= Ada_Language_Index
then
2645 -- If we have looked for sources and found none, then
2646 -- it is an error, except if it is an extending project.
2647 -- If a non extending project is not supposed to contain
2648 -- any source, then we never call Find_Sources.
2650 if Current_Source
/= Nil_String
then
2651 Data
.Ada_Sources_Present
:= True;
2653 elsif Data
.Extends
= No_Project
then
2656 "there are no Ada sources in this project",
2662 --------------------------------
2663 -- Free_Ada_Naming_Exceptions --
2664 --------------------------------
2666 procedure Free_Ada_Naming_Exceptions
is
2668 Ada_Naming_Exception_Table
.Set_Last
(0);
2669 Ada_Naming_Exceptions
.Reset
;
2670 Reverse_Ada_Naming_Exceptions
.Reset
;
2671 end Free_Ada_Naming_Exceptions
;
2673 ---------------------
2674 -- Get_Directories --
2675 ---------------------
2677 procedure Get_Directories
2678 (Project
: Project_Id
;
2679 Data
: in out Project_Data
)
2681 Object_Dir
: constant Variable_Value
:=
2682 Util
.Value_Of
(Name_Object_Dir
, Data
.Decl
.Attributes
);
2684 Exec_Dir
: constant Variable_Value
:=
2685 Util
.Value_Of
(Name_Exec_Dir
, Data
.Decl
.Attributes
);
2687 Source_Dirs
: constant Variable_Value
:=
2689 (Name_Source_Dirs
, Data
.Decl
.Attributes
);
2691 Last_Source_Dir
: String_List_Id
:= Nil_String
;
2693 procedure Find_Source_Dirs
(From
: Name_Id
; Location
: Source_Ptr
);
2694 -- Find one or several source directories, and add them
2695 -- to the list of source directories of the project.
2697 ----------------------
2698 -- Find_Source_Dirs --
2699 ----------------------
2701 procedure Find_Source_Dirs
(From
: Name_Id
; Location
: Source_Ptr
) is
2702 Directory
: constant String := Get_Name_String
(From
);
2703 Element
: String_Element
;
2705 procedure Recursive_Find_Dirs
(Path
: Name_Id
);
2706 -- Find all the subdirectories (recursively) of Path and add them
2707 -- to the list of source directories of the project.
2709 -------------------------
2710 -- Recursive_Find_Dirs --
2711 -------------------------
2713 procedure Recursive_Find_Dirs
(Path
: Name_Id
) is
2715 Name
: String (1 .. 250);
2717 List
: String_List_Id
:= Data
.Source_Dirs
;
2718 Element
: String_Element
;
2719 Found
: Boolean := False;
2721 Non_Canonical_Path
: Name_Id
:= No_Name
;
2722 Canonical_Path
: Name_Id
:= No_Name
;
2724 The_Path
: constant String :=
2725 Normalize_Pathname
(Get_Name_String
(Path
)) &
2726 Directory_Separator
;
2728 The_Path_Last
: constant Natural :=
2729 Compute_Directory_Last
(The_Path
);
2732 Name_Len
:= The_Path_Last
- The_Path
'First + 1;
2733 Name_Buffer
(1 .. Name_Len
) :=
2734 The_Path
(The_Path
'First .. The_Path_Last
);
2735 Non_Canonical_Path
:= Name_Find
;
2736 Get_Name_String
(Non_Canonical_Path
);
2737 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
2738 Canonical_Path
:= Name_Find
;
2740 -- To avoid processing the same directory several times, check
2741 -- if the directory is already in Recursive_Dirs. If it is,
2742 -- then there is nothing to do, just return. If it is not, put
2743 -- it there and continue recursive processing.
2745 if Recursive_Dirs
.Get
(Canonical_Path
) then
2749 Recursive_Dirs
.Set
(Canonical_Path
, True);
2752 -- Check if directory is already in list
2754 while List
/= Nil_String
loop
2755 Element
:= String_Elements
.Table
(List
);
2757 if Element
.Value
/= No_Name
then
2758 Found
:= Element
.Value
= Canonical_Path
;
2762 List
:= Element
.Next
;
2765 -- If directory is not already in list, put it there
2768 if Current_Verbosity
= High
then
2770 Write_Line
(The_Path
(The_Path
'First .. The_Path_Last
));
2773 String_Elements
.Increment_Last
;
2775 (Value
=> Canonical_Path
,
2776 Display_Value
=> Non_Canonical_Path
,
2777 Location
=> No_Location
,
2782 -- Case of first source directory
2784 if Last_Source_Dir
= Nil_String
then
2785 Data
.Source_Dirs
:= String_Elements
.Last
;
2787 -- Here we already have source directories
2790 -- Link the previous last to the new one
2792 String_Elements
.Table
(Last_Source_Dir
).Next
:=
2793 String_Elements
.Last
;
2796 -- And register this source directory as the new last
2798 Last_Source_Dir
:= String_Elements
.Last
;
2799 String_Elements
.Table
(Last_Source_Dir
) := Element
;
2802 -- Now look for subdirectories. We do that even when this
2803 -- directory is already in the list, because some of its
2804 -- subdirectories may not be in the list yet.
2806 Open
(Dir
, The_Path
(The_Path
'First .. The_Path_Last
));
2809 Read
(Dir
, Name
, Last
);
2812 if Name
(1 .. Last
) /= "."
2813 and then Name
(1 .. Last
) /= ".."
2815 -- Avoid . and .. directories
2817 if Current_Verbosity
= High
then
2818 Write_Str
(" Checking ");
2819 Write_Line
(Name
(1 .. Last
));
2823 Path_Name
: constant String :=
2825 (Name
=> Name
(1 .. Last
),
2828 (The_Path
'First .. The_Path_Last
),
2829 Resolve_Links
=> False,
2830 Case_Sensitive
=> True);
2833 if Is_Directory
(Path_Name
) then
2835 -- We have found a new subdirectory, call self
2837 Name_Len
:= Path_Name
'Length;
2838 Name_Buffer
(1 .. Name_Len
) := Path_Name
;
2839 Recursive_Find_Dirs
(Name_Find
);
2848 when Directory_Error
=>
2850 end Recursive_Find_Dirs
;
2852 -- Start of processing for Find_Source_Dirs
2855 if Current_Verbosity
= High
then
2856 Write_Str
("Find_Source_Dirs (""");
2857 Write_Str
(Directory
);
2861 -- First, check if we are looking for a directory tree,
2862 -- indicated by "/**" at the end.
2864 if Directory
'Length >= 3
2865 and then Directory
(Directory
'Last - 1 .. Directory
'Last) = "**"
2866 and then (Directory
(Directory
'Last - 2) = '/'
2868 Directory
(Directory
'Last - 2) = Directory_Separator
)
2870 Data
.Known_Order_Of_Source_Dirs
:= False;
2872 Name_Len
:= Directory
'Length - 3;
2874 if Name_Len
= 0 then
2876 -- This is the case of "/**": all directories
2877 -- in the file system.
2880 Name_Buffer
(1) := Directory
(Directory
'First);
2883 Name_Buffer
(1 .. Name_Len
) :=
2884 Directory
(Directory
'First .. Directory
'Last - 3);
2887 if Current_Verbosity
= High
then
2888 Write_Str
("Looking for all subdirectories of """);
2889 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2894 Base_Dir
: constant Name_Id
:= Name_Find
;
2895 Root_Dir
: constant String :=
2897 (Name
=> Get_Name_String
(Base_Dir
),
2899 Get_Name_String
(Data
.Display_Directory
),
2900 Resolve_Links
=> False,
2901 Case_Sensitive
=> True);
2904 if Root_Dir
'Length = 0 then
2905 Err_Vars
.Error_Msg_Name_1
:= Base_Dir
;
2907 if Location
= No_Location
then
2910 "{ is not a valid directory.",
2915 "{ is not a valid directory.",
2920 -- We have an existing directory, we register it and all
2921 -- of its subdirectories.
2923 if Current_Verbosity
= High
then
2924 Write_Line
("Looking for source directories:");
2927 Name_Len
:= Root_Dir
'Length;
2928 Name_Buffer
(1 .. Name_Len
) := Root_Dir
;
2929 Recursive_Find_Dirs
(Name_Find
);
2931 if Current_Verbosity
= High
then
2932 Write_Line
("End of looking for source directories.");
2937 -- We have a single directory
2941 Path_Name
: Name_Id
;
2942 Display_Path_Name
: Name_Id
;
2946 (From
, Data
.Display_Directory
, Path_Name
, Display_Path_Name
);
2948 if Path_Name
= No_Name
then
2949 Err_Vars
.Error_Msg_Name_1
:= From
;
2951 if Location
= No_Location
then
2954 "{ is not a valid directory",
2959 "{ is not a valid directory",
2964 -- As it is an existing directory, we add it to
2965 -- the list of directories.
2967 String_Elements
.Increment_Last
;
2968 Element
.Value
:= Path_Name
;
2969 Element
.Display_Value
:= Display_Path_Name
;
2971 if Last_Source_Dir
= Nil_String
then
2973 -- This is the first source directory
2975 Data
.Source_Dirs
:= String_Elements
.Last
;
2978 -- We already have source directories,
2979 -- link the previous last to the new one.
2981 String_Elements
.Table
(Last_Source_Dir
).Next
:=
2982 String_Elements
.Last
;
2985 -- And register this source directory as the new last
2987 Last_Source_Dir
:= String_Elements
.Last
;
2988 String_Elements
.Table
(Last_Source_Dir
) := Element
;
2992 end Find_Source_Dirs
;
2994 -- Start of processing for Get_Directories
2997 if Current_Verbosity
= High
then
2998 Write_Line
("Starting to look for directories");
3001 -- Check the object directory
3003 pragma Assert
(Object_Dir
.Kind
= Single
,
3004 "Object_Dir is not a single string");
3006 -- We set the object directory to its default
3008 Data
.Object_Directory
:= Data
.Directory
;
3009 Data
.Display_Object_Dir
:= Data
.Display_Directory
;
3011 if Object_Dir
.Value
/= Empty_String
then
3012 Get_Name_String
(Object_Dir
.Value
);
3014 if Name_Len
= 0 then
3017 "Object_Dir cannot be empty",
3018 Object_Dir
.Location
);
3021 -- We check that the specified object directory does exist
3024 (Object_Dir
.Value
, Data
.Display_Directory
,
3025 Data
.Object_Directory
, Data
.Display_Object_Dir
);
3027 if Data
.Object_Directory
= No_Name
then
3029 -- The object directory does not exist, report an error
3031 Err_Vars
.Error_Msg_Name_1
:= Object_Dir
.Value
;
3034 "the object directory { cannot be found",
3037 -- Do not keep a nil Object_Directory. Set it to the specified
3038 -- (relative or absolute) path. This is for the benefit of
3039 -- tools that recover from errors; for example, these tools
3040 -- could create the non existent directory.
3042 Data
.Display_Object_Dir
:= Object_Dir
.Value
;
3043 Get_Name_String
(Object_Dir
.Value
);
3044 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3045 Data
.Object_Directory
:= Name_Find
;
3050 if Current_Verbosity
= High
then
3051 if Data
.Object_Directory
= No_Name
then
3052 Write_Line
("No object directory");
3054 Write_Str
("Object directory: """);
3055 Write_Str
(Get_Name_String
(Data
.Display_Object_Dir
));
3060 -- Check the exec directory
3062 pragma Assert
(Exec_Dir
.Kind
= Single
,
3063 "Exec_Dir is not a single string");
3065 -- We set the object directory to its default
3067 Data
.Exec_Directory
:= Data
.Object_Directory
;
3068 Data
.Display_Exec_Dir
:= Data
.Display_Object_Dir
;
3070 if Exec_Dir
.Value
/= Empty_String
then
3071 Get_Name_String
(Exec_Dir
.Value
);
3073 if Name_Len
= 0 then
3076 "Exec_Dir cannot be empty",
3080 -- We check that the specified object directory
3084 (Exec_Dir
.Value
, Data
.Directory
,
3085 Data
.Exec_Directory
, Data
.Display_Exec_Dir
);
3087 if Data
.Exec_Directory
= No_Name
then
3088 Err_Vars
.Error_Msg_Name_1
:= Exec_Dir
.Value
;
3091 "the exec directory { cannot be found",
3097 if Current_Verbosity
= High
then
3098 if Data
.Exec_Directory
= No_Name
then
3099 Write_Line
("No exec directory");
3101 Write_Str
("Exec directory: """);
3102 Write_Str
(Get_Name_String
(Data
.Display_Exec_Dir
));
3107 -- Look for the source directories
3109 if Current_Verbosity
= High
then
3110 Write_Line
("Starting to look for source directories");
3113 pragma Assert
(Source_Dirs
.Kind
= List
, "Source_Dirs is not a list");
3115 if Source_Dirs
.Default
then
3117 -- No Source_Dirs specified: the single source directory
3118 -- is the one containing the project file
3120 String_Elements
.Increment_Last
;
3121 Data
.Source_Dirs
:= String_Elements
.Last
;
3122 String_Elements
.Table
(Data
.Source_Dirs
) :=
3123 (Value
=> Data
.Directory
,
3124 Display_Value
=> Data
.Display_Directory
,
3125 Location
=> No_Location
,
3130 if Current_Verbosity
= High
then
3131 Write_Line
("Single source directory:");
3133 Write_Str
(Get_Name_String
(Data
.Display_Directory
));
3137 elsif Source_Dirs
.Values
= Nil_String
then
3139 -- If Source_Dirs is an empty string list, this means
3140 -- that this project contains no source. For projects that
3141 -- don't extend other projects, this also means that there is no
3142 -- need for an object directory, if not specified.
3144 if Data
.Extends
= No_Project
3145 and then Data
.Object_Directory
= Data
.Directory
3147 Data
.Object_Directory
:= No_Name
;
3150 Data
.Source_Dirs
:= Nil_String
;
3151 Data
.Ada_Sources_Present
:= False;
3152 Data
.Other_Sources_Present
:= False;
3156 Source_Dir
: String_List_Id
:= Source_Dirs
.Values
;
3157 Element
: String_Element
;
3160 -- We will find the source directories for each
3161 -- element of the list
3163 while Source_Dir
/= Nil_String
loop
3164 Element
:= String_Elements
.Table
(Source_Dir
);
3165 Find_Source_Dirs
(Element
.Value
, Element
.Location
);
3166 Source_Dir
:= Element
.Next
;
3171 if Current_Verbosity
= High
then
3172 Write_Line
("Putting source directories in canonical cases");
3176 Current
: String_List_Id
:= Data
.Source_Dirs
;
3177 Element
: String_Element
;
3180 while Current
/= Nil_String
loop
3181 Element
:= String_Elements
.Table
(Current
);
3182 if Element
.Value
/= No_Name
then
3183 Get_Name_String
(Element
.Value
);
3184 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3185 Element
.Value
:= Name_Find
;
3186 String_Elements
.Table
(Current
) := Element
;
3189 Current
:= Element
.Next
;
3193 end Get_Directories
;
3199 procedure Get_Mains
(Project
: Project_Id
; Data
: in out Project_Data
) is
3200 Mains
: constant Variable_Value
:=
3201 Prj
.Util
.Value_Of
(Name_Main
, Data
.Decl
.Attributes
);
3204 Data
.Mains
:= Mains
.Values
;
3206 -- If no Mains were specified, and if we are an extending
3207 -- project, inherit the Mains from the project we are extending.
3209 if Mains
.Default
then
3210 if Data
.Extends
/= No_Project
then
3211 Data
.Mains
:= Projects
.Table
(Data
.Extends
).Mains
;
3214 -- In a library project file, Main cannot be specified
3216 elsif Data
.Library
then
3219 "a library project file cannot have Main specified",
3224 ---------------------------
3225 -- Get_Sources_From_File --
3226 ---------------------------
3228 procedure Get_Sources_From_File
3230 Location
: Source_Ptr
;
3231 Project
: Project_Id
)
3233 File
: Prj
.Util
.Text_File
;
3234 Line
: String (1 .. 250);
3236 Source_Name
: Name_Id
;
3241 if Current_Verbosity
= High
then
3242 Write_Str
("Opening """);
3249 Prj
.Util
.Open
(File
, Path
);
3251 if not Prj
.Util
.Is_Valid
(File
) then
3252 Error_Msg
(Project
, "file does not exist", Location
);
3254 -- Read the lines one by one
3256 while not Prj
.Util
.End_Of_File
(File
) loop
3257 Prj
.Util
.Get_Line
(File
, Line
, Last
);
3259 -- A non empty, non comment line should contain a file name
3262 and then (Last
= 1 or else Line
(1 .. 2) /= "--")
3264 -- ??? we should check that there is no directory information
3267 Name_Buffer
(1 .. Name_Len
) := Line
(1 .. Last
);
3268 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3269 Source_Name
:= Name_Find
;
3273 (Name
=> Source_Name
,
3274 Location
=> Location
,
3279 Prj
.Util
.Close
(File
);
3282 end Get_Sources_From_File
;
3289 (Canonical_File_Name
: Name_Id
;
3290 Naming
: Naming_Data
;
3291 Exception_Id
: out Ada_Naming_Exception_Id
;
3292 Unit_Name
: out Name_Id
;
3293 Unit_Kind
: out Spec_Or_Body
;
3294 Needs_Pragma
: out Boolean)
3296 Info_Id
: Ada_Naming_Exception_Id
3297 := Ada_Naming_Exceptions
.Get
(Canonical_File_Name
);
3301 if Info_Id
= No_Ada_Naming_Exception
then
3302 if Hostparm
.OpenVMS
then
3303 VMS_Name
:= Canonical_File_Name
;
3304 Get_Name_String
(VMS_Name
);
3306 if Name_Buffer
(Name_Len
) = '.' then
3307 Name_Len
:= Name_Len
- 1;
3308 VMS_Name
:= Name_Find
;
3311 Info_Id
:= Ada_Naming_Exceptions
.Get
(VMS_Name
);
3316 if Info_Id
/= No_Ada_Naming_Exception
then
3317 Exception_Id
:= Info_Id
;
3318 Unit_Name
:= No_Name
;
3319 Unit_Kind
:= Specification
;
3320 Needs_Pragma
:= True;
3324 Needs_Pragma
:= False;
3325 Exception_Id
:= No_Ada_Naming_Exception
;
3327 Get_Name_String
(Canonical_File_Name
);
3330 File
: String := Name_Buffer
(1 .. Name_Len
);
3331 First
: constant Positive := File
'First;
3332 Last
: Natural := File
'Last;
3333 Standard_GNAT
: Boolean;
3337 Naming
.Ada_Spec_Suffix
= Default_Ada_Spec_Suffix
3338 and then Naming
.Ada_Body_Suffix
= Default_Ada_Body_Suffix
;
3340 -- Check if the end of the file name is Specification_Append
3342 Get_Name_String
(Naming
.Ada_Spec_Suffix
);
3344 if File
'Length > Name_Len
3345 and then File
(Last
- Name_Len
+ 1 .. Last
) =
3346 Name_Buffer
(1 .. Name_Len
)
3350 Unit_Kind
:= Specification
;
3351 Last
:= Last
- Name_Len
;
3353 if Current_Verbosity
= High
then
3354 Write_Str
(" Specification: ");
3355 Write_Line
(File
(First
.. Last
));
3359 Get_Name_String
(Naming
.Ada_Body_Suffix
);
3361 -- Check if the end of the file name is Body_Append
3363 if File
'Length > Name_Len
3364 and then File
(Last
- Name_Len
+ 1 .. Last
) =
3365 Name_Buffer
(1 .. Name_Len
)
3369 Unit_Kind
:= Body_Part
;
3370 Last
:= Last
- Name_Len
;
3372 if Current_Verbosity
= High
then
3373 Write_Str
(" Body: ");
3374 Write_Line
(File
(First
.. Last
));
3377 elsif Naming
.Separate_Suffix
/= Naming
.Ada_Spec_Suffix
then
3378 Get_Name_String
(Naming
.Separate_Suffix
);
3380 -- Check if the end of the file name is Separate_Append
3382 if File
'Length > Name_Len
3383 and then File
(Last
- Name_Len
+ 1 .. Last
) =
3384 Name_Buffer
(1 .. Name_Len
)
3386 -- We have a separate (a body)
3388 Unit_Kind
:= Body_Part
;
3389 Last
:= Last
- Name_Len
;
3391 if Current_Verbosity
= High
then
3392 Write_Str
(" Separate: ");
3393 Write_Line
(File
(First
.. Last
));
3407 -- This is not a source file
3409 Unit_Name
:= No_Name
;
3410 Unit_Kind
:= Specification
;
3412 if Current_Verbosity
= High
then
3413 Write_Line
(" Not a valid file name.");
3419 Get_Name_String
(Naming
.Dot_Replacement
);
3421 Standard_GNAT
and then Name_Buffer
(1 .. Name_Len
) = "-";
3423 if Name_Buffer
(1 .. Name_Len
) /= "." then
3425 -- If Dot_Replacement is not a single dot, then there should
3426 -- not be any dot in the name.
3428 for Index
in First
.. Last
loop
3429 if File
(Index
) = '.' then
3430 if Current_Verbosity
= High
then
3432 (" Not a valid file name (some dot not replaced).");
3435 Unit_Name
:= No_Name
;
3441 -- Replace the substring Dot_Replacement with dots
3444 Index
: Positive := First
;
3447 while Index
<= Last
- Name_Len
+ 1 loop
3449 if File
(Index
.. Index
+ Name_Len
- 1) =
3450 Name_Buffer
(1 .. Name_Len
)
3452 File
(Index
) := '.';
3454 if Name_Len
> 1 and then Index
< Last
then
3455 File
(Index
+ 1 .. Last
- Name_Len
+ 1) :=
3456 File
(Index
+ Name_Len
.. Last
);
3459 Last
:= Last
- Name_Len
+ 1;
3467 -- Check if the casing is right
3470 Src
: String := File
(First
.. Last
);
3473 case Naming
.Casing
is
3474 when All_Lower_Case
=>
3477 Mapping
=> Lower_Case_Map
);
3479 when All_Upper_Case
=>
3482 Mapping
=> Upper_Case_Map
);
3484 when Mixed_Case | Unknown
=>
3488 if Src
/= File
(First
.. Last
) then
3489 if Current_Verbosity
= High
then
3490 Write_Line
(" Not a valid file name (casing).");
3493 Unit_Name
:= No_Name
;
3497 -- We put the name in lower case
3501 Mapping
=> Lower_Case_Map
);
3503 -- In the standard GNAT naming scheme, check for special cases:
3504 -- children or separates of A, G, I or S, and run time sources.
3506 if Standard_GNAT
and then Src
'Length >= 3 then
3508 S1
: constant Character := Src
(Src
'First);
3509 S2
: constant Character := Src
(Src
'First + 1);
3512 if S1
= 'a' or else S1
= 'g'
3513 or else S1
= 'i' or else S1
= 's'
3515 -- Children or separates of packages A, G, I or S
3517 if (Hostparm
.OpenVMS
and then S2
= '$')
3518 or else (not Hostparm
.OpenVMS
and then S2
= '~')
3520 Src
(Src
'First + 1) := '.';
3522 -- If it is potentially a run time source, disable
3523 -- filling of the mapping file to avoid warnings.
3526 Set_Mapping_File_Initial_State_To_Empty
;
3533 if Current_Verbosity
= High
then
3538 -- Now, we check if this name is a valid unit name
3540 Check_Ada_Name
(Name
=> Src
, Unit
=> Unit_Name
);
3550 function Hash
(Unit
: Unit_Info
) return Header_Num
is
3552 return Header_Num
(Unit
.Unit
mod 2048);
3555 -----------------------
3556 -- Is_Illegal_Suffix --
3557 -----------------------
3559 function Is_Illegal_Suffix
3561 Dot_Replacement_Is_A_Single_Dot
: Boolean) return Boolean
3564 if Suffix
'Length = 0 or else Index
(Suffix
, ".") = 0 then
3568 -- If dot replacement is a single dot, and first character of
3569 -- suffix is also a dot
3571 if Dot_Replacement_Is_A_Single_Dot
3572 and then Suffix
(Suffix
'First) = '.'
3574 for Index
in Suffix
'First + 1 .. Suffix
'Last loop
3576 -- If there is another dot
3578 if Suffix
(Index
) = '.' then
3580 -- It is illegal to have a letter following the initial dot
3582 return Is_Letter
(Suffix
(Suffix
'First + 1));
3590 end Is_Illegal_Suffix
;
3592 ----------------------
3593 -- Locate_Directory --
3594 ----------------------
3596 procedure Locate_Directory
3600 Display
: out Name_Id
)
3602 The_Name
: constant String := Get_Name_String
(Name
);
3604 The_Parent
: constant String :=
3605 Get_Name_String
(Parent
) & Directory_Separator
;
3607 The_Parent_Last
: constant Natural :=
3608 Compute_Directory_Last
(The_Parent
);
3611 if Current_Verbosity
= High
then
3612 Write_Str
("Locate_Directory (""");
3613 Write_Str
(The_Name
);
3614 Write_Str
(""", """);
3615 Write_Str
(The_Parent
);
3622 if Is_Absolute_Path
(The_Name
) then
3623 if Is_Directory
(The_Name
) then
3625 Normed
: constant String :=
3628 Resolve_Links
=> False,
3629 Case_Sensitive
=> True);
3631 Canonical_Path
: constant String :=
3634 Resolve_Links
=> True,
3635 Case_Sensitive
=> False);
3638 Name_Len
:= Normed
'Length;
3639 Name_Buffer
(1 .. Name_Len
) := Normed
;
3640 Display
:= Name_Find
;
3642 Name_Len
:= Canonical_Path
'Length;
3643 Name_Buffer
(1 .. Name_Len
) := Canonical_Path
;
3650 Full_Path
: constant String :=
3651 The_Parent
(The_Parent
'First .. The_Parent_Last
) &
3655 if Is_Directory
(Full_Path
) then
3657 Normed
: constant String :=
3660 Resolve_Links
=> False,
3661 Case_Sensitive
=> True);
3663 Canonical_Path
: constant String :=
3666 Resolve_Links
=> True,
3667 Case_Sensitive
=> False);
3670 Name_Len
:= Normed
'Length;
3671 Name_Buffer
(1 .. Name_Len
) := Normed
;
3672 Display
:= Name_Find
;
3674 Name_Len
:= Canonical_Path
'Length;
3675 Name_Buffer
(1 .. Name_Len
) := Canonical_Path
;
3681 end Locate_Directory
;
3683 ----------------------
3684 -- Look_For_Sources --
3685 ----------------------
3687 procedure Look_For_Sources
3688 (Project
: Project_Id
;
3689 Data
: in out Project_Data
;
3690 Follow_Links
: Boolean)
3692 procedure Get_Path_Names_And_Record_Sources
(Follow_Links
: Boolean);
3693 -- Find the path names of the source files in the Source_Names table
3694 -- in the source directories and record those that are Ada sources.
3696 procedure Get_Sources_From_File
3698 Location
: Source_Ptr
);
3699 -- Get the sources of a project from a text file
3701 ---------------------------------------
3702 -- Get_Path_Names_And_Record_Sources --
3703 ---------------------------------------
3705 procedure Get_Path_Names_And_Record_Sources
(Follow_Links
: Boolean) is
3706 Source_Dir
: String_List_Id
:= Data
.Source_Dirs
;
3707 Element
: String_Element
;
3712 Canonical_Name
: Name_Id
;
3713 Name_Str
: String (1 .. 1_024
);
3714 Last
: Natural := 0;
3717 Current_Source
: String_List_Id
:= Nil_String
;
3719 First_Error
: Boolean := True;
3721 Source_Recorded
: Boolean := False;
3724 -- We look in all source directories for the file names in the
3725 -- hash table Source_Names
3727 while Source_Dir
/= Nil_String
loop
3728 Source_Recorded
:= False;
3729 Element
:= String_Elements
.Table
(Source_Dir
);
3732 Dir_Path
: constant String := Get_Name_String
(Element
.Value
);
3734 if Current_Verbosity
= High
then
3735 Write_Str
("checking directory """);
3736 Write_Str
(Dir_Path
);
3740 Open
(Dir
, Dir_Path
);
3743 Read
(Dir
, Name_Str
, Last
);
3746 Name_Buffer
(1 .. Name_Len
) := Name_Str
(1 .. Last
);
3748 Canonical_Case_File_Name
(Name_Str
(1 .. Last
));
3750 Name_Buffer
(1 .. Name_Len
) := Name_Str
(1 .. Last
);
3751 Canonical_Name
:= Name_Find
;
3752 NL
:= Source_Names
.Get
(Canonical_Name
);
3754 if NL
/= No_Name_Location
and then not NL
.Found
then
3756 Source_Names
.Set
(Canonical_Name
, NL
);
3757 Name_Len
:= Dir_Path
'Length;
3758 Name_Buffer
(1 .. Name_Len
) := Dir_Path
;
3760 if Name_Buffer
(Name_Len
) /= Directory_Separator
then
3761 Add_Char_To_Name_Buffer
(Directory_Separator
);
3764 Add_Str_To_Name_Buffer
(Name_Str
(1 .. Last
));
3767 if Current_Verbosity
= High
then
3768 Write_Str
(" found ");
3769 Write_Line
(Get_Name_String
(Name
));
3772 -- Register the source if it is an Ada compilation unit
3779 Location
=> NL
.Location
,
3780 Current_Source
=> Current_Source
,
3781 Source_Recorded
=> Source_Recorded
,
3782 Follow_Links
=> Follow_Links
);
3789 if Source_Recorded
then
3790 String_Elements
.Table
(Source_Dir
).Flag
:= True;
3793 Source_Dir
:= Element
.Next
;
3796 -- It is an error if a source file name in a source list or
3797 -- in a source list file is not found.
3799 NL
:= Source_Names
.Get_First
;
3801 while NL
/= No_Name_Location
loop
3802 if not NL
.Found
then
3803 Err_Vars
.Error_Msg_Name_1
:= NL
.Name
;
3808 "source file { cannot be found",
3810 First_Error
:= False;
3815 "\source file { cannot be found",
3820 NL
:= Source_Names
.Get_Next
;
3822 end Get_Path_Names_And_Record_Sources
;
3824 ---------------------------
3825 -- Get_Sources_From_File --
3826 ---------------------------
3828 procedure Get_Sources_From_File
3830 Location
: Source_Ptr
)
3833 -- Get the list of sources from the file and put them in hash table
3836 Get_Sources_From_File
(Path
, Location
, Project
);
3838 -- Look in the source directories to find those sources
3840 Get_Path_Names_And_Record_Sources
(Follow_Links
);
3842 -- We should have found at least one source.
3843 -- If not, report an error.
3845 if Data
.Sources
= Nil_String
then
3847 "there are no Ada sources in this project",
3850 end Get_Sources_From_File
;
3853 if Data
.Ada_Sources_Present
then
3855 Sources
: constant Variable_Value
:=
3858 Data
.Decl
.Attributes
);
3860 Source_List_File
: constant Variable_Value
:=
3862 (Name_Source_List_File
,
3863 Data
.Decl
.Attributes
);
3865 Locally_Removed
: constant Variable_Value
:=
3867 (Name_Locally_Removed_Files
,
3868 Data
.Decl
.Attributes
);
3872 (Sources
.Kind
= List
,
3873 "Source_Files is not a list");
3876 (Source_List_File
.Kind
= Single
,
3877 "Source_List_File is not a single string");
3879 if not Sources
.Default
then
3880 if not Source_List_File
.Default
then
3883 "?both variables source_files and " &
3884 "source_list_file are present",
3885 Source_List_File
.Location
);
3888 -- Sources is a list of file names
3891 Current
: String_List_Id
:= Sources
.Values
;
3892 Element
: String_Element
;
3893 Location
: Source_Ptr
;
3899 Data
.Ada_Sources_Present
:= Current
/= Nil_String
;
3901 while Current
/= Nil_String
loop
3902 Element
:= String_Elements
.Table
(Current
);
3903 Get_Name_String
(Element
.Value
);
3904 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3907 -- If the element has no location, then use the
3908 -- location of Sources to report possible errors.
3910 if Element
.Location
= No_Location
then
3911 Location
:= Sources
.Location
;
3913 Location
:= Element
.Location
;
3920 Location
=> Location
,
3923 Current
:= Element
.Next
;
3926 Get_Path_Names_And_Record_Sources
(Follow_Links
);
3929 -- No source_files specified
3931 -- We check Source_List_File has been specified
3933 elsif not Source_List_File
.Default
then
3935 -- Source_List_File is the name of the file
3936 -- that contains the source file names
3939 Source_File_Path_Name
: constant String :=
3941 (Source_List_File
.Value
,
3945 if Source_File_Path_Name
'Length = 0 then
3946 Err_Vars
.Error_Msg_Name_1
:= Source_List_File
.Value
;
3949 "file with sources { does not exist",
3950 Source_List_File
.Location
);
3953 Get_Sources_From_File
3954 (Source_File_Path_Name
,
3955 Source_List_File
.Location
);
3960 -- Neither Source_Files nor Source_List_File has been
3961 -- specified. Find all the files that satisfy the naming
3962 -- scheme in all the source directories.
3965 (Project
, Data
, Ada_Language_Index
, Follow_Links
);
3968 -- If there are sources that are locally removed, mark them as
3969 -- such in the Units table.
3971 if not Locally_Removed
.Default
then
3973 -- Sources can be locally removed only in extending
3976 if Data
.Extends
= No_Project
then
3979 "Locally_Removed_Files can only be used " &
3980 "in an extending project file",
3981 Locally_Removed
.Location
);
3985 Current
: String_List_Id
:= Locally_Removed
.Values
;
3986 Element
: String_Element
;
3987 Location
: Source_Ptr
;
3991 Extended
: Project_Id
;
3994 while Current
/= Nil_String
loop
3995 Element
:= String_Elements
.Table
(Current
);
3996 Get_Name_String
(Element
.Value
);
3997 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
4000 -- If the element has no location, then use the
4001 -- location of Locally_Removed to report
4004 if Element
.Location
= No_Location
then
4005 Location
:= Locally_Removed
.Location
;
4007 Location
:= Element
.Location
;
4012 for Index
in 1 .. Units
.Last
loop
4013 Unit
:= Units
.Table
(Index
);
4015 if Unit
.File_Names
(Specification
).Name
= Name
then
4018 -- Check that this is from a project that
4019 -- the current project extends, but not the
4022 Extended
:= Unit
.File_Names
4023 (Specification
).Project
;
4025 if Extended
= Project
then
4028 "cannot remove a source " &
4029 "of the same project",
4033 Project_Extends
(Project
, Extended
)
4036 (Specification
).Path
:= Slash
;
4038 (Specification
).Needs_Pragma
:= False;
4039 Units
.Table
(Index
) := Unit
;
4040 Add_Forbidden_File_Name
4041 (Unit
.File_Names
(Specification
).Name
);
4047 "cannot remove a source from " &
4053 Unit
.File_Names
(Body_Part
).Name
= Name
4057 -- Check that this is from a project that
4058 -- the current project extends, but not the
4061 Extended
:= Unit
.File_Names
4062 (Body_Part
).Project
;
4064 if Extended
= Project
then
4067 "cannot remove a source " &
4068 "of the same project",
4072 Project_Extends
(Project
, Extended
)
4074 Unit
.File_Names
(Body_Part
).Path
:= Slash
;
4075 Unit
.File_Names
(Body_Part
).Needs_Pragma
4077 Units
.Table
(Index
) := Unit
;
4078 Add_Forbidden_File_Name
4079 (Unit
.File_Names
(Body_Part
).Name
);
4087 Err_Vars
.Error_Msg_Name_1
:= Name
;
4088 Error_Msg
(Project
, "unknown file {", Location
);
4091 Current
:= Element
.Next
;
4099 if Data
.Other_Sources_Present
then
4101 -- Set Source_Present to False. It will be set back to True
4102 -- whenever a source is found.
4104 Data
.Other_Sources_Present
:= False;
4105 for Lang
in Ada_Language_Index
+ 1 .. Last_Language_Index
loop
4107 -- For each language (other than Ada) in the project file
4109 if Is_Present
(Lang
, Data
) then
4111 -- Reset the indication that there are sources of this
4112 -- language. It will be set back to True whenever we find a
4113 -- source of the language.
4115 Set
(Lang
, False, Data
);
4117 -- First, get the source suffix for the language
4119 Set
(Suffix
=> Suffix_For
(Lang
, Data
.Naming
),
4120 For_Language
=> Lang
,
4121 In_Project
=> Data
);
4123 -- Then, deal with the naming exceptions, if any
4128 Naming_Exceptions
: constant Variable_Value
:=
4130 (Index
=> Language_Names
.Table
(Lang
),
4132 In_Array
=> Data
.Naming
.Implementation_Exceptions
);
4133 Element_Id
: String_List_Id
;
4134 Element
: String_Element
;
4136 Source_Found
: Boolean := False;
4139 -- If there are naming exceptions, look through them one
4142 if Naming_Exceptions
/= Nil_Variable_Value
then
4143 Element_Id
:= Naming_Exceptions
.Values
;
4145 while Element_Id
/= Nil_String
loop
4146 Element
:= String_Elements
.Table
(Element_Id
);
4147 Get_Name_String
(Element
.Value
);
4148 Canonical_Case_File_Name
4149 (Name_Buffer
(1 .. Name_Len
));
4150 File_Id
:= Name_Find
;
4152 -- Put each naming exception in the Source_Names
4153 -- hash table, but if there are repetition, don't
4154 -- bother after the first instance.
4157 Source_Names
.Get
(File_Id
) = No_Name_Location
4159 Source_Found
:= True;
4163 Location
=> Element
.Location
,
4167 Element_Id
:= Element
.Next
;
4170 -- If there is at least one naming exception, record
4171 -- those that are found in the source directories.
4173 if Source_Found
then
4174 Record_Other_Sources
4175 (Project
=> Project
,
4178 Naming_Exceptions
=> True);
4184 -- Now, check if a list of sources is declared either through
4185 -- a string list (attribute Source_Files) or a text file
4186 -- (attribute Source_List_File). If a source list is declared,
4187 -- we will consider only those naming exceptions that are
4191 Sources
: constant Variable_Value
:=
4194 Data
.Decl
.Attributes
);
4196 Source_List_File
: constant Variable_Value
:=
4198 (Name_Source_List_File
,
4199 Data
.Decl
.Attributes
);
4203 (Sources
.Kind
= List
,
4204 "Source_Files is not a list");
4207 (Source_List_File
.Kind
= Single
,
4208 "Source_List_File is not a single string");
4210 if not Sources
.Default
then
4211 if not Source_List_File
.Default
then
4214 "?both variables source_files and " &
4215 "source_list_file are present",
4216 Source_List_File
.Location
);
4219 -- Sources is a list of file names
4222 Current
: String_List_Id
:= Sources
.Values
;
4223 Element
: String_Element
;
4224 Location
: Source_Ptr
;
4230 -- Put all the sources in the Source_Names hash table
4232 while Current
/= Nil_String
loop
4233 Element
:= String_Elements
.Table
(Current
);
4234 Get_Name_String
(Element
.Value
);
4235 Canonical_Case_File_Name
4236 (Name_Buffer
(1 .. Name_Len
));
4239 -- If the element has no location, then use the
4240 -- location of Sources to report possible errors.
4242 if Element
.Location
= No_Location
then
4243 Location
:= Sources
.Location
;
4245 Location
:= Element
.Location
;
4252 Location
=> Location
,
4255 Current
:= Element
.Next
;
4258 -- And look for their directories
4260 Record_Other_Sources
4261 (Project
=> Project
,
4264 Naming_Exceptions
=> False);
4267 -- No source_files specified
4269 -- We check if Source_List_File has been specified
4271 elsif not Source_List_File
.Default
then
4273 -- Source_List_File is the name of the file
4274 -- that contains the source file names
4277 Source_File_Path_Name
: constant String :=
4279 (Source_List_File
.Value
,
4283 if Source_File_Path_Name
'Length = 0 then
4284 Err_Vars
.Error_Msg_Name_1
:=
4285 Source_List_File
.Value
;
4288 "file with sources { does not exist",
4289 Source_List_File
.Location
);
4292 -- Read the file, putting each source in the
4293 -- Source_Names hash table.
4295 Get_Sources_From_File
4296 (Source_File_Path_Name
,
4297 Source_List_File
.Location
,
4300 -- And look for their directories
4302 Record_Other_Sources
4303 (Project
=> Project
,
4306 Naming_Exceptions
=> False);
4310 -- Neither Source_Files nor Source_List_File was specified
4313 -- Find all the files that satisfy the naming scheme in
4314 -- all the source directories. All the naming exceptions
4315 -- that effectively exist are also part of the source
4316 -- of this language.
4318 Find_Sources
(Project
, Data
, Lang
);
4324 end Look_For_Sources
;
4330 function Path_Name_Of
4331 (File_Name
: Name_Id
;
4332 Directory
: Name_Id
) return String
4334 Result
: String_Access
;
4336 The_Directory
: constant String := Get_Name_String
(Directory
);
4339 Get_Name_String
(File_Name
);
4340 Result
:= Locate_Regular_File
4341 (File_Name
=> Name_Buffer
(1 .. Name_Len
),
4342 Path
=> The_Directory
);
4344 if Result
= null then
4347 Canonical_Case_File_Name
(Result
.all);
4352 -------------------------------
4353 -- Prepare_Ada_Naming_Exceptions --
4354 -------------------------------
4356 procedure Prepare_Ada_Naming_Exceptions
4357 (List
: Array_Element_Id
;
4358 Kind
: Spec_Or_Body
)
4360 Current
: Array_Element_Id
:= List
;
4361 Element
: Array_Element
;
4366 -- Traverse the list
4368 while Current
/= No_Array_Element
loop
4369 Element
:= Array_Elements
.Table
(Current
);
4371 if Element
.Index
/= No_Name
then
4374 Unit
=> Element
.Index
,
4375 Next
=> No_Ada_Naming_Exception
);
4376 Reverse_Ada_Naming_Exceptions
.Set
4377 (Unit
, (Element
.Value
.Value
, Element
.Value
.Index
));
4378 Unit
.Next
:= Ada_Naming_Exceptions
.Get
(Element
.Value
.Value
);
4379 Ada_Naming_Exception_Table
.Increment_Last
;
4380 Ada_Naming_Exception_Table
.Table
4381 (Ada_Naming_Exception_Table
.Last
) := Unit
;
4382 Ada_Naming_Exceptions
.Set
4383 (Element
.Value
.Value
, Ada_Naming_Exception_Table
.Last
);
4386 Current
:= Element
.Next
;
4388 end Prepare_Ada_Naming_Exceptions
;
4390 ---------------------
4391 -- Project_Extends --
4392 ---------------------
4394 function Project_Extends
4395 (Extending
: Project_Id
;
4396 Extended
: Project_Id
) return Boolean
4398 Current
: Project_Id
:= Extending
;
4401 if Current
= No_Project
then
4404 elsif Current
= Extended
then
4408 Current
:= Projects
.Table
(Current
).Extends
;
4410 end Project_Extends
;
4412 -----------------------
4413 -- Record_Ada_Source --
4414 -----------------------
4416 procedure Record_Ada_Source
4417 (File_Name
: Name_Id
;
4418 Path_Name
: Name_Id
;
4419 Project
: Project_Id
;
4420 Data
: in out Project_Data
;
4421 Location
: Source_Ptr
;
4422 Current_Source
: in out String_List_Id
;
4423 Source_Recorded
: in out Boolean;
4424 Follow_Links
: Boolean)
4426 Canonical_File_Name
: Name_Id
;
4427 Canonical_Path_Name
: Name_Id
;
4429 Exception_Id
: Ada_Naming_Exception_Id
;
4430 Unit_Name
: Name_Id
;
4431 Unit_Kind
: Spec_Or_Body
;
4432 Unit_Index
: Int
:= 0;
4434 Name_Index
: Name_And_Index
;
4435 Needs_Pragma
: Boolean;
4437 The_Location
: Source_Ptr
:= Location
;
4438 Previous_Source
: constant String_List_Id
:= Current_Source
;
4439 Except_Name
: Name_And_Index
:= No_Name_And_Index
;
4441 Unit_Prj
: Unit_Project
;
4443 File_Name_Recorded
: Boolean := False;
4446 Get_Name_String
(File_Name
);
4447 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
4448 Canonical_File_Name
:= Name_Find
;
4451 Canonical_Path
: constant String :=
4453 (Get_Name_String
(Path_Name
),
4454 Resolve_Links
=> Follow_Links
,
4455 Case_Sensitive
=> False);
4458 Add_Str_To_Name_Buffer
(Canonical_Path
);
4459 Canonical_Path_Name
:= Name_Find
;
4462 -- Find out the unit name, the unit kind and if it needs
4463 -- a specific SFN pragma.
4466 (Canonical_File_Name
=> Canonical_File_Name
,
4467 Naming
=> Data
.Naming
,
4468 Exception_Id
=> Exception_Id
,
4469 Unit_Name
=> Unit_Name
,
4470 Unit_Kind
=> Unit_Kind
,
4471 Needs_Pragma
=> Needs_Pragma
);
4473 if Exception_Id
= No_Ada_Naming_Exception
and then
4476 if Current_Verbosity
= High
then
4478 Write_Str
(Get_Name_String
(Canonical_File_Name
));
4479 Write_Line
(""" is not a valid source file name (ignored).");
4483 -- Check to see if the source has been hidden by an exception,
4484 -- but only if it is not an exception.
4486 if not Needs_Pragma
then
4488 Reverse_Ada_Naming_Exceptions
.Get
4489 ((Unit_Kind
, Unit_Name
, No_Ada_Naming_Exception
));
4491 if Except_Name
/= No_Name_And_Index
then
4492 if Current_Verbosity
= High
then
4494 Write_Str
(Get_Name_String
(Canonical_File_Name
));
4495 Write_Str
(""" contains a unit that is found in """);
4496 Write_Str
(Get_Name_String
(Except_Name
.Name
));
4497 Write_Line
(""" (ignored).");
4500 -- The file is not included in the source of the project,
4501 -- because it is hidden by the exception.
4502 -- So, there is nothing else to do.
4509 if Exception_Id
/= No_Ada_Naming_Exception
then
4510 Info
:= Ada_Naming_Exception_Table
.Table
(Exception_Id
);
4511 Exception_Id
:= Info
.Next
;
4512 Info
.Next
:= No_Ada_Naming_Exception
;
4513 Name_Index
:= Reverse_Ada_Naming_Exceptions
.Get
(Info
);
4515 Unit_Name
:= Info
.Unit
;
4516 Unit_Index
:= Name_Index
.Index
;
4517 Unit_Kind
:= Info
.Kind
;
4520 -- Put the file name in the list of sources of the project
4522 if not File_Name_Recorded
then
4523 String_Elements
.Increment_Last
;
4524 String_Elements
.Table
(String_Elements
.Last
) :=
4525 (Value
=> Canonical_File_Name
,
4526 Display_Value
=> File_Name
,
4527 Location
=> No_Location
,
4530 Index
=> Unit_Index
);
4533 if Current_Source
= Nil_String
then
4534 Data
.Sources
:= String_Elements
.Last
;
4536 String_Elements
.Table
(Current_Source
).Next
:=
4537 String_Elements
.Last
;
4540 Current_Source
:= String_Elements
.Last
;
4542 -- Put the unit in unit list
4545 The_Unit
: Unit_Id
:= Units_Htable
.Get
(Unit_Name
);
4546 The_Unit_Data
: Unit_Data
;
4549 if Current_Verbosity
= High
then
4550 Write_Str
("Putting ");
4551 Write_Str
(Get_Name_String
(Unit_Name
));
4552 Write_Line
(" in the unit list.");
4555 -- The unit is already in the list, but may be it is
4556 -- only the other unit kind (spec or body), or what is
4557 -- in the unit list is a unit of a project we are extending.
4559 if The_Unit
/= Prj
.Com
.No_Unit
then
4560 The_Unit_Data
:= Units
.Table
(The_Unit
);
4562 if The_Unit_Data
.File_Names
(Unit_Kind
).Name
= No_Name
4563 or else Project_Extends
4565 The_Unit_Data
.File_Names
(Unit_Kind
).Project
)
4567 if The_Unit_Data
.File_Names
(Unit_Kind
).Path
= Slash
then
4568 Remove_Forbidden_File_Name
4569 (The_Unit_Data
.File_Names
(Unit_Kind
).Name
);
4572 -- Record the file name in the hash table Files_Htable
4574 Unit_Prj
:= (Unit
=> The_Unit
, Project
=> Project
);
4575 Files_Htable
.Set
(Canonical_File_Name
, Unit_Prj
);
4577 The_Unit_Data
.File_Names
(Unit_Kind
) :=
4578 (Name
=> Canonical_File_Name
,
4579 Index
=> Unit_Index
,
4580 Display_Name
=> File_Name
,
4581 Path
=> Canonical_Path_Name
,
4582 Display_Path
=> Path_Name
,
4584 Needs_Pragma
=> Needs_Pragma
);
4585 Units
.Table
(The_Unit
) := The_Unit_Data
;
4586 Source_Recorded
:= True;
4588 elsif The_Unit_Data
.File_Names
(Unit_Kind
).Project
= Project
4589 and then (Data
.Known_Order_Of_Source_Dirs
or else
4590 The_Unit_Data
.File_Names
(Unit_Kind
).Path
=
4591 Canonical_Path_Name
)
4593 if Previous_Source
= Nil_String
then
4594 Data
.Sources
:= Nil_String
;
4596 String_Elements
.Table
(Previous_Source
).Next
:=
4598 String_Elements
.Decrement_Last
;
4601 Current_Source
:= Previous_Source
;
4604 -- It is an error to have two units with the same name
4605 -- and the same kind (spec or body).
4607 if The_Location
= No_Location
then
4608 The_Location
:= Projects
.Table
(Project
).Location
;
4611 Err_Vars
.Error_Msg_Name_1
:= Unit_Name
;
4612 Error_Msg
(Project
, "duplicate source {", The_Location
);
4614 Err_Vars
.Error_Msg_Name_1
:=
4616 (The_Unit_Data
.File_Names
(Unit_Kind
).Project
).Name
;
4617 Err_Vars
.Error_Msg_Name_2
:=
4618 The_Unit_Data
.File_Names
(Unit_Kind
).Path
;
4620 (Project
, "\ project file {, {", The_Location
);
4622 Err_Vars
.Error_Msg_Name_1
:=
4623 Projects
.Table
(Project
).Name
;
4624 Err_Vars
.Error_Msg_Name_2
:= Canonical_Path_Name
;
4626 (Project
, "\ project file {, {", The_Location
);
4629 -- It is a new unit, create a new record
4632 -- First, check if there is no other unit with this file
4633 -- name in another project. If it is, report an error.
4634 -- Of course, we do that only for the first unit in the
4637 Unit_Prj
:= Files_Htable
.Get
(Canonical_File_Name
);
4639 if not File_Name_Recorded
and then
4640 Unit_Prj
/= No_Unit_Project
4642 Error_Msg_Name_1
:= File_Name
;
4644 Projects
.Table
(Unit_Prj
.Project
).Name
;
4647 "{ is already a source of project {",
4651 Units
.Increment_Last
;
4652 The_Unit
:= Units
.Last
;
4653 Units_Htable
.Set
(Unit_Name
, The_Unit
);
4654 Unit_Prj
:= (Unit
=> The_Unit
, Project
=> Project
);
4655 Files_Htable
.Set
(Canonical_File_Name
, Unit_Prj
);
4656 The_Unit_Data
.Name
:= Unit_Name
;
4657 The_Unit_Data
.File_Names
(Unit_Kind
) :=
4658 (Name
=> Canonical_File_Name
,
4659 Index
=> Unit_Index
,
4660 Display_Name
=> File_Name
,
4661 Path
=> Canonical_Path_Name
,
4662 Display_Path
=> Path_Name
,
4664 Needs_Pragma
=> Needs_Pragma
);
4665 Units
.Table
(The_Unit
) := The_Unit_Data
;
4666 Source_Recorded
:= True;
4671 exit when Exception_Id
= No_Ada_Naming_Exception
;
4672 File_Name_Recorded
:= True;
4675 end Record_Ada_Source
;
4677 --------------------------
4678 -- Record_Other_Sources --
4679 --------------------------
4681 procedure Record_Other_Sources
4682 (Project
: Project_Id
;
4683 Data
: in out Project_Data
;
4684 Language
: Language_Index
;
4685 Naming_Exceptions
: Boolean)
4687 Source_Dir
: String_List_Id
:= Data
.Source_Dirs
;
4688 Element
: String_Element
;
4692 Canonical_Name
: Name_Id
;
4694 Name_Str
: String (1 .. 1_024
);
4695 Last
: Natural := 0;
4698 First_Error
: Boolean := True;
4700 Suffix
: constant String := Body_Suffix_Of
(Language
, Data
);
4703 while Source_Dir
/= Nil_String
loop
4704 Element
:= String_Elements
.Table
(Source_Dir
);
4707 Dir_Path
: constant String := Get_Name_String
(Element
.Value
);
4710 if Current_Verbosity
= High
then
4711 Write_Str
("checking directory """);
4712 Write_Str
(Dir_Path
);
4713 Write_Str
(""" for ");
4715 if Naming_Exceptions
then
4716 Write_Str
("naming exceptions");
4719 Write_Str
("sources");
4722 Write_Str
(" of Language ");
4723 Display_Language_Name
(Language
);
4726 Open
(Dir
, Dir_Path
);
4729 Read
(Dir
, Name_Str
, Last
);
4733 (Dir_Path
& Directory_Separator
& Name_Str
(1 .. Last
))
4736 Name_Buffer
(1 .. Name_Len
) := Name_Str
(1 .. Last
);
4737 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
4738 Canonical_Name
:= Name_Find
;
4739 NL
:= Source_Names
.Get
(Canonical_Name
);
4741 if NL
/= No_Name_Location
then
4743 if not Data
.Known_Order_Of_Source_Dirs
then
4744 Error_Msg_Name_1
:= Canonical_Name
;
4747 "{ is found in several source directories",
4753 Source_Names
.Set
(Canonical_Name
, NL
);
4754 Name_Len
:= Dir_Path
'Length;
4755 Name_Buffer
(1 .. Name_Len
) := Dir_Path
;
4756 Add_Char_To_Name_Buffer
(Directory_Separator
);
4757 Add_Str_To_Name_Buffer
(Name_Str
(1 .. Last
));
4761 (File_Name
=> Canonical_Name
,
4765 Location
=> NL
.Location
,
4766 Language
=> Language
,
4768 Naming_Exception
=> Naming_Exceptions
);
4777 Source_Dir
:= Element
.Next
;
4780 if not Naming_Exceptions
then
4781 NL
:= Source_Names
.Get_First
;
4783 -- It is an error if a source file name in a source list or
4784 -- in a source list file is not found.
4786 while NL
/= No_Name_Location
loop
4787 if not NL
.Found
then
4788 Err_Vars
.Error_Msg_Name_1
:= NL
.Name
;
4793 "source file { cannot be found",
4795 First_Error
:= False;
4800 "\source file { cannot be found",
4805 NL
:= Source_Names
.Get_Next
;
4808 -- Any naming exception of this language that is not in a list
4809 -- of sources must be removed.
4812 Source_Id
: Other_Source_Id
:= Data
.First_Other_Source
;
4813 Prev_Id
: Other_Source_Id
:= No_Other_Source
;
4814 Source
: Other_Source
;
4817 while Source_Id
/= No_Other_Source
loop
4818 Source
:= Other_Sources
.Table
(Source_Id
);
4820 if Source
.Language
= Language
4821 and then Source
.Naming_Exception
4823 if Current_Verbosity
= High
then
4824 Write_Str
("Naming exception """);
4825 Write_Str
(Get_Name_String
(Source
.File_Name
));
4826 Write_Str
(""" is not in the list of sources,");
4827 Write_Line
(" so it is removed.");
4830 if Prev_Id
= No_Other_Source
then
4831 Data
.First_Other_Source
:= Source
.Next
;
4834 Other_Sources
.Table
(Prev_Id
).Next
:= Source
.Next
;
4837 Source_Id
:= Source
.Next
;
4839 if Source_Id
= No_Other_Source
then
4840 Data
.Last_Other_Source
:= Prev_Id
;
4844 Prev_Id
:= Source_Id
;
4845 Source_Id
:= Source
.Next
;
4850 end Record_Other_Sources
;
4852 ----------------------
4853 -- Show_Source_Dirs --
4854 ----------------------
4856 procedure Show_Source_Dirs
(Project
: Project_Id
) is
4857 Current
: String_List_Id
:= Projects
.Table
(Project
).Source_Dirs
;
4858 Element
: String_Element
;
4861 Write_Line
("Source_Dirs:");
4863 while Current
/= Nil_String
loop
4864 Element
:= String_Elements
.Table
(Current
);
4866 Write_Line
(Get_Name_String
(Element
.Value
));
4867 Current
:= Element
.Next
;
4870 Write_Line
("end Source_Dirs.");
4871 end Show_Source_Dirs
;
4878 (Language
: Language_Index
;
4879 Naming
: Naming_Data
) return Name_Id
4881 Suffix
: constant Variable_Value
:=
4883 (Index
=> Language_Names
.Table
(Language
),
4885 In_Array
=> Naming
.Body_Suffix
);
4887 -- If no suffix for this language in package Naming, use the default
4889 if Suffix
= Nil_Variable_Value
then
4893 when Ada_Language_Index
=>
4894 Add_Str_To_Name_Buffer
(".adb");
4896 when C_Language_Index
=>
4897 Add_Str_To_Name_Buffer
(".c");
4899 when C_Plus_Plus_Language_Index
=>
4900 Add_Str_To_Name_Buffer
(".cc");
4906 -- Otherwise use the one specified
4909 Get_Name_String
(Suffix
.Value
);
4912 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
4916 -------------------------
4917 -- Warn_If_Not_Sources --
4918 -------------------------
4920 -- comments needed in this body ???
4922 procedure Warn_If_Not_Sources
4923 (Project
: Project_Id
;
4924 Conventions
: Array_Element_Id
;
4926 Extending
: Boolean)
4928 Conv
: Array_Element_Id
:= Conventions
;
4930 The_Unit_Id
: Unit_Id
;
4931 The_Unit_Data
: Unit_Data
;
4932 Location
: Source_Ptr
;
4935 while Conv
/= No_Array_Element
loop
4936 Unit
:= Array_Elements
.Table
(Conv
).Index
;
4937 Error_Msg_Name_1
:= Unit
;
4938 Get_Name_String
(Unit
);
4939 To_Lower
(Name_Buffer
(1 .. Name_Len
));
4941 The_Unit_Id
:= Units_Htable
.Get
(Unit
);
4942 Location
:= Array_Elements
.Table
(Conv
).Value
.Location
;
4944 if The_Unit_Id
= Prj
.Com
.No_Unit
then
4951 The_Unit_Data
:= Units
.Table
(The_Unit_Id
);
4954 if not Check_Project
4955 (The_Unit_Data
.File_Names
(Specification
).Project
,
4960 "?unit{ has no spec in this project",
4965 if not Check_Project
4966 (The_Unit_Data
.File_Names
(Com
.Body_Part
).Project
,
4971 "?unit{ has no body in this project",
4977 Conv
:= Array_Elements
.Table
(Conv
).Next
;
4979 end Warn_If_Not_Sources
;