1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2000-2003 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 Types
; use Types
;
43 with Ada
.Characters
.Handling
; use Ada
.Characters
.Handling
;
44 with Ada
.Strings
; use Ada
.Strings
;
45 with Ada
.Strings
.Fixed
; use Ada
.Strings
.Fixed
;
46 with Ada
.Strings
.Maps
.Constants
; use Ada
.Strings
.Maps
.Constants
;
48 with GNAT
.Case_Util
; use GNAT
.Case_Util
;
49 with GNAT
.Directory_Operations
; use GNAT
.Directory_Operations
;
50 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
53 package body Prj
.Nmsc
is
55 Error_Report
: Put_Line_Access
:= null;
57 ALI_Suffix
: constant String := ".ali";
59 type Name_Location
is record
61 Location
: Source_Ptr
;
62 Found
: Boolean := False;
64 -- Information about file names found in string list attribute
65 -- Source_Files or in a source list file, stored in hash table
66 -- Source_Names, used by procedure
67 -- Ada_Check.Get_Path_Names_And_Record_Sources.
69 No_Name_Location
: constant Name_Location
:=
70 (Name
=> No_Name
, Location
=> No_Location
, Found
=> False);
72 package Source_Names
is new GNAT
.HTable
.Simple_HTable
73 (Header_Num
=> Header_Num
,
74 Element
=> Name_Location
,
75 No_Element
=> No_Name_Location
,
79 -- Hash table to store file names found in string list attribute
80 -- Source_Files or in a source list file, stored in hash table
81 -- Source_Names, used by procedure
82 -- Ada_Check.Get_Path_Names_And_Record_Sources.
84 package Recursive_Dirs
is new GNAT
.HTable
.Simple_HTable
85 (Header_Num
=> Header_Num
,
91 -- Hash table to store recursive source directories, to avoid looking
92 -- several times, and to avoid cycles that may be introduced by symbolic
95 function ALI_File_Name
(Source
: String) return String;
96 -- Return the ALI file name corresponding to a source.
98 procedure Check_Ada_Naming_Scheme
99 (Project
: Project_Id
;
100 Naming
: Naming_Data
);
101 -- Check that the package Naming is correct.
103 procedure Check_Ada_Name
106 -- Check that a name is a valid Ada unit name.
109 (Project
: Project_Id
;
111 Flag_Location
: Source_Ptr
);
112 -- Output an error message. If Error_Report is null, simply call
113 -- Prj.Err.Error_Msg. Otherwise, disregard Flag_Location and use
117 (Canonical_File_Name
: Name_Id
;
118 Naming
: Naming_Data
;
119 Unit_Name
: out Name_Id
;
120 Unit_Kind
: out Spec_Or_Body
;
121 Needs_Pragma
: out Boolean);
122 -- Find out, from a file name, the unit name, the unit kind and if a
123 -- specific SFN pragma is needed. If the file name corresponds to no
124 -- unit, then Unit_Name will be No_Name.
126 function Is_Illegal_Suffix
128 Dot_Replacement_Is_A_Single_Dot
: Boolean)
130 -- Returns True if the string Suffix cannot be used as
131 -- a spec suffix, a body suffix or a separate suffix.
133 procedure Record_Source
134 (File_Name
: Name_Id
;
136 Project
: Project_Id
;
137 Data
: in out Project_Data
;
138 Location
: Source_Ptr
;
139 Current_Source
: in out String_List_Id
;
140 Source_Recorded
: in out Boolean);
141 -- Put a unit in the list of units of a project, if the file name
142 -- corresponds to a valid unit name.
144 procedure Show_Source_Dirs
(Project
: Project_Id
);
145 -- List all the source directories of a project.
147 procedure Locate_Directory
151 Display
: out Name_Id
);
152 -- Locate a directory.
153 -- Returns No_Name if directory does not exist.
155 function Path_Name_Of
156 (File_Name
: Name_Id
;
159 -- Returns the path name of a (non project) file.
160 -- Returns an empty string if file cannot be found.
162 function Project_Extends
163 (Extending
: Project_Id
;
164 Extended
: Project_Id
)
166 -- Returns True if Extending is extending directly or indirectly Extended.
168 procedure Check_Naming_Scheme
169 (Data
: in out Project_Data
;
170 Project
: Project_Id
);
171 -- Check the naming scheme part of Data
173 type Unit_Info
is record
177 No_Unit
: constant Unit_Info
:= (Specification
, No_Name
);
179 package Naming_Exceptions
is new GNAT
.HTable
.Simple_HTable
180 (Header_Num
=> Header_Num
,
181 Element
=> Unit_Info
,
182 No_Element
=> No_Unit
,
187 function Hash
(Unit
: Unit_Info
) return Header_Num
;
189 package Reverse_Naming_Exceptions
is new GNAT
.HTable
.Simple_HTable
190 (Header_Num
=> Header_Num
,
192 No_Element
=> No_Name
,
196 -- A table to check if a unit with an exceptional name will hide
197 -- a source with a file name following the naming convention.
199 procedure Prepare_Naming_Exceptions
200 (List
: Array_Element_Id
;
201 Kind
: Spec_Or_Body
);
202 -- Prepare the internal hash tables used for checking naming exceptions.
203 -- Insert all elements of List in the tables.
205 procedure Free_Naming_Exceptions
;
206 -- Free the internal hash tables used for checking naming exceptions
208 function Compute_Directory_Last
(Dir
: String) return Natural;
209 -- Return the index of the last significant character in Dir. This is used
210 -- to avoid duplicates '/' at the end of directory names
212 ----------------------------
213 -- Compute_Directory_Last --
214 ----------------------------
216 function Compute_Directory_Last
(Dir
: String) return Natural is
219 and then (Dir
(Dir
'Last - 1) = Directory_Separator
220 or else Dir
(Dir
'Last - 1) = '/')
226 end Compute_Directory_Last
;
229 -------------------------------
230 -- Prepare_Naming_Exceptions --
231 -------------------------------
233 procedure Prepare_Naming_Exceptions
234 (List
: Array_Element_Id
;
237 Current
: Array_Element_Id
:= List
;
238 Element
: Array_Element
;
241 while Current
/= No_Array_Element
loop
242 Element
:= Array_Elements
.Table
(Current
);
244 if Element
.Index
/= No_Name
then
245 Naming_Exceptions
.Set
246 (Element
.Value
.Value
,
247 (Kind
=> Kind
, Unit
=> Element
.Index
));
248 Reverse_Naming_Exceptions
.Set
249 ((Kind
=> Kind
, Unit
=> Element
.Index
),
250 Element
.Value
.Value
);
253 Current
:= Element
.Next
;
255 end Prepare_Naming_Exceptions
;
261 function Hash
(Unit
: Unit_Info
) return Header_Num
is
263 return Header_Num
(Unit
.Unit
mod 2048);
266 ----------------------------
267 -- Free_Naming_Exceptions --
268 ----------------------------
270 procedure Free_Naming_Exceptions
is
272 Naming_Exceptions
.Reset
;
273 Reverse_Naming_Exceptions
.Reset
;
274 end Free_Naming_Exceptions
;
276 -------------------------
277 -- Check_Naming_Scheme --
278 -------------------------
280 procedure Check_Naming_Scheme
281 (Data
: in out Project_Data
;
282 Project
: Project_Id
)
284 Naming_Id
: constant Package_Id
:=
285 Util
.Value_Of
(Name_Naming
, Data
.Decl
.Packages
);
287 Naming
: Package_Element
;
289 procedure Check_Unit_Names
(List
: Array_Element_Id
);
290 -- Check that a list of unit names contains only valid names.
292 ----------------------
293 -- Check_Unit_Names --
294 ----------------------
296 procedure Check_Unit_Names
(List
: Array_Element_Id
) is
297 Current
: Array_Element_Id
:= List
;
298 Element
: Array_Element
;
302 -- Loop through elements of the string list
304 while Current
/= No_Array_Element
loop
305 Element
:= Array_Elements
.Table
(Current
);
307 -- Put file name in canonical case
309 Get_Name_String
(Element
.Value
.Value
);
310 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
311 Element
.Value
.Value
:= Name_Find
;
313 -- Check that it contains a valid unit name
315 Get_Name_String
(Element
.Index
);
316 Check_Ada_Name
(Name_Buffer
(1 .. Name_Len
), Unit_Name
);
318 if Unit_Name
= No_Name
then
319 Err_Vars
.Error_Msg_Name_1
:= Element
.Index
;
322 "{ is not a valid unit name.",
323 Element
.Value
.Location
);
326 if Current_Verbosity
= High
then
327 Write_Str
(" Unit (""");
328 Write_Str
(Get_Name_String
(Unit_Name
));
332 Element
.Index
:= Unit_Name
;
333 Array_Elements
.Table
(Current
) := Element
;
336 Current
:= Element
.Next
;
338 end Check_Unit_Names
;
340 -- Start of processing for Check_Naming_Scheme
343 -- If there is a package Naming, we will put in Data.Naming what is in
344 -- this package Naming.
346 if Naming_Id
/= No_Package
then
347 Naming
:= Packages
.Table
(Naming_Id
);
349 if Current_Verbosity
= High
then
350 Write_Line
("Checking ""Naming"" for Ada.");
354 Bodies
: constant Array_Element_Id
:=
355 Util
.Value_Of
(Name_Body
, Naming
.Decl
.Arrays
);
357 Specs
: constant Array_Element_Id
:=
358 Util
.Value_Of
(Name_Spec
, Naming
.Decl
.Arrays
);
361 if Bodies
/= No_Array_Element
then
363 -- We have elements in the array Body_Part
365 if Current_Verbosity
= High
then
366 Write_Line
("Found Bodies.");
369 Data
.Naming
.Bodies
:= Bodies
;
370 Check_Unit_Names
(Bodies
);
373 if Current_Verbosity
= High
then
374 Write_Line
("No Bodies.");
378 if Specs
/= No_Array_Element
then
380 -- We have elements in the array Specs
382 if Current_Verbosity
= High
then
383 Write_Line
("Found Specs.");
386 Data
.Naming
.Specs
:= Specs
;
387 Check_Unit_Names
(Specs
);
390 if Current_Verbosity
= High
then
391 Write_Line
("No Specs.");
396 -- We are now checking if variables Dot_Replacement, Casing,
397 -- Spec_Suffix, Body_Suffix and/or Separate_Suffix
400 -- For each variable, if it does not exist, we do nothing,
401 -- because we already have the default.
403 -- Check Dot_Replacement
406 Dot_Replacement
: constant Variable_Value
:=
408 (Name_Dot_Replacement
,
409 Naming
.Decl
.Attributes
);
412 pragma Assert
(Dot_Replacement
.Kind
= Single
,
413 "Dot_Replacement is not a single string");
415 if not Dot_Replacement
.Default
then
416 Get_Name_String
(Dot_Replacement
.Value
);
421 "Dot_Replacement cannot be empty",
422 Dot_Replacement
.Location
);
425 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
426 Data
.Naming
.Dot_Replacement
:= Name_Find
;
427 Data
.Naming
.Dot_Repl_Loc
:= Dot_Replacement
.Location
;
432 if Current_Verbosity
= High
then
433 Write_Str
(" Dot_Replacement = """);
434 Write_Str
(Get_Name_String
(Data
.Naming
.Dot_Replacement
));
442 Casing_String
: constant Variable_Value
:=
444 (Name_Casing
, Naming
.Decl
.Attributes
);
447 pragma Assert
(Casing_String
.Kind
= Single
,
448 "Casing is not a single string");
450 if not Casing_String
.Default
then
452 Casing_Image
: constant String :=
453 Get_Name_String
(Casing_String
.Value
);
456 Casing
: constant Casing_Type
:= Value
(Casing_Image
);
458 Data
.Naming
.Casing
:= Casing
;
462 when Constraint_Error
=>
463 if Casing_Image
'Length = 0 then
466 "Casing cannot be an empty string",
467 Casing_String
.Location
);
470 Name_Len
:= Casing_Image
'Length;
471 Name_Buffer
(1 .. Name_Len
) := Casing_Image
;
472 Err_Vars
.Error_Msg_Name_1
:= Name_Find
;
475 "{ is not a correct Casing",
476 Casing_String
.Location
);
482 if Current_Verbosity
= High
then
483 Write_Str
(" Casing = ");
484 Write_Str
(Image
(Data
.Naming
.Casing
));
492 Ada_Spec_Suffix
: constant Variable_Value
:=
495 In_Array
=> Data
.Naming
.Spec_Suffix
);
498 if Ada_Spec_Suffix
.Kind
= Single
499 and then Get_Name_String
(Ada_Spec_Suffix
.Value
) /= ""
501 Data
.Naming
.Current_Spec_Suffix
:= Ada_Spec_Suffix
.Value
;
502 Data
.Naming
.Spec_Suffix_Loc
:= Ada_Spec_Suffix
.Location
;
505 Data
.Naming
.Current_Spec_Suffix
:= Default_Ada_Spec_Suffix
;
509 if Current_Verbosity
= High
then
510 Write_Str
(" Spec_Suffix = """);
511 Write_Str
(Get_Name_String
(Data
.Naming
.Current_Spec_Suffix
));
519 Ada_Body_Suffix
: constant Variable_Value
:=
522 In_Array
=> Data
.Naming
.Body_Suffix
);
525 if Ada_Body_Suffix
.Kind
= Single
526 and then Get_Name_String
(Ada_Body_Suffix
.Value
) /= ""
528 Data
.Naming
.Current_Body_Suffix
:= Ada_Body_Suffix
.Value
;
529 Data
.Naming
.Body_Suffix_Loc
:= Ada_Body_Suffix
.Location
;
532 Data
.Naming
.Current_Body_Suffix
:= Default_Ada_Body_Suffix
;
536 if Current_Verbosity
= High
then
537 Write_Str
(" Body_Suffix = """);
538 Write_Str
(Get_Name_String
(Data
.Naming
.Current_Body_Suffix
));
543 -- Check Separate_Suffix
546 Ada_Sep_Suffix
: constant Variable_Value
:=
548 (Variable_Name
=> Name_Separate_Suffix
,
549 In_Variables
=> Naming
.Decl
.Attributes
);
552 if Ada_Sep_Suffix
.Default
then
553 Data
.Naming
.Separate_Suffix
:=
554 Data
.Naming
.Current_Body_Suffix
;
557 if Get_Name_String
(Ada_Sep_Suffix
.Value
) = "" then
560 "Separate_Suffix cannot be empty",
561 Ada_Sep_Suffix
.Location
);
564 Data
.Naming
.Separate_Suffix
:= Ada_Sep_Suffix
.Value
;
565 Data
.Naming
.Sep_Suffix_Loc
:= Ada_Sep_Suffix
.Location
;
570 if Current_Verbosity
= High
then
571 Write_Str
(" Separate_Suffix = """);
572 Write_Str
(Get_Name_String
(Data
.Naming
.Separate_Suffix
));
577 -- Check if Data.Naming is valid
579 Check_Ada_Naming_Scheme
(Project
, Data
.Naming
);
582 Data
.Naming
.Current_Spec_Suffix
:= Default_Ada_Spec_Suffix
;
583 Data
.Naming
.Current_Body_Suffix
:= Default_Ada_Body_Suffix
;
584 Data
.Naming
.Separate_Suffix
:= Default_Ada_Body_Suffix
;
586 end Check_Naming_Scheme
;
593 (Project
: Project_Id
;
594 Report_Error
: Put_Line_Access
)
597 Languages
: Variable_Value
:= Nil_Variable_Value
;
599 Extending
: Boolean := False;
601 function Check_Project
(P
: Project_Id
) return Boolean;
602 -- Returns True if P is Project or a project extended by Project
604 procedure Find_Sources
;
605 -- Find all the sources in all of the source directories
608 procedure Get_Path_Names_And_Record_Sources
;
609 -- Find the path names of the source files in the Source_Names table
610 -- in the source directories and record those that are Ada sources.
612 procedure Get_Sources_From_File
614 Location
: Source_Ptr
);
615 -- Get the sources of a project from a text file
617 procedure Warn_If_Not_Sources
618 (Conventions
: Array_Element_Id
;
620 -- Check that individual naming conventions apply to immediate
621 -- sources of the project; if not, issue a warning.
627 function Check_Project
(P
: Project_Id
) return Boolean is
633 Data
: Project_Data
:= Projects
.Table
(Project
);
636 while Data
.Extends
/= No_Project
loop
637 if P
= Data
.Extends
then
641 Data
:= Projects
.Table
(Data
.Extends
);
653 procedure Find_Sources
is
654 Source_Dir
: String_List_Id
:= Data
.Source_Dirs
;
655 Element
: String_Element
;
657 Current_Source
: String_List_Id
:= Nil_String
;
658 Source_Recorded
: Boolean := False;
661 if Current_Verbosity
= High
then
662 Write_Line
("Looking for sources:");
665 -- For each subdirectory
667 while Source_Dir
/= Nil_String
loop
669 Source_Recorded
:= False;
670 Element
:= String_Elements
.Table
(Source_Dir
);
671 if Element
.Value
/= No_Name
then
673 Source_Directory
: constant String :=
674 Get_Name_String
(Element
.Value
);
677 if Current_Verbosity
= High
then
678 Write_Str
("Source_Dir = ");
679 Write_Line
(Source_Directory
);
682 -- We look to every entry in the source directory
684 Open
(Dir
, Source_Directory
);
686 -- Canonical_Case_File_Name (Source_Directory);
689 Read
(Dir
, Name_Buffer
, Name_Len
);
691 if Current_Verbosity
= High
then
692 Write_Str
(" Checking ");
693 Write_Line
(Name_Buffer
(1 .. Name_Len
));
696 exit when Name_Len
= 0;
698 -- Canonical_Case_File_Name
699 -- (Name_Buffer (1 .. Name_Len));
702 File_Name
: constant Name_Id
:= Name_Find
;
703 Dir
: constant String :=
706 Dir_Last
: constant Natural :=
707 Compute_Directory_Last
(Dir
);
708 Path
: constant String :=
710 (Name
=> Name_Buffer
(1 .. Name_Len
),
711 Directory
=> Dir
(Dir
'First .. Dir_Last
));
715 if Is_Regular_File
(Path
) then
717 Name_Len
:= Path
'Length;
718 Name_Buffer
(1 .. Name_Len
) := Path
;
719 Path_Name
:= Name_Find
;
721 -- We attempt to register it as a source.
722 -- However, there is no error if the file
723 -- does not contain a valid source.
724 -- But there is an error if we have a
725 -- duplicate unit name.
728 (File_Name
=> File_Name
,
729 Path_Name
=> Path_Name
,
732 Location
=> No_Location
,
733 Current_Source
=> Current_Source
,
734 Source_Recorded
=> Source_Recorded
);
744 when Directory_Error
=>
748 if Source_Recorded
then
749 String_Elements
.Table
(Source_Dir
).Flag
:= True;
752 Source_Dir
:= Element
.Next
;
755 if Current_Verbosity
= High
then
756 Write_Line
("end Looking for sources.");
759 -- If we have looked for sources and found none, then
760 -- it is an error, except if it is an extending project.
761 -- If a non extending project is not supposed to contain
762 -- any source, then we never call Find_Sources.
764 if Data
.Extends
= No_Project
765 and then Current_Source
= Nil_String
769 "there are no Ada sources in this project",
774 ---------------------------------------
775 -- Get_Path_Names_And_Record_Sources --
776 ---------------------------------------
778 procedure Get_Path_Names_And_Record_Sources
is
779 Source_Dir
: String_List_Id
:= Data
.Source_Dirs
;
780 Element
: String_Element
;
785 Canonical_Name
: Name_Id
;
786 Name_Str
: String (1 .. 1_024
);
790 Current_Source
: String_List_Id
:= Nil_String
;
792 First_Error
: Boolean := True;
794 Source_Recorded
: Boolean := False;
797 -- We look in all source directories for this file name
799 while Source_Dir
/= Nil_String
loop
800 Source_Recorded
:= False;
801 Element
:= String_Elements
.Table
(Source_Dir
);
804 Dir_Path
: constant String := Get_Name_String
(Element
.Value
);
806 if Current_Verbosity
= High
then
807 Write_Str
("checking directory """);
808 Write_Str
(Dir_Path
);
812 Open
(Dir
, Dir_Path
);
815 Read
(Dir
, Name_Str
, Last
);
818 Name_Buffer
(1 .. Name_Len
) := Name_Str
(1 .. Last
);
820 Canonical_Case_File_Name
(Name_Str
(1 .. Last
));
822 Name_Buffer
(1 .. Name_Len
) := Name_Str
(1 .. Last
);
823 Canonical_Name
:= Name_Find
;
824 NL
:= Source_Names
.Get
(Canonical_Name
);
826 if NL
/= No_Name_Location
and then not NL
.Found
then
828 Source_Names
.Set
(Canonical_Name
, NL
);
829 Name_Len
:= Dir_Path
'Length;
830 Name_Buffer
(1 .. Name_Len
) := Dir_Path
;
831 Add_Char_To_Name_Buffer
(Directory_Separator
);
832 Add_Str_To_Name_Buffer
(Name_Str
(1 .. Last
));
835 if Current_Verbosity
= High
then
836 Write_Str
(" found ");
837 Write_Line
(Get_Name_String
(Name
));
840 -- Register the source if it is an Ada compilation unit..
847 Location
=> NL
.Location
,
848 Current_Source
=> Current_Source
,
849 Source_Recorded
=> Source_Recorded
);
856 if Source_Recorded
then
857 String_Elements
.Table
(Source_Dir
).Flag
:= True;
860 Source_Dir
:= Element
.Next
;
863 -- It is an error if a source file name in a source list or
864 -- in a source list file is not found.
866 NL
:= Source_Names
.Get_First
;
868 while NL
/= No_Name_Location
loop
870 Err_Vars
.Error_Msg_Name_1
:= NL
.Name
;
875 "source file { cannot be found",
877 First_Error
:= False;
882 "\source file { cannot be found",
887 NL
:= Source_Names
.Get_Next
;
889 end Get_Path_Names_And_Record_Sources
;
891 ---------------------------
892 -- Get_Sources_From_File --
893 ---------------------------
895 procedure Get_Sources_From_File
897 Location
: Source_Ptr
)
899 File
: Prj
.Util
.Text_File
;
900 Line
: String (1 .. 250);
902 Source_Name
: Name_Id
;
905 if Current_Verbosity
= High
then
906 Write_Str
("Opening """);
913 Prj
.Util
.Open
(File
, Path
);
915 if not Prj
.Util
.Is_Valid
(File
) then
916 Error_Msg
(Project
, "file does not exist", Location
);
920 while not Prj
.Util
.End_Of_File
(File
) loop
921 Prj
.Util
.Get_Line
(File
, Line
, Last
);
923 -- If the line is not empty and does not start with "--",
924 -- then it should contain a file name. However, if the
925 -- file name does not exist, it may be for another language
926 -- and we don't fail.
929 and then (Last
= 1 or else Line
(1 .. 2) /= "--")
932 Name_Buffer
(1 .. Name_Len
) := Line
(1 .. Last
);
933 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
934 Source_Name
:= Name_Find
;
938 (Name
=> Source_Name
,
939 Location
=> Location
,
944 Prj
.Util
.Close
(File
);
948 Get_Path_Names_And_Record_Sources
;
950 -- We should have found at least one source.
951 -- If not, report an error.
953 if Data
.Sources
= Nil_String
then
955 "there are no Ada sources in this project",
958 end Get_Sources_From_File
;
960 -------------------------
961 -- Warn_If_Not_Sources --
962 -------------------------
964 procedure Warn_If_Not_Sources
965 (Conventions
: Array_Element_Id
;
968 Conv
: Array_Element_Id
:= Conventions
;
970 The_Unit_Id
: Unit_Id
;
971 The_Unit_Data
: Unit_Data
;
972 Location
: Source_Ptr
;
975 while Conv
/= No_Array_Element
loop
976 Unit
:= Array_Elements
.Table
(Conv
).Index
;
977 Error_Msg_Name_1
:= Unit
;
978 Get_Name_String
(Unit
);
979 To_Lower
(Name_Buffer
(1 .. Name_Len
));
981 The_Unit_Id
:= Units_Htable
.Get
(Unit
);
982 Location
:= Array_Elements
.Table
(Conv
).Value
.Location
;
984 if The_Unit_Id
= Prj
.Com
.No_Unit
then
991 The_Unit_Data
:= Units
.Table
(The_Unit_Id
);
995 (The_Unit_Data
.File_Names
(Specification
).Project
)
999 "?unit{ has no spec in this project",
1004 if not Check_Project
1005 (The_Unit_Data
.File_Names
(Com
.Body_Part
).Project
)
1009 "?unit{ has no body in this project",
1015 Conv
:= Array_Elements
.Table
(Conv
).Next
;
1017 end Warn_If_Not_Sources
;
1019 -- Start of processing for Ada_Check
1022 Language_Independent_Check
(Project
, Report_Error
);
1024 Error_Report
:= Report_Error
;
1026 Data
:= Projects
.Table
(Project
);
1027 Extending
:= Data
.Extends
/= No_Project
;
1028 Languages
:= Prj
.Util
.Value_Of
(Name_Languages
, Data
.Decl
.Attributes
);
1030 Data
.Naming
.Current_Language
:= Name_Ada
;
1031 Data
.Sources_Present
:= Data
.Source_Dirs
/= Nil_String
;
1033 if not Languages
.Default
then
1035 Current
: String_List_Id
:= Languages
.Values
;
1036 Element
: String_Element
;
1037 Ada_Found
: Boolean := False;
1040 Look_For_Ada
: while Current
/= Nil_String
loop
1041 Element
:= String_Elements
.Table
(Current
);
1042 Get_Name_String
(Element
.Value
);
1043 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1045 if Name_Buffer
(1 .. Name_Len
) = "ada" then
1050 Current
:= Element
.Next
;
1051 end loop Look_For_Ada
;
1053 if not Ada_Found
then
1055 -- Mark the project file as having no sources for Ada
1057 Data
.Sources_Present
:= False;
1062 Check_Naming_Scheme
(Data
, Project
);
1064 Prepare_Naming_Exceptions
(Data
.Naming
.Bodies
, Body_Part
);
1065 Prepare_Naming_Exceptions
(Data
.Naming
.Specs
, Specification
);
1067 -- If we have source directories, then find the sources
1069 if Data
.Sources_Present
then
1070 if Data
.Source_Dirs
= Nil_String
then
1071 Data
.Sources_Present
:= False;
1075 Sources
: constant Variable_Value
:=
1078 Data
.Decl
.Attributes
);
1080 Source_List_File
: constant Variable_Value
:=
1082 (Name_Source_List_File
,
1083 Data
.Decl
.Attributes
);
1085 Locally_Removed
: constant Variable_Value
:=
1087 (Name_Locally_Removed_Files
,
1088 Data
.Decl
.Attributes
);
1093 (Sources
.Kind
= List
,
1094 "Source_Files is not a list");
1097 (Source_List_File
.Kind
= Single
,
1098 "Source_List_File is not a single string");
1100 if not Sources
.Default
then
1101 if not Source_List_File
.Default
then
1104 "?both variables source_files and " &
1105 "source_list_file are present",
1106 Source_List_File
.Location
);
1109 -- Sources is a list of file names
1112 Current
: String_List_Id
:= Sources
.Values
;
1113 Element
: String_Element
;
1114 Location
: Source_Ptr
;
1120 Data
.Sources_Present
:= Current
/= Nil_String
;
1122 while Current
/= Nil_String
loop
1123 Element
:= String_Elements
.Table
(Current
);
1124 Get_Name_String
(Element
.Value
);
1125 Canonical_Case_File_Name
1126 (Name_Buffer
(1 .. Name_Len
));
1129 -- If the element has no location, then use the
1130 -- location of Sources to report possible errors.
1132 if Element
.Location
= No_Location
then
1133 Location
:= Sources
.Location
;
1136 Location
:= Element
.Location
;
1143 Location
=> Location
,
1146 Current
:= Element
.Next
;
1149 Get_Path_Names_And_Record_Sources
;
1152 -- No source_files specified.
1153 -- We check Source_List_File has been specified.
1155 elsif not Source_List_File
.Default
then
1157 -- Source_List_File is the name of the file
1158 -- that contains the source file names
1161 Source_File_Path_Name
: constant String :=
1163 (Source_List_File
.Value
,
1167 if Source_File_Path_Name
'Length = 0 then
1168 Err_Vars
.Error_Msg_Name_1
:= Source_List_File
.Value
;
1171 "file with sources { does not exist",
1172 Source_List_File
.Location
);
1175 Get_Sources_From_File
1176 (Source_File_Path_Name
,
1177 Source_List_File
.Location
);
1182 -- Neither Source_Files nor Source_List_File has been
1184 -- Find all the files that satisfy
1185 -- the naming scheme in all the source directories.
1190 -- If there are sources that are locally removed, mark them as
1191 -- such in the Units table.
1193 if not Locally_Removed
.Default
then
1194 -- Sources can be locally removed only in extending
1197 if Data
.Extends
= No_Project
then
1200 "Locally_Removed_Files can only be used " &
1201 "in an extending project file",
1202 Locally_Removed
.Location
);
1206 Current
: String_List_Id
:=
1207 Locally_Removed
.Values
;
1208 Element
: String_Element
;
1209 Location
: Source_Ptr
;
1213 Extended
: Project_Id
;
1216 while Current
/= Nil_String
loop
1217 Element
:= String_Elements
.Table
(Current
);
1218 Get_Name_String
(Element
.Value
);
1219 Canonical_Case_File_Name
1220 (Name_Buffer
(1 .. Name_Len
));
1223 -- If the element has no location, then use the
1224 -- location of Locally_Removed to report
1227 if Element
.Location
= No_Location
then
1228 Location
:= Locally_Removed
.Location
;
1231 Location
:= Element
.Location
;
1236 for Index
in 1 .. Units
.Last
loop
1237 Unit
:= Units
.Table
(Index
);
1240 Unit
.File_Names
(Specification
).Name
= Name
1244 -- Check that this is from a project that
1245 -- the current project extends, but not the
1248 Extended
:= Unit
.File_Names
1249 (Specification
).Project
;
1251 if Extended
= Project
then
1254 "cannot remove a source " &
1255 "of the same project",
1259 Project_Extends
(Project
, Extended
)
1262 (Specification
).Path
:= Slash
;
1264 (Specification
).Needs_Pragma
:= False;
1265 Units
.Table
(Index
) := Unit
;
1266 Add_Forbidden_File_Name
1267 (Unit
.File_Names
(Specification
).Name
);
1273 "cannot remove a source from " &
1279 Unit
.File_Names
(Body_Part
).Name
= Name
1283 -- Check that this is from a project that
1284 -- the current project extends, but not the
1287 Extended
:= Unit
.File_Names
1288 (Body_Part
).Project
;
1290 if Extended
= Project
then
1293 "cannot remove a source " &
1294 "of the same project",
1298 Project_Extends
(Project
, Extended
)
1300 Unit
.File_Names
(Body_Part
).Path
:= Slash
;
1301 Unit
.File_Names
(Body_Part
).Needs_Pragma
1303 Units
.Table
(Index
) := Unit
;
1304 Add_Forbidden_File_Name
1305 (Unit
.File_Names
(Body_Part
).Name
);
1313 Err_Vars
.Error_Msg_Name_1
:= Name
;
1314 Error_Msg
(Project
, "unknown file {", Location
);
1317 Current
:= Element
.Next
;
1326 if Data
.Sources_Present
then
1328 -- Check that all individual naming conventions apply to
1329 -- sources of this project file.
1331 Warn_If_Not_Sources
(Data
.Naming
.Bodies
, Specs
=> False);
1332 Warn_If_Not_Sources
(Data
.Naming
.Specs
, Specs
=> True);
1335 -- If it is a library project file, check if it is a standalone library
1337 if Data
.Library
then
1338 Standalone_Library
: declare
1339 Lib_Interfaces
: constant Prj
.Variable_Value
:=
1341 (Snames
.Name_Library_Interface
,
1342 Data
.Decl
.Attributes
);
1343 Lib_Auto_Init
: constant Prj
.Variable_Value
:=
1345 (Snames
.Name_Library_Auto_Init
,
1346 Data
.Decl
.Attributes
);
1348 Lib_Src_Dir
: constant Prj
.Variable_Value
:=
1350 (Snames
.Name_Library_Src_Dir
,
1351 Data
.Decl
.Attributes
);
1353 Lib_Symbol_File
: constant Prj
.Variable_Value
:=
1355 (Snames
.Name_Library_Symbol_File
,
1356 Data
.Decl
.Attributes
);
1358 Lib_Symbol_Policy
: constant Prj
.Variable_Value
:=
1360 (Snames
.Name_Library_Symbol_Policy
,
1361 Data
.Decl
.Attributes
);
1363 Lib_Ref_Symbol_File
: constant Prj
.Variable_Value
:=
1365 (Snames
.Name_Library_Reference_Symbol_File
,
1366 Data
.Decl
.Attributes
);
1368 Auto_Init_Supported
: constant Boolean :=
1370 Standalone_Library_Auto_Init_Is_Supported
;
1372 OK
: Boolean := True;
1375 pragma Assert
(Lib_Interfaces
.Kind
= List
);
1377 -- It is a stand-alone library project file if attribute
1378 -- Library_Interface is defined.
1380 if not Lib_Interfaces
.Default
then
1382 Interfaces
: String_List_Id
:= Lib_Interfaces
.Values
;
1383 Interface_ALIs
: String_List_Id
:= Nil_String
;
1385 The_Unit_Id
: Unit_Id
;
1386 The_Unit_Data
: Unit_Data
;
1388 procedure Add_ALI_For
(Source
: Name_Id
);
1389 -- Add an ALI file name to the list of Interface ALIs
1395 procedure Add_ALI_For
(Source
: Name_Id
) is
1397 Get_Name_String
(Source
);
1400 ALI
: constant String :=
1401 ALI_File_Name
(Name_Buffer
(1 .. Name_Len
));
1402 ALI_Name_Id
: Name_Id
;
1404 Name_Len
:= ALI
'Length;
1405 Name_Buffer
(1 .. Name_Len
) := ALI
;
1406 ALI_Name_Id
:= Name_Find
;
1408 String_Elements
.Increment_Last
;
1409 String_Elements
.Table
(String_Elements
.Last
) :=
1410 (Value
=> ALI_Name_Id
,
1411 Display_Value
=> No_Name
,
1412 Location
=> String_Elements
.Table
1413 (Interfaces
).Location
,
1415 Next
=> Interface_ALIs
);
1416 Interface_ALIs
:= String_Elements
.Last
;
1421 Data
.Standalone_Library
:= True;
1423 -- Library_Interface cannot be an empty list
1425 if Interfaces
= Nil_String
then
1428 "Library_Interface cannot be an empty list",
1429 Lib_Interfaces
.Location
);
1432 -- Process each unit name specified in the attribute
1433 -- Library_Interface.
1435 while Interfaces
/= Nil_String
loop
1437 (String_Elements
.Table
(Interfaces
).Value
);
1438 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1440 if Name_Len
= 0 then
1443 "an interface cannot be an empty string",
1444 String_Elements
.Table
(Interfaces
).Location
);
1448 Error_Msg_Name_1
:= Unit
;
1449 The_Unit_Id
:= Units_Htable
.Get
(Unit
);
1451 if The_Unit_Id
= Prj
.Com
.No_Unit
then
1455 String_Elements
.Table
(Interfaces
).Location
);
1458 -- Check that the unit is part of the project
1460 The_Unit_Data
:= Units
.Table
(The_Unit_Id
);
1462 if The_Unit_Data
.File_Names
1463 (Com
.Body_Part
).Name
/= No_Name
1464 and then The_Unit_Data
.File_Names
1465 (Com
.Body_Part
).Path
/= Slash
1468 (The_Unit_Data
.File_Names
(Body_Part
).Project
)
1470 -- There is a body for this unit.
1471 -- If there is no spec, we need to check
1472 -- that it is not a subunit.
1474 if The_Unit_Data
.File_Names
1475 (Specification
).Name
= No_Name
1478 Src_Ind
: Source_File_Index
;
1481 Src_Ind
:= Sinput
.P
.Load_Project_File
1483 (The_Unit_Data
.File_Names
1486 if Sinput
.P
.Source_File_Is_Subunit
1491 "{ is a subunit; " &
1492 "it cannot be an interface",
1493 String_Elements
.Table
1494 (Interfaces
).Location
);
1499 -- The unit is not a subunit, so we add
1500 -- to the Interface ALIs the ALI file
1501 -- corresponding to the body.
1504 (The_Unit_Data
.File_Names
(Body_Part
).Name
);
1509 "{ is not an unit of this project",
1510 String_Elements
.Table
1511 (Interfaces
).Location
);
1514 elsif The_Unit_Data
.File_Names
1515 (Com
.Specification
).Name
/= No_Name
1516 and then The_Unit_Data
.File_Names
1517 (Com
.Specification
).Path
/= Slash
1518 and then Check_Project
1519 (The_Unit_Data
.File_Names
1520 (Specification
).Project
)
1523 -- The unit is part of the project, it has
1524 -- a spec, but no body. We add to the Interface
1525 -- ALIs the ALI file corresponding to the spec.
1528 (The_Unit_Data
.File_Names
(Specification
).Name
);
1533 "{ is not an unit of this project",
1534 String_Elements
.Table
(Interfaces
).Location
);
1540 Interfaces
:= String_Elements
.Table
(Interfaces
).Next
;
1543 -- Put the list of Interface ALIs in the project data
1545 Data
.Lib_Interface_ALIs
:= Interface_ALIs
;
1547 -- Check value of attribute Library_Auto_Init and set
1548 -- Lib_Auto_Init accordingly.
1550 if Lib_Auto_Init
.Default
then
1551 -- If no attribute Library_Auto_Init is declared, then
1552 -- set auto init only if it is supported.
1554 Data
.Lib_Auto_Init
:= Auto_Init_Supported
;
1557 Get_Name_String
(Lib_Auto_Init
.Value
);
1558 To_Lower
(Name_Buffer
(1 .. Name_Len
));
1560 if Name_Buffer
(1 .. Name_Len
) = "false" then
1561 Data
.Lib_Auto_Init
:= False;
1563 elsif Name_Buffer
(1 .. Name_Len
) = "true" then
1564 if Auto_Init_Supported
then
1565 Data
.Lib_Auto_Init
:= True;
1568 -- Library_Auto_Init cannot be "true" if auto init
1573 "library auto init not supported " &
1575 Lib_Auto_Init
.Location
);
1581 "invalid value for attribute Library_Auto_Init",
1582 Lib_Auto_Init
.Location
);
1587 -- If attribute Library_Src_Dir is defined and not the
1588 -- empty string, check if the directory exist and is not
1589 -- the object directory or one of the source directories.
1590 -- This is the directory where copies of the interface
1591 -- sources will be copied. Note that this directory may be
1592 -- the library directory.
1594 if Lib_Src_Dir
.Value
/= Empty_String
then
1596 Dir_Id
: constant Name_Id
:= Lib_Src_Dir
.Value
;
1600 (Dir_Id
, Data
.Display_Directory
,
1601 Data
.Library_Src_Dir
,
1602 Data
.Display_Library_Src_Dir
);
1604 -- If directory does not exist, report an error
1606 if Data
.Library_Src_Dir
= No_Name
then
1608 -- Get the absolute name of the library directory
1609 -- that does not exist, to report an error.
1612 Dir_Name
: constant String :=
1613 Get_Name_String
(Dir_Id
);
1616 if Is_Absolute_Path
(Dir_Name
) then
1617 Err_Vars
.Error_Msg_Name_1
:= Dir_Id
;
1620 Get_Name_String
(Data
.Directory
);
1622 if Name_Buffer
(Name_Len
) /=
1625 Name_Len
:= Name_Len
+ 1;
1626 Name_Buffer
(Name_Len
) :=
1627 Directory_Separator
;
1632 Name_Len
+ Dir_Name
'Length) :=
1634 Name_Len
:= Name_Len
+ Dir_Name
'Length;
1635 Err_Vars
.Error_Msg_Name_1
:= Name_Find
;
1642 "Directory { does not exist",
1643 Lib_Src_Dir
.Location
);
1646 -- Report an error if it is the same as the object
1649 elsif Data
.Library_Src_Dir
= Data
.Object_Directory
then
1652 "directory to copy interfaces cannot be " &
1653 "the object directory",
1654 Lib_Src_Dir
.Location
);
1655 Data
.Library_Src_Dir
:= No_Name
;
1657 -- Check if it is the same as one of the source
1662 Src_Dirs
: String_List_Id
:= Data
.Source_Dirs
;
1663 Src_Dir
: String_Element
;
1666 while Src_Dirs
/= Nil_String
loop
1667 Src_Dir
:= String_Elements
.Table
(Src_Dirs
);
1668 Src_Dirs
:= Src_Dir
.Next
;
1670 -- Report an error if it is one of the
1671 -- source directories.
1673 if Data
.Library_Src_Dir
= Src_Dir
.Value
then
1676 "directory to copy interfaces cannot " &
1677 "be one of the source directories",
1678 Lib_Src_Dir
.Location
);
1679 Data
.Library_Src_Dir
:= No_Name
;
1685 if Data
.Library_Src_Dir
/= No_Name
1686 and then Current_Verbosity
= High
1688 Write_Str
("Directory to copy interfaces =""");
1689 Write_Str
(Get_Name_String
(Data
.Library_Dir
));
1696 if not Lib_Symbol_File
.Default
then
1697 Data
.Symbol_Data
.Symbol_File
:= Lib_Symbol_File
.Value
;
1699 Get_Name_String
(Lib_Symbol_File
.Value
);
1701 if Name_Len
= 0 then
1704 "symbol file name cannot be an empty string",
1705 Lib_Symbol_File
.Location
);
1708 OK
:= not Is_Absolute_Path
(Name_Buffer
(1 .. Name_Len
));
1711 for J
in 1 .. Name_Len
loop
1712 if Name_Buffer
(J
) = '/'
1713 or else Name_Buffer
(J
) = Directory_Separator
1722 Error_Msg_Name_1
:= Lib_Symbol_File
.Value
;
1725 "symbol file name { is illegal. " &
1726 "Name canot include directory info.",
1727 Lib_Symbol_File
.Location
);
1732 if not Lib_Symbol_Policy
.Default
then
1734 Value
: constant String :=
1736 (Get_Name_String
(Lib_Symbol_Policy
.Value
));
1739 if Value
= "autonomous" or else Value
= "default" then
1740 Data
.Symbol_Data
.Symbol_Policy
:= Autonomous
;
1742 elsif Value
= "compliant" then
1743 Data
.Symbol_Data
.Symbol_Policy
:= Compliant
;
1745 elsif Value
= "controlled" then
1746 Data
.Symbol_Data
.Symbol_Policy
:= Controlled
;
1751 "illegal value for Library_Symbol_Policy",
1752 Lib_Symbol_Policy
.Location
);
1757 if Lib_Ref_Symbol_File
.Default
then
1758 if Data
.Symbol_Data
.Symbol_Policy
/= Autonomous
then
1761 "a reference symbol file need to be defined",
1762 Lib_Symbol_Policy
.Location
);
1766 Data
.Symbol_Data
.Reference
:= Lib_Ref_Symbol_File
.Value
;
1768 Get_Name_String
(Lib_Symbol_File
.Value
);
1770 if Name_Len
= 0 then
1773 "reference symbol file name cannot be an empty string",
1774 Lib_Symbol_File
.Location
);
1777 OK
:= not Is_Absolute_Path
(Name_Buffer
(1 .. Name_Len
));
1780 for J
in 1 .. Name_Len
loop
1781 if Name_Buffer
(J
) = '/'
1782 or else Name_Buffer
(J
) = Directory_Separator
1791 Error_Msg_Name_1
:= Lib_Ref_Symbol_File
.Value
;
1794 "reference symbol file { name is illegal. " &
1795 "Name canot include directory info.",
1796 Lib_Ref_Symbol_File
.Location
);
1799 if not Is_Regular_File
1800 (Get_Name_String
(Data
.Object_Directory
) &
1801 Directory_Separator
&
1802 Get_Name_String
(Lib_Ref_Symbol_File
.Value
))
1804 Error_Msg_Name_1
:= Lib_Ref_Symbol_File
.Value
;
1807 "library reference symbol file { does not exist",
1808 Lib_Ref_Symbol_File
.Location
);
1811 if Data
.Symbol_Data
.Symbol_File
/= No_Name
then
1815 (Data
.Symbol_Data
.Symbol_File
);
1817 Reference
: String :=
1819 (Data
.Symbol_Data
.Reference
);
1822 Canonical_Case_File_Name
(Symbol
);
1823 Canonical_Case_File_Name
(Reference
);
1825 if Symbol
= Reference
then
1828 "reference symbol file and symbol file " &
1829 "cannot be the same file",
1830 Lib_Ref_Symbol_File
.Location
);
1837 end Standalone_Library
;
1840 -- Put the list of Mains, if any, in the project data
1843 Mains
: constant Variable_Value
:=
1844 Prj
.Util
.Value_Of
(Name_Main
, Data
.Decl
.Attributes
);
1847 Data
.Mains
:= Mains
.Values
;
1849 -- If no Mains were specified, and if we are an extending
1850 -- project, inherit the Mains from the project we are extending.
1852 if Mains
.Default
then
1853 if Data
.Extends
/= No_Project
then
1854 Data
.Mains
:= Projects
.Table
(Data
.Extends
).Mains
;
1857 -- In a library project file, Main cannot be specified
1859 elsif Data
.Library
then
1862 "a library project file cannot have Main specified",
1867 Projects
.Table
(Project
) := Data
;
1869 Free_Naming_Exceptions
;
1876 function ALI_File_Name
(Source
: String) return String is
1878 -- If the source name has an extension, then replace it with
1881 for Index
in reverse Source
'First + 1 .. Source
'Last loop
1882 if Source
(Index
) = '.' then
1883 return Source
(Source
'First .. Index
- 1) & ALI_Suffix
;
1887 -- If there is no dot, or if it is the first character, just add the
1890 return Source
& ALI_Suffix
;
1893 --------------------
1894 -- Check_Ada_Name --
1895 --------------------
1897 procedure Check_Ada_Name
1901 The_Name
: String := Name
;
1902 Real_Name
: Name_Id
;
1903 Need_Letter
: Boolean := True;
1904 Last_Underscore
: Boolean := False;
1905 OK
: Boolean := The_Name
'Length > 0;
1908 To_Lower
(The_Name
);
1910 Name_Len
:= The_Name
'Length;
1911 Name_Buffer
(1 .. Name_Len
) := The_Name
;
1912 Real_Name
:= Name_Find
;
1914 -- Check first that the given name is not an Ada reserved word
1916 if Get_Name_Table_Byte
(Real_Name
) /= 0
1917 and then Real_Name
/= Name_Project
1918 and then Real_Name
/= Name_Extends
1919 and then Real_Name
/= Name_External
1923 if Current_Verbosity
= High
then
1924 Write_Str
(The_Name
);
1925 Write_Line
(" is an Ada reserved word.");
1931 for Index
in The_Name
'Range loop
1934 -- We need a letter (at the beginning, and following a dot),
1935 -- but we don't have one.
1937 if Is_Letter
(The_Name
(Index
)) then
1938 Need_Letter
:= False;
1943 if Current_Verbosity
= High
then
1944 Write_Int
(Types
.Int
(Index
));
1946 Write_Char
(The_Name
(Index
));
1947 Write_Line
("' is not a letter.");
1953 elsif Last_Underscore
1954 and then (The_Name
(Index
) = '_' or else The_Name
(Index
) = '.')
1956 -- Two underscores are illegal, and a dot cannot follow
1961 if Current_Verbosity
= High
then
1962 Write_Int
(Types
.Int
(Index
));
1964 Write_Char
(The_Name
(Index
));
1965 Write_Line
("' is illegal here.");
1970 elsif The_Name
(Index
) = '.' then
1972 -- We need a letter after a dot
1974 Need_Letter
:= True;
1976 elsif The_Name
(Index
) = '_' then
1977 Last_Underscore
:= True;
1980 -- We need an letter or a digit
1982 Last_Underscore
:= False;
1984 if not Is_Alphanumeric
(The_Name
(Index
)) then
1987 if Current_Verbosity
= High
then
1988 Write_Int
(Types
.Int
(Index
));
1990 Write_Char
(The_Name
(Index
));
1991 Write_Line
("' is not alphanumeric.");
1999 -- Cannot end with an underscore or a dot
2001 OK
:= OK
and then not Need_Letter
and then not Last_Underscore
;
2007 -- Signal a problem with No_Name
2013 -----------------------------
2014 -- Check_Ada_Naming_Scheme --
2015 -----------------------------
2017 procedure Check_Ada_Naming_Scheme
2018 (Project
: Project_Id
;
2019 Naming
: Naming_Data
)
2022 -- Only check if we are not using the standard naming scheme
2024 if Naming
/= Standard_Naming_Data
then
2026 Dot_Replacement
: constant String :=
2028 (Naming
.Dot_Replacement
);
2030 Spec_Suffix
: constant String :=
2032 (Naming
.Current_Spec_Suffix
);
2034 Body_Suffix
: constant String :=
2036 (Naming
.Current_Body_Suffix
);
2038 Separate_Suffix
: constant String :=
2040 (Naming
.Separate_Suffix
);
2043 -- Dot_Replacement cannot
2045 -- - start or end with an alphanumeric
2046 -- - be a single '_'
2047 -- - start with an '_' followed by an alphanumeric
2048 -- - contain a '.' except if it is "."
2050 if Dot_Replacement
'Length = 0
2051 or else Is_Alphanumeric
2052 (Dot_Replacement
(Dot_Replacement
'First))
2053 or else Is_Alphanumeric
2054 (Dot_Replacement
(Dot_Replacement
'Last))
2055 or else (Dot_Replacement
(Dot_Replacement
'First) = '_'
2057 (Dot_Replacement
'Length = 1
2060 (Dot_Replacement
(Dot_Replacement
'First + 1))))
2061 or else (Dot_Replacement
'Length > 1
2063 Index
(Source
=> Dot_Replacement
,
2064 Pattern
=> ".") /= 0)
2068 '"' & Dot_Replacement
&
2069 """ is illegal for Dot_Replacement.",
2070 Naming
.Dot_Repl_Loc
);
2076 if Is_Illegal_Suffix
2077 (Spec_Suffix
, Dot_Replacement
= ".")
2079 Err_Vars
.Error_Msg_Name_1
:= Naming
.Current_Spec_Suffix
;
2082 "{ is illegal for Spec_Suffix",
2083 Naming
.Spec_Suffix_Loc
);
2086 if Is_Illegal_Suffix
2087 (Body_Suffix
, Dot_Replacement
= ".")
2089 Err_Vars
.Error_Msg_Name_1
:= Naming
.Current_Body_Suffix
;
2092 "{ is illegal for Body_Suffix",
2093 Naming
.Body_Suffix_Loc
);
2096 if Body_Suffix
/= Separate_Suffix
then
2097 if Is_Illegal_Suffix
2098 (Separate_Suffix
, Dot_Replacement
= ".")
2100 Err_Vars
.Error_Msg_Name_1
:= Naming
.Separate_Suffix
;
2103 "{ is illegal for Separate_Suffix",
2104 Naming
.Sep_Suffix_Loc
);
2108 -- Spec_Suffix cannot have the same termination as
2109 -- Body_Suffix or Separate_Suffix
2111 if Spec_Suffix
'Length <= Body_Suffix
'Length
2113 Body_Suffix
(Body_Suffix
'Last -
2114 Spec_Suffix
'Length + 1 ..
2115 Body_Suffix
'Last) = Spec_Suffix
2121 """) cannot end with" &
2122 " Spec_Suffix (""" &
2123 Spec_Suffix
& """).",
2124 Naming
.Body_Suffix_Loc
);
2127 if Body_Suffix
/= Separate_Suffix
2128 and then Spec_Suffix
'Length <= Separate_Suffix
'Length
2131 (Separate_Suffix
'Last - Spec_Suffix
'Length + 1
2133 Separate_Suffix
'Last) = Spec_Suffix
2137 "Separate_Suffix (""" &
2139 """) cannot end with" &
2140 " Spec_Suffix (""" &
2141 Spec_Suffix
& """).",
2142 Naming
.Sep_Suffix_Loc
);
2146 end Check_Ada_Naming_Scheme
;
2153 (Project
: Project_Id
;
2155 Flag_Location
: Source_Ptr
)
2157 Error_Buffer
: String (1 .. 5_000
);
2158 Error_Last
: Natural := 0;
2159 Msg_Name
: Natural := 0;
2160 First
: Positive := Msg
'First;
2162 procedure Add
(C
: Character);
2163 -- Add a character to the buffer
2165 procedure Add
(S
: String);
2166 -- Add a string to the buffer
2168 procedure Add
(Id
: Name_Id
);
2169 -- Add a name to the buffer
2175 procedure Add
(C
: Character) is
2177 Error_Last
:= Error_Last
+ 1;
2178 Error_Buffer
(Error_Last
) := C
;
2181 procedure Add
(S
: String) is
2183 Error_Buffer
(Error_Last
+ 1 .. Error_Last
+ S
'Length) := S
;
2184 Error_Last
:= Error_Last
+ S
'Length;
2187 procedure Add
(Id
: Name_Id
) is
2189 Get_Name_String
(Id
);
2190 Add
(Name_Buffer
(1 .. Name_Len
));
2193 -- Start of processing for Error_Msg
2196 if Error_Report
= null then
2197 Prj
.Err
.Error_Msg
(Msg
, Flag_Location
);
2201 if Msg
(First
) = '\' then
2203 -- Continuation character, ignore.
2207 elsif Msg
(First
) = '?' then
2209 -- Warning character. It is always the first one in this package
2215 for Index
in First
.. Msg
'Last loop
2216 if Msg
(Index
) = '{' or else Msg
(Index
) = '%' then
2218 -- Include a name between double quotes.
2220 Msg_Name
:= Msg_Name
+ 1;
2224 when 1 => Add
(Err_Vars
.Error_Msg_Name_1
);
2225 when 2 => Add
(Err_Vars
.Error_Msg_Name_2
);
2226 when 3 => Add
(Err_Vars
.Error_Msg_Name_3
);
2228 when others => null;
2239 Error_Report
(Error_Buffer
(1 .. Error_Last
), Project
);
2247 (Canonical_File_Name
: Name_Id
;
2248 Naming
: Naming_Data
;
2249 Unit_Name
: out Name_Id
;
2250 Unit_Kind
: out Spec_Or_Body
;
2251 Needs_Pragma
: out Boolean)
2253 function Check_Exception
(Canonical
: Name_Id
) return Boolean;
2254 pragma Inline
(Check_Exception
);
2255 -- Check if Canonical is one of the exceptions in List.
2256 -- Returns True if Get_Unit should exit
2258 ---------------------
2259 -- Check_Exception --
2260 ---------------------
2262 function Check_Exception
(Canonical
: Name_Id
) return Boolean is
2263 Info
: Unit_Info
:= Naming_Exceptions
.Get
(Canonical
);
2267 if Info
= No_Unit
then
2268 if Hostparm
.OpenVMS
then
2269 VMS_Name
:= Canonical
;
2270 Get_Name_String
(VMS_Name
);
2272 if Name_Buffer
(Name_Len
) = '.' then
2273 Name_Len
:= Name_Len
- 1;
2274 VMS_Name
:= Name_Find
;
2277 Info
:= Naming_Exceptions
.Get
(VMS_Name
);
2280 if Info
= No_Unit
then
2285 Unit_Kind
:= Info
.Kind
;
2286 Unit_Name
:= Info
.Unit
;
2287 Needs_Pragma
:= True;
2289 end Check_Exception
;
2291 -- Start of processing for Get_Unit
2294 Needs_Pragma
:= False;
2296 if Check_Exception
(Canonical_File_Name
) then
2300 Get_Name_String
(Canonical_File_Name
);
2303 File
: String := Name_Buffer
(1 .. Name_Len
);
2304 First
: constant Positive := File
'First;
2305 Last
: Natural := File
'Last;
2306 Standard_GNAT
: Boolean;
2310 Naming
.Current_Spec_Suffix
= Default_Ada_Spec_Suffix
2311 and then Naming
.Current_Body_Suffix
= Default_Ada_Body_Suffix
;
2313 -- Check if the end of the file name is Specification_Append
2315 Get_Name_String
(Naming
.Current_Spec_Suffix
);
2317 if File
'Length > Name_Len
2318 and then File
(Last
- Name_Len
+ 1 .. Last
) =
2319 Name_Buffer
(1 .. Name_Len
)
2323 Unit_Kind
:= Specification
;
2324 Last
:= Last
- Name_Len
;
2326 if Current_Verbosity
= High
then
2327 Write_Str
(" Specification: ");
2328 Write_Line
(File
(First
.. Last
));
2332 Get_Name_String
(Naming
.Current_Body_Suffix
);
2334 -- Check if the end of the file name is Body_Append
2336 if File
'Length > Name_Len
2337 and then File
(Last
- Name_Len
+ 1 .. Last
) =
2338 Name_Buffer
(1 .. Name_Len
)
2342 Unit_Kind
:= Body_Part
;
2343 Last
:= Last
- Name_Len
;
2345 if Current_Verbosity
= High
then
2346 Write_Str
(" Body: ");
2347 Write_Line
(File
(First
.. Last
));
2350 elsif Naming
.Separate_Suffix
/= Naming
.Current_Spec_Suffix
then
2351 Get_Name_String
(Naming
.Separate_Suffix
);
2353 -- Check if the end of the file name is Separate_Append
2355 if File
'Length > Name_Len
2356 and then File
(Last
- Name_Len
+ 1 .. Last
) =
2357 Name_Buffer
(1 .. Name_Len
)
2359 -- We have a separate (a body)
2361 Unit_Kind
:= Body_Part
;
2362 Last
:= Last
- Name_Len
;
2364 if Current_Verbosity
= High
then
2365 Write_Str
(" Separate: ");
2366 Write_Line
(File
(First
.. Last
));
2380 -- This is not a source file
2382 Unit_Name
:= No_Name
;
2383 Unit_Kind
:= Specification
;
2385 if Current_Verbosity
= High
then
2386 Write_Line
(" Not a valid file name.");
2392 Get_Name_String
(Naming
.Dot_Replacement
);
2394 Standard_GNAT
and then Name_Buffer
(1 .. Name_Len
) = "-";
2396 if Name_Buffer
(1 .. Name_Len
) /= "." then
2398 -- If Dot_Replacement is not a single dot,
2399 -- then there should not be any dot in the name.
2401 for Index
in First
.. Last
loop
2402 if File
(Index
) = '.' then
2403 if Current_Verbosity
= High
then
2405 (" Not a valid file name (some dot not replaced).");
2408 Unit_Name
:= No_Name
;
2414 -- Replace the substring Dot_Replacement with dots
2417 Index
: Positive := First
;
2420 while Index
<= Last
- Name_Len
+ 1 loop
2422 if File
(Index
.. Index
+ Name_Len
- 1) =
2423 Name_Buffer
(1 .. Name_Len
)
2425 File
(Index
) := '.';
2427 if Name_Len
> 1 and then Index
< Last
then
2428 File
(Index
+ 1 .. Last
- Name_Len
+ 1) :=
2429 File
(Index
+ Name_Len
.. Last
);
2432 Last
:= Last
- Name_Len
+ 1;
2440 -- Check if the casing is right
2443 Src
: String := File
(First
.. Last
);
2446 case Naming
.Casing
is
2447 when All_Lower_Case
=>
2450 Mapping
=> Lower_Case_Map
);
2452 when All_Upper_Case
=>
2455 Mapping
=> Upper_Case_Map
);
2457 when Mixed_Case | Unknown
=>
2461 if Src
/= File
(First
.. Last
) then
2462 if Current_Verbosity
= High
then
2463 Write_Line
(" Not a valid file name (casing).");
2466 Unit_Name
:= No_Name
;
2470 -- We put the name in lower case
2474 Mapping
=> Lower_Case_Map
);
2476 -- In the standard GNAT naming scheme, check for special cases:
2477 -- children or separates of A, G, I or S, and run time sources.
2479 if Standard_GNAT
and then Src
'Length >= 3 then
2481 S1
: constant Character := Src
(Src
'First);
2482 S2
: constant Character := Src
(Src
'First + 1);
2485 if S1
= 'a' or else S1
= 'g'
2486 or else S1
= 'i' or else S1
= 's'
2488 -- Children or separates of packages A, G, I or S
2490 if (Hostparm
.OpenVMS
and then S2
= '$')
2491 or else (not Hostparm
.OpenVMS
and then S2
= '~')
2493 Src
(Src
'First + 1) := '.';
2495 -- If it is potentially a run time source, disable
2496 -- filling of the mapping file to avoid warnings.
2499 Set_Mapping_File_Initial_State_To_Empty
;
2506 if Current_Verbosity
= High
then
2511 -- Now, we check if this name is a valid unit name
2513 Check_Ada_Name
(Name
=> Src
, Unit
=> Unit_Name
);
2519 -----------------------
2520 -- Is_Illegal_Suffix --
2521 -----------------------
2523 function Is_Illegal_Suffix
2525 Dot_Replacement_Is_A_Single_Dot
: Boolean)
2529 if Suffix
'Length = 0 or else Index
(Suffix
, ".") = 0 then
2533 -- If dot replacement is a single dot, and first character of
2534 -- suffix is also a dot
2536 if Dot_Replacement_Is_A_Single_Dot
2537 and then Suffix
(Suffix
'First) = '.'
2539 for Index
in Suffix
'First + 1 .. Suffix
'Last loop
2541 -- If there is another dot
2543 if Suffix
(Index
) = '.' then
2545 -- It is illegal to have a letter following the initial dot
2547 return Is_Letter
(Suffix
(Suffix
'First + 1));
2555 end Is_Illegal_Suffix
;
2557 --------------------------------
2558 -- Language_Independent_Check --
2559 --------------------------------
2561 procedure Language_Independent_Check
2562 (Project
: Project_Id
;
2563 Report_Error
: Put_Line_Access
)
2565 Last_Source_Dir
: String_List_Id
:= Nil_String
;
2566 Data
: Project_Data
:= Projects
.Table
(Project
);
2568 procedure Find_Source_Dirs
(From
: Name_Id
; Location
: Source_Ptr
);
2569 -- Find one or several source directories, and add them
2570 -- to the list of source directories of the project.
2572 ----------------------
2573 -- Find_Source_Dirs --
2574 ----------------------
2576 procedure Find_Source_Dirs
(From
: Name_Id
; Location
: Source_Ptr
) is
2577 Directory
: constant String := Get_Name_String
(From
);
2578 Canonical_Directory_Id
: Name_Id
;
2579 Element
: String_Element
;
2581 procedure Recursive_Find_Dirs
(Path
: Name_Id
);
2582 -- Find all the subdirectories (recursively) of Path
2583 -- and add them to the list of source directories
2586 -------------------------
2587 -- Recursive_Find_Dirs --
2588 -------------------------
2590 procedure Recursive_Find_Dirs
(Path
: Name_Id
) is
2592 Name
: String (1 .. 250);
2594 List
: String_List_Id
:= Data
.Source_Dirs
;
2595 Element
: String_Element
;
2596 Found
: Boolean := False;
2598 Canonical_Path
: Name_Id
:= No_Name
;
2601 Get_Name_String
(Path
);
2602 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
2605 The_Path
: String :=
2607 (Name
=> Name_Buffer
(1 .. Name_Len
)) &
2608 Directory_Separator
;
2609 The_Path_Last
: constant Natural :=
2610 Compute_Directory_Last
(The_Path
);
2612 Name_Len
:= The_Path_Last
- The_Path
'First + 1;
2613 Name_Buffer
(1 .. Name_Len
) :=
2614 The_Path
(The_Path
'First .. The_Path_Last
);
2615 Canonical_Path
:= Name_Find
;
2617 -- To avoid processing the same directory several times, check
2618 -- if the directory is already in Recursive_Dirs. If it is,
2619 -- then there is nothing to do, just return. If it is not, put
2620 -- it there and continue recursive processing.
2622 if Recursive_Dirs
.Get
(Canonical_Path
) then
2626 Recursive_Dirs
.Set
(Canonical_Path
, True);
2629 -- Check if directory is already in list
2631 while List
/= Nil_String
loop
2632 Element
:= String_Elements
.Table
(List
);
2634 if Element
.Value
/= No_Name
then
2635 Get_Name_String
(Element
.Value
);
2637 The_Path
(The_Path
'First .. The_Path_Last
) =
2638 Name_Buffer
(1 .. Name_Len
);
2642 List
:= Element
.Next
;
2645 -- If directory is not already in list, put it there
2648 if Current_Verbosity
= High
then
2650 Write_Line
(The_Path
(The_Path
'First .. The_Path_Last
));
2653 String_Elements
.Increment_Last
;
2655 (Value
=> Canonical_Path
,
2656 Display_Value
=> No_Name
,
2657 Location
=> No_Location
,
2659 Next
=> Nil_String
);
2661 -- Case of first source directory
2663 if Last_Source_Dir
= Nil_String
then
2664 Data
.Source_Dirs
:= String_Elements
.Last
;
2666 -- Here we already have source directories.
2669 -- Link the previous last to the new one
2671 String_Elements
.Table
(Last_Source_Dir
).Next
:=
2672 String_Elements
.Last
;
2675 -- And register this source directory as the new last
2677 Last_Source_Dir
:= String_Elements
.Last
;
2678 String_Elements
.Table
(Last_Source_Dir
) := Element
;
2681 -- Now look for subdirectories. We do that even when this
2682 -- directory is already in the list, because some of its
2683 -- subdirectories may not be in the list yet.
2685 Open
(Dir
, The_Path
(The_Path
'First .. The_Path_Last
));
2688 Read
(Dir
, Name
, Last
);
2691 if Name
(1 .. Last
) /= "."
2692 and then Name
(1 .. Last
) /= ".."
2696 if Current_Verbosity
= High
then
2697 Write_Str
(" Checking ");
2698 Write_Line
(Name
(1 .. Last
));
2702 Path_Name
: String :=
2704 (Name
=> Name
(1 .. Last
),
2707 (The_Path
'First .. The_Path_Last
));
2710 Canonical_Case_File_Name
(Path_Name
);
2712 if Is_Directory
(Path_Name
) then
2714 -- We have found a new subdirectory, call self
2716 Name_Len
:= Path_Name
'Length;
2717 Name_Buffer
(1 .. Name_Len
) := Path_Name
;
2718 Recursive_Find_Dirs
(Name_Find
);
2728 when Directory_Error
=>
2730 end Recursive_Find_Dirs
;
2732 -- Start of processing for Find_Source_Dirs
2735 if Current_Verbosity
= High
then
2736 Write_Str
("Find_Source_Dirs (""");
2739 Get_Name_String
(From
);
2740 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
2741 -- Directory := Name_Buffer (1 .. Name_Len);
2742 Canonical_Directory_Id
:= Name_Find
;
2744 if Current_Verbosity
= High
then
2745 Write_Str
(Directory
);
2749 -- First, check if we are looking for a directory tree,
2750 -- indicated by "/**" at the end.
2752 if Directory
'Length >= 3
2753 and then Directory
(Directory
'Last - 1 .. Directory
'Last) = "**"
2754 and then (Directory
(Directory
'Last - 2) = '/'
2756 Directory
(Directory
'Last - 2) = Directory_Separator
)
2758 Data
.Known_Order_Of_Source_Dirs
:= False;
2760 Name_Len
:= Directory
'Length - 3;
2762 if Name_Len
= 0 then
2764 -- This is the case of "/**": all directories
2765 -- in the file system.
2768 Name_Buffer
(1) := Directory
(Directory
'First);
2771 Name_Buffer
(1 .. Name_Len
) :=
2772 Directory
(Directory
'First .. Directory
'Last - 3);
2775 if Current_Verbosity
= High
then
2776 Write_Str
("Looking for all subdirectories of """);
2777 Write_Str
(Name_Buffer
(1 .. Name_Len
));
2782 Base_Dir
: constant Name_Id
:= Name_Find
;
2783 Root_Dir
: constant String :=
2785 (Name
=> Get_Name_String
(Base_Dir
),
2787 Get_Name_String
(Data
.Display_Directory
));
2790 if Root_Dir
'Length = 0 then
2791 Err_Vars
.Error_Msg_Name_1
:= Base_Dir
;
2793 if Location
= No_Location
then
2796 "{ is not a valid directory.",
2801 "{ is not a valid directory.",
2806 -- We have an existing directory,
2807 -- we register it and all of its subdirectories.
2809 if Current_Verbosity
= High
then
2810 Write_Line
("Looking for source directories:");
2813 Name_Len
:= Root_Dir
'Length;
2814 Name_Buffer
(1 .. Name_Len
) := Root_Dir
;
2815 Recursive_Find_Dirs
(Name_Find
);
2817 if Current_Verbosity
= High
then
2818 Write_Line
("End of looking for source directories.");
2823 -- We have a single directory
2827 Path_Name
: Name_Id
;
2828 Display_Path_Name
: Name_Id
;
2831 (From
, Data
.Display_Directory
, Path_Name
, Display_Path_Name
);
2832 if Path_Name
= No_Name
then
2833 Err_Vars
.Error_Msg_Name_1
:= From
;
2835 if Location
= No_Location
then
2838 "{ is not a valid directory",
2843 "{ is not a valid directory",
2848 -- As it is an existing directory, we add it to
2849 -- the list of directories.
2851 String_Elements
.Increment_Last
;
2852 Element
.Value
:= Path_Name
;
2853 Element
.Display_Value
:= Display_Path_Name
;
2855 if Last_Source_Dir
= Nil_String
then
2857 -- This is the first source directory
2859 Data
.Source_Dirs
:= String_Elements
.Last
;
2862 -- We already have source directories,
2863 -- link the previous last to the new one.
2865 String_Elements
.Table
(Last_Source_Dir
).Next
:=
2866 String_Elements
.Last
;
2869 -- And register this source directory as the new last
2871 Last_Source_Dir
:= String_Elements
.Last
;
2872 String_Elements
.Table
(Last_Source_Dir
) := Element
;
2876 end Find_Source_Dirs
;
2878 -- Start of processing for Language_Independent_Check
2881 if Data
.Language_Independent_Checked
then
2885 Data
.Language_Independent_Checked
:= True;
2887 Error_Report
:= Report_Error
;
2889 Recursive_Dirs
.Reset
;
2891 if Current_Verbosity
= High
then
2892 Write_Line
("Starting to look for directories");
2895 -- Check the object directory
2898 Object_Dir
: constant Variable_Value
:=
2899 Util
.Value_Of
(Name_Object_Dir
, Data
.Decl
.Attributes
);
2902 pragma Assert
(Object_Dir
.Kind
= Single
,
2903 "Object_Dir is not a single string");
2905 -- We set the object directory to its default
2907 Data
.Object_Directory
:= Data
.Directory
;
2908 Data
.Display_Object_Dir
:= Data
.Display_Directory
;
2910 if Object_Dir
.Value
/= Empty_String
then
2912 Get_Name_String
(Object_Dir
.Value
);
2914 if Name_Len
= 0 then
2917 "Object_Dir cannot be empty",
2918 Object_Dir
.Location
);
2921 -- We check that the specified object directory
2925 (Object_Dir
.Value
, Data
.Display_Directory
,
2926 Data
.Object_Directory
, Data
.Display_Object_Dir
);
2928 if Data
.Object_Directory
= No_Name
then
2929 -- The object directory does not exist, report an error
2930 Err_Vars
.Error_Msg_Name_1
:= Object_Dir
.Value
;
2933 "the object directory { cannot be found",
2936 -- Do not keep a nil Object_Directory. Set it to the
2937 -- specified (relative or absolute) path.
2938 -- This is for the benefit of tools that recover from
2939 -- errors; for example, these tools could create the
2940 -- non existent directory.
2942 Data
.Display_Object_Dir
:= Object_Dir
.Value
;
2943 Get_Name_String
(Object_Dir
.Value
);
2944 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
2945 Data
.Object_Directory
:= Name_Find
;
2951 if Current_Verbosity
= High
then
2952 if Data
.Object_Directory
= No_Name
then
2953 Write_Line
("No object directory");
2955 Write_Str
("Object directory: """);
2956 Write_Str
(Get_Name_String
(Data
.Display_Object_Dir
));
2961 -- Check the exec directory
2964 Exec_Dir
: constant Variable_Value
:=
2965 Util
.Value_Of
(Name_Exec_Dir
, Data
.Decl
.Attributes
);
2968 pragma Assert
(Exec_Dir
.Kind
= Single
,
2969 "Exec_Dir is not a single string");
2971 -- We set the object directory to its default
2973 Data
.Exec_Directory
:= Data
.Object_Directory
;
2974 Data
.Display_Exec_Dir
:= Data
.Display_Object_Dir
;
2976 if Exec_Dir
.Value
/= Empty_String
then
2978 Get_Name_String
(Exec_Dir
.Value
);
2980 if Name_Len
= 0 then
2983 "Exec_Dir cannot be empty",
2987 -- We check that the specified object directory
2991 (Exec_Dir
.Value
, Data
.Directory
,
2992 Data
.Exec_Directory
, Data
.Display_Exec_Dir
);
2994 if Data
.Exec_Directory
= No_Name
then
2995 Err_Vars
.Error_Msg_Name_1
:= Exec_Dir
.Value
;
2998 "the exec directory { cannot be found",
3005 if Current_Verbosity
= High
then
3006 if Data
.Exec_Directory
= No_Name
then
3007 Write_Line
("No exec directory");
3009 Write_Str
("Exec directory: """);
3010 Write_Str
(Get_Name_String
(Data
.Display_Exec_Dir
));
3015 -- Look for the source directories
3018 Source_Dirs
: constant Variable_Value
:=
3020 (Name_Source_Dirs
, Data
.Decl
.Attributes
);
3023 if Current_Verbosity
= High
then
3024 Write_Line
("Starting to look for source directories");
3027 pragma Assert
(Source_Dirs
.Kind
= List
,
3028 "Source_Dirs is not a list");
3030 if Source_Dirs
.Default
then
3032 -- No Source_Dirs specified: the single source directory
3033 -- is the one containing the project file
3035 String_Elements
.Increment_Last
;
3036 Data
.Source_Dirs
:= String_Elements
.Last
;
3037 String_Elements
.Table
(Data
.Source_Dirs
) :=
3038 (Value
=> Data
.Directory
,
3039 Display_Value
=> Data
.Display_Directory
,
3040 Location
=> No_Location
,
3042 Next
=> Nil_String
);
3044 if Current_Verbosity
= High
then
3045 Write_Line
("Single source directory:");
3047 Write_Str
(Get_Name_String
(Data
.Display_Directory
));
3051 elsif Source_Dirs
.Values
= Nil_String
then
3053 -- If Source_Dirs is an empty string list, this means
3054 -- that this project contains no source. For projects that
3055 -- don't extend other projects, this also means that there is no
3056 -- need for an object directory, if not specified.
3058 if Data
.Extends
= No_Project
3059 and then Data
.Object_Directory
= Data
.Directory
3061 Data
.Object_Directory
:= No_Name
;
3064 Data
.Source_Dirs
:= Nil_String
;
3065 Data
.Sources_Present
:= False;
3069 Source_Dir
: String_List_Id
:= Source_Dirs
.Values
;
3070 Element
: String_Element
;
3073 -- We will find the source directories for each
3074 -- element of the list
3076 while Source_Dir
/= Nil_String
loop
3077 Element
:= String_Elements
.Table
(Source_Dir
);
3078 Find_Source_Dirs
(Element
.Value
, Element
.Location
);
3079 Source_Dir
:= Element
.Next
;
3084 if Current_Verbosity
= High
then
3085 Write_Line
("Putting source directories in canonical cases");
3089 Current
: String_List_Id
:= Data
.Source_Dirs
;
3090 Element
: String_Element
;
3093 while Current
/= Nil_String
loop
3094 Element
:= String_Elements
.Table
(Current
);
3095 if Element
.Value
/= No_Name
then
3096 Element
.Display_Value
:= Element
.Value
;
3097 Get_Name_String
(Element
.Value
);
3098 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3099 Element
.Value
:= Name_Find
;
3100 String_Elements
.Table
(Current
) := Element
;
3103 Current
:= Element
.Next
;
3108 -- Library attributes
3111 Attributes
: constant Prj
.Variable_Id
:= Data
.Decl
.Attributes
;
3113 Lib_Dir
: constant Prj
.Variable_Value
:=
3114 Prj
.Util
.Value_Of
(Snames
.Name_Library_Dir
, Attributes
);
3116 Lib_Name
: constant Prj
.Variable_Value
:=
3117 Prj
.Util
.Value_Of
(Snames
.Name_Library_Name
, Attributes
);
3119 Lib_Version
: constant Prj
.Variable_Value
:=
3121 (Snames
.Name_Library_Version
, Attributes
);
3123 The_Lib_Kind
: constant Prj
.Variable_Value
:=
3125 (Snames
.Name_Library_Kind
, Attributes
);
3128 -- Special case of extending project
3130 if Data
.Extends
/= No_Project
then
3132 Extended_Data
: constant Project_Data
:=
3133 Projects
.Table
(Data
.Extends
);
3136 -- If the project extended is a library project, we inherit
3137 -- the library name, if it is not redefined; we check that
3138 -- the library directory is specified; and we reset the
3139 -- library flag for the extended project.
3141 if Extended_Data
.Library
then
3142 if Lib_Name
.Default
then
3143 Data
.Library_Name
:= Extended_Data
.Library_Name
;
3146 if Lib_Dir
.Default
then
3148 -- If the extending project is a virtual project, we
3149 -- put the error message in the library project that
3150 -- is extended, rather than in the extending all project.
3151 -- Of course, we cannot put it in the virtual extending
3152 -- project, because it has no source.
3154 if Data
.Virtual
then
3155 Error_Msg_Name_1
:= Extended_Data
.Name
;
3159 "library project % cannot be virtually extended",
3160 Extended_Data
.Location
);
3165 "a project extending a library project must " &
3166 "specify an attribute Library_Dir",
3171 Projects
.Table
(Data
.Extends
).Library
:= False;
3176 pragma Assert
(Lib_Dir
.Kind
= Single
);
3178 if Lib_Dir
.Value
= Empty_String
then
3180 if Current_Verbosity
= High
then
3181 Write_Line
("No library directory");
3185 -- Find path name, check that it is a directory
3188 (Lib_Dir
.Value
, Data
.Display_Directory
,
3189 Data
.Library_Dir
, Data
.Display_Library_Dir
);
3191 if Data
.Library_Dir
= No_Name
then
3193 -- Get the absolute name of the library directory that
3194 -- does not exist, to report an error.
3197 Dir_Name
: constant String :=
3198 Get_Name_String
(Lib_Dir
.Value
);
3200 if Is_Absolute_Path
(Dir_Name
) then
3201 Err_Vars
.Error_Msg_Name_1
:= Lib_Dir
.Value
;
3204 Get_Name_String
(Data
.Display_Directory
);
3206 if Name_Buffer
(Name_Len
) /= Directory_Separator
then
3207 Name_Len
:= Name_Len
+ 1;
3208 Name_Buffer
(Name_Len
) := Directory_Separator
;
3212 (Name_Len
+ 1 .. Name_Len
+ Dir_Name
'Length) :=
3214 Name_Len
:= Name_Len
+ Dir_Name
'Length;
3215 Err_Vars
.Error_Msg_Name_1
:= Name_Find
;
3222 "library directory { does not exist",
3226 elsif Data
.Library_Dir
= Data
.Object_Directory
then
3229 "library directory cannot be the same " &
3230 "as object directory",
3232 Data
.Library_Dir
:= No_Name
;
3233 Data
.Display_Library_Dir
:= No_Name
;
3236 if Current_Verbosity
= High
then
3237 Write_Str
("Library directory =""");
3238 Write_Str
(Get_Name_String
(Data
.Display_Library_Dir
));
3244 pragma Assert
(Lib_Name
.Kind
= Single
);
3246 if Lib_Name
.Value
= Empty_String
then
3247 if Current_Verbosity
= High
3248 and then Data
.Library_Name
= No_Name
3250 Write_Line
("No library name");
3254 -- There is no restriction on the syntax of library names
3256 Data
.Library_Name
:= Lib_Name
.Value
;
3259 if Data
.Library_Name
/= No_Name
3260 and then Current_Verbosity
= High
3262 Write_Str
("Library name = """);
3263 Write_Str
(Get_Name_String
(Data
.Library_Name
));
3268 Data
.Library_Dir
/= No_Name
3270 Data
.Library_Name
/= No_Name
;
3272 if Data
.Library
then
3273 if MLib
.Tgt
.Support_For_Libraries
= MLib
.Tgt
.None
then
3276 "?libraries are not supported on this platform",
3278 Data
.Library
:= False;
3281 pragma Assert
(Lib_Version
.Kind
= Single
);
3283 if Lib_Version
.Value
= Empty_String
then
3284 if Current_Verbosity
= High
then
3285 Write_Line
("No library version specified");
3289 Data
.Lib_Internal_Name
:= Lib_Version
.Value
;
3292 pragma Assert
(The_Lib_Kind
.Kind
= Single
);
3294 if The_Lib_Kind
.Value
= Empty_String
then
3295 if Current_Verbosity
= High
then
3296 Write_Line
("No library kind specified");
3300 Get_Name_String
(The_Lib_Kind
.Value
);
3303 Kind_Name
: constant String :=
3304 To_Lower
(Name_Buffer
(1 .. Name_Len
));
3306 OK
: Boolean := True;
3309 if Kind_Name
= "static" then
3310 Data
.Library_Kind
:= Static
;
3312 elsif Kind_Name
= "dynamic" then
3313 Data
.Library_Kind
:= Dynamic
;
3315 elsif Kind_Name
= "relocatable" then
3316 Data
.Library_Kind
:= Relocatable
;
3321 "illegal value for Library_Kind",
3322 The_Lib_Kind
.Location
);
3326 if Current_Verbosity
= High
and then OK
then
3327 Write_Str
("Library kind = ");
3328 Write_Line
(Kind_Name
);
3331 if Data
.Library_Kind
/= Static
and then
3332 MLib
.Tgt
.Support_For_Libraries
= MLib
.Tgt
.Static_Only
3336 "only static libraries are supported " &
3338 The_Lib_Kind
.Location
);
3339 Data
.Library
:= False;
3344 if Data
.Library
and then Current_Verbosity
= High
then
3345 Write_Line
("This is a library project file");
3352 if Current_Verbosity
= High
then
3353 Show_Source_Dirs
(Project
);
3357 Naming_Id
: constant Package_Id
:=
3358 Util
.Value_Of
(Name_Naming
, Data
.Decl
.Packages
);
3360 Naming
: Package_Element
;
3363 -- If there is a package Naming, we will put in Data.Naming
3364 -- what is in this package Naming.
3366 if Naming_Id
/= No_Package
then
3367 Naming
:= Packages
.Table
(Naming_Id
);
3369 if Current_Verbosity
= High
then
3370 Write_Line
("Checking ""Naming"".");
3373 -- Check Spec_Suffix
3376 Spec_Suffixs
: Array_Element_Id
:=
3379 Naming
.Decl
.Arrays
);
3380 Suffix
: Array_Element_Id
;
3381 Element
: Array_Element
;
3382 Suffix2
: Array_Element_Id
;
3385 -- If some suffixs have been specified, we make sure that
3386 -- for each language for which a default suffix has been
3387 -- specified, there is a suffix specified, either the one
3388 -- in the project file or if there were none, the default.
3390 if Spec_Suffixs
/= No_Array_Element
then
3391 Suffix
:= Data
.Naming
.Spec_Suffix
;
3393 while Suffix
/= No_Array_Element
loop
3394 Element
:= Array_Elements
.Table
(Suffix
);
3395 Suffix2
:= Spec_Suffixs
;
3397 while Suffix2
/= No_Array_Element
loop
3398 exit when Array_Elements
.Table
(Suffix2
).Index
=
3400 Suffix2
:= Array_Elements
.Table
(Suffix2
).Next
;
3403 -- There is a registered default suffix, but no
3404 -- suffix specified in the project file.
3405 -- Add the default to the array.
3407 if Suffix2
= No_Array_Element
then
3408 Array_Elements
.Increment_Last
;
3409 Array_Elements
.Table
(Array_Elements
.Last
) :=
3410 (Index
=> Element
.Index
,
3411 Index_Case_Sensitive
=> False,
3412 Value
=> Element
.Value
,
3413 Next
=> Spec_Suffixs
);
3414 Spec_Suffixs
:= Array_Elements
.Last
;
3417 Suffix
:= Element
.Next
;
3420 -- Put the resulting array as the specification suffixs
3422 Data
.Naming
.Spec_Suffix
:= Spec_Suffixs
;
3427 Current
: Array_Element_Id
:= Data
.Naming
.Spec_Suffix
;
3428 Element
: Array_Element
;
3431 while Current
/= No_Array_Element
loop
3432 Element
:= Array_Elements
.Table
(Current
);
3433 Get_Name_String
(Element
.Value
.Value
);
3435 if Name_Len
= 0 then
3438 "Spec_Suffix cannot be empty",
3439 Element
.Value
.Location
);
3442 Array_Elements
.Table
(Current
) := Element
;
3443 Current
:= Element
.Next
;
3447 -- Check Body_Suffix
3450 Impl_Suffixs
: Array_Element_Id
:=
3453 Naming
.Decl
.Arrays
);
3455 Suffix
: Array_Element_Id
;
3456 Element
: Array_Element
;
3457 Suffix2
: Array_Element_Id
;
3460 -- If some suffixs have been specified, we make sure that
3461 -- for each language for which a default suffix has been
3462 -- specified, there is a suffix specified, either the one
3463 -- in the project file or if there were noe, the default.
3465 if Impl_Suffixs
/= No_Array_Element
then
3466 Suffix
:= Data
.Naming
.Body_Suffix
;
3468 while Suffix
/= No_Array_Element
loop
3469 Element
:= Array_Elements
.Table
(Suffix
);
3470 Suffix2
:= Impl_Suffixs
;
3472 while Suffix2
/= No_Array_Element
loop
3473 exit when Array_Elements
.Table
(Suffix2
).Index
=
3475 Suffix2
:= Array_Elements
.Table
(Suffix2
).Next
;
3478 -- There is a registered default suffix, but no
3479 -- suffix specified in the project file.
3480 -- Add the default to the array.
3482 if Suffix2
= No_Array_Element
then
3483 Array_Elements
.Increment_Last
;
3484 Array_Elements
.Table
(Array_Elements
.Last
) :=
3485 (Index
=> Element
.Index
,
3486 Index_Case_Sensitive
=> False,
3487 Value
=> Element
.Value
,
3488 Next
=> Impl_Suffixs
);
3489 Impl_Suffixs
:= Array_Elements
.Last
;
3492 Suffix
:= Element
.Next
;
3495 -- Put the resulting array as the implementation suffixs
3497 Data
.Naming
.Body_Suffix
:= Impl_Suffixs
;
3502 Current
: Array_Element_Id
:= Data
.Naming
.Body_Suffix
;
3503 Element
: Array_Element
;
3506 while Current
/= No_Array_Element
loop
3507 Element
:= Array_Elements
.Table
(Current
);
3508 Get_Name_String
(Element
.Value
.Value
);
3510 if Name_Len
= 0 then
3513 "Body_Suffix cannot be empty",
3514 Element
.Value
.Location
);
3517 Array_Elements
.Table
(Current
) := Element
;
3518 Current
:= Element
.Next
;
3522 -- Get the exceptions, if any
3524 Data
.Naming
.Specification_Exceptions
:=
3526 (Name_Specification_Exceptions
,
3527 In_Arrays
=> Naming
.Decl
.Arrays
);
3529 Data
.Naming
.Implementation_Exceptions
:=
3531 (Name_Implementation_Exceptions
,
3532 In_Arrays
=> Naming
.Decl
.Arrays
);
3536 Projects
.Table
(Project
) := Data
;
3537 end Language_Independent_Check
;
3539 ----------------------
3540 -- Locate_Directory --
3541 ----------------------
3543 procedure Locate_Directory
3547 Display
: out Name_Id
)
3549 The_Name
: constant String := Get_Name_String
(Name
);
3550 The_Parent
: constant String :=
3551 Get_Name_String
(Parent
) & Directory_Separator
;
3552 The_Parent_Last
: constant Natural :=
3553 Compute_Directory_Last
(The_Parent
);
3556 if Current_Verbosity
= High
then
3557 Write_Str
("Locate_Directory (""");
3558 Write_Str
(The_Name
);
3559 Write_Str
(""", """);
3560 Write_Str
(The_Parent
);
3567 if Is_Absolute_Path
(The_Name
) then
3568 if Is_Directory
(The_Name
) then
3570 Normed
: constant String :=
3571 Normalize_Pathname
(The_Name
);
3574 Name_Len
:= Normed
'Length;
3575 Name_Buffer
(1 .. Name_Len
) := Normed
;
3576 Display
:= Name_Find
;
3577 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3584 Full_Path
: constant String :=
3585 The_Parent
(The_Parent
'First .. The_Parent_Last
) &
3589 if Is_Directory
(Full_Path
) then
3591 Normed
: constant String :=
3592 Normalize_Pathname
(Full_Path
);
3595 Name_Len
:= Normed
'Length;
3596 Name_Buffer
(1 .. Name_Len
) := Normed
;
3597 Display
:= Name_Find
;
3598 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3604 end Locate_Directory
;
3610 function Path_Name_Of
3611 (File_Name
: Name_Id
;
3612 Directory
: Name_Id
)
3615 Result
: String_Access
;
3616 The_Directory
: constant String := Get_Name_String
(Directory
);
3619 Get_Name_String
(File_Name
);
3620 Result
:= Locate_Regular_File
3621 (File_Name
=> Name_Buffer
(1 .. Name_Len
),
3622 Path
=> The_Directory
);
3624 if Result
= null then
3627 Canonical_Case_File_Name
(Result
.all);
3632 ---------------------
3633 -- Project_Extends --
3634 ---------------------
3636 function Project_Extends
3637 (Extending
: Project_Id
;
3638 Extended
: Project_Id
)
3641 Current
: Project_Id
:= Extending
;
3644 if Current
= No_Project
then
3647 elsif Current
= Extended
then
3651 Current
:= Projects
.Table
(Current
).Extends
;
3653 end Project_Extends
;
3659 procedure Record_Source
3660 (File_Name
: Name_Id
;
3661 Path_Name
: Name_Id
;
3662 Project
: Project_Id
;
3663 Data
: in out Project_Data
;
3664 Location
: Source_Ptr
;
3665 Current_Source
: in out String_List_Id
;
3666 Source_Recorded
: in out Boolean)
3668 Canonical_File_Name
: Name_Id
;
3669 Canonical_Path_Name
: Name_Id
;
3670 Unit_Name
: Name_Id
;
3671 Unit_Kind
: Spec_Or_Body
;
3672 Needs_Pragma
: Boolean;
3674 The_Location
: Source_Ptr
:= Location
;
3675 Previous_Source
: constant String_List_Id
:= Current_Source
;
3676 Except_Name
: Name_Id
:= No_Name
;
3679 Get_Name_String
(File_Name
);
3680 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3681 Canonical_File_Name
:= Name_Find
;
3682 Get_Name_String
(Path_Name
);
3683 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
3684 Canonical_Path_Name
:= Name_Find
;
3686 -- Find out the unit name, the unit kind and if it needs
3687 -- a specific SFN pragma.
3690 (Canonical_File_Name
=> Canonical_File_Name
,
3691 Naming
=> Data
.Naming
,
3692 Unit_Name
=> Unit_Name
,
3693 Unit_Kind
=> Unit_Kind
,
3694 Needs_Pragma
=> Needs_Pragma
);
3696 if Unit_Name
= No_Name
then
3697 if Current_Verbosity
= High
then
3699 Write_Str
(Get_Name_String
(Canonical_File_Name
));
3700 Write_Line
(""" is not a valid source file name (ignored).");
3704 -- Check to see if the source has been hidden by an exception,
3705 -- but only if it is not an exception.
3707 if not Needs_Pragma
then
3709 Reverse_Naming_Exceptions
.Get
((Unit_Kind
, Unit_Name
));
3711 if Except_Name
/= No_Name
then
3712 if Current_Verbosity
= High
then
3714 Write_Str
(Get_Name_String
(Canonical_File_Name
));
3715 Write_Str
(""" contains a unit that is found in """);
3716 Write_Str
(Get_Name_String
(Except_Name
));
3717 Write_Line
(""" (ignored).");
3720 -- The file is not included in the source of the project,
3721 -- because it is hidden by the exception.
3722 -- So, there is nothing else to do.
3728 -- Put the file name in the list of sources of the project
3730 String_Elements
.Increment_Last
;
3731 String_Elements
.Table
(String_Elements
.Last
) :=
3732 (Value
=> Canonical_File_Name
,
3733 Display_Value
=> File_Name
,
3734 Location
=> No_Location
,
3736 Next
=> Nil_String
);
3738 if Current_Source
= Nil_String
then
3739 Data
.Sources
:= String_Elements
.Last
;
3742 String_Elements
.Table
(Current_Source
).Next
:=
3743 String_Elements
.Last
;
3746 Current_Source
:= String_Elements
.Last
;
3748 -- Put the unit in unit list
3751 The_Unit
: Unit_Id
:= Units_Htable
.Get
(Unit_Name
);
3752 The_Unit_Data
: Unit_Data
;
3755 if Current_Verbosity
= High
then
3756 Write_Str
("Putting ");
3757 Write_Str
(Get_Name_String
(Unit_Name
));
3758 Write_Line
(" in the unit list.");
3761 -- The unit is already in the list, but may be it is
3762 -- only the other unit kind (spec or body), or what is
3763 -- in the unit list is a unit of a project we are extending.
3765 if The_Unit
/= Prj
.Com
.No_Unit
then
3766 The_Unit_Data
:= Units
.Table
(The_Unit
);
3768 if The_Unit_Data
.File_Names
(Unit_Kind
).Name
= No_Name
3769 or else Project_Extends
3771 The_Unit_Data
.File_Names
(Unit_Kind
).Project
)
3773 if The_Unit_Data
.File_Names
(Unit_Kind
).Path
= Slash
then
3774 Remove_Forbidden_File_Name
3775 (The_Unit_Data
.File_Names
(Unit_Kind
).Name
);
3778 The_Unit_Data
.File_Names
(Unit_Kind
) :=
3779 (Name
=> Canonical_File_Name
,
3780 Display_Name
=> File_Name
,
3781 Path
=> Canonical_Path_Name
,
3782 Display_Path
=> Path_Name
,
3784 Needs_Pragma
=> Needs_Pragma
);
3785 Units
.Table
(The_Unit
) := The_Unit_Data
;
3786 Source_Recorded
:= True;
3788 elsif The_Unit_Data
.File_Names
(Unit_Kind
).Project
= Project
3789 and then (Data
.Known_Order_Of_Source_Dirs
or else
3790 The_Unit_Data
.File_Names
(Unit_Kind
).Path
=
3791 Canonical_Path_Name
)
3793 if Previous_Source
= Nil_String
then
3794 Data
.Sources
:= Nil_String
;
3796 String_Elements
.Table
(Previous_Source
).Next
:=
3798 String_Elements
.Decrement_Last
;
3801 Current_Source
:= Previous_Source
;
3804 -- It is an error to have two units with the same name
3805 -- and the same kind (spec or body).
3807 if The_Location
= No_Location
then
3808 The_Location
:= Projects
.Table
(Project
).Location
;
3811 Err_Vars
.Error_Msg_Name_1
:= Unit_Name
;
3812 Error_Msg
(Project
, "duplicate source {", The_Location
);
3814 Err_Vars
.Error_Msg_Name_1
:=
3816 (The_Unit_Data
.File_Names
(Unit_Kind
).Project
).Name
;
3817 Err_Vars
.Error_Msg_Name_2
:=
3818 The_Unit_Data
.File_Names
(Unit_Kind
).Path
;
3819 Error_Msg
(Project
, "\ project file {, {", The_Location
);
3821 Err_Vars
.Error_Msg_Name_1
:= Projects
.Table
(Project
).Name
;
3822 Err_Vars
.Error_Msg_Name_2
:= Canonical_Path_Name
;
3823 Error_Msg
(Project
, "\ project file {, {", The_Location
);
3827 -- It is a new unit, create a new record
3830 Units
.Increment_Last
;
3831 The_Unit
:= Units
.Last
;
3832 Units_Htable
.Set
(Unit_Name
, The_Unit
);
3833 The_Unit_Data
.Name
:= Unit_Name
;
3834 The_Unit_Data
.File_Names
(Unit_Kind
) :=
3835 (Name
=> Canonical_File_Name
,
3836 Display_Name
=> File_Name
,
3837 Path
=> Canonical_Path_Name
,
3838 Display_Path
=> Path_Name
,
3840 Needs_Pragma
=> Needs_Pragma
);
3841 Units
.Table
(The_Unit
) := The_Unit_Data
;
3842 Source_Recorded
:= True;
3848 ----------------------
3849 -- Show_Source_Dirs --
3850 ----------------------
3852 procedure Show_Source_Dirs
(Project
: Project_Id
) is
3853 Current
: String_List_Id
:= Projects
.Table
(Project
).Source_Dirs
;
3854 Element
: String_Element
;
3857 Write_Line
("Source_Dirs:");
3859 while Current
/= Nil_String
loop
3860 Element
:= String_Elements
.Table
(Current
);
3862 Write_Line
(Get_Name_String
(Element
.Value
));
3863 Current
:= Element
.Next
;
3866 Write_Line
("end Source_Dirs.");
3867 end Show_Source_Dirs
;