1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2000-2005 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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.Env; use Prj.Env;
37 with Prj.Util; use Prj.Util;
39 with Snames; use Snames;
40 with Table; use Table;
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;
56 -- Set to point to error reporting procedure
58 ALI_Suffix : constant String := ".ali";
59 -- File suffix for ali files
61 Object_Suffix : constant String := Get_Object_Suffix.all;
62 -- File suffix for object files
64 type Name_Location is record
66 Location : Source_Ptr;
67 Found : Boolean := False;
69 -- Information about file names found in string list attribute
70 -- Source_Files or in a source list file, stored in hash table
71 -- Source_Names, used by procedure Get_Path_Names_And_Record_Sources.
73 No_Name_Location : constant Name_Location :=
74 (Name => No_Name, Location => No_Location, Found => False);
76 package Source_Names is new GNAT.HTable.Simple_HTable
77 (Header_Num => Header_Num,
78 Element => Name_Location,
79 No_Element => No_Name_Location,
83 -- Hash table to store file names found in string list attribute
84 -- Source_Files or in a source list file, stored in hash table
85 -- Source_Names, used by procedure Get_Path_Names_And_Record_Sources.
87 package Recursive_Dirs is new GNAT.HTable.Simple_HTable
88 (Header_Num => Header_Num,
94 -- Hash table to store recursive source directories, to avoid looking
95 -- several times, and to avoid cycles that may be introduced by symbolic
98 type Ada_Naming_Exception_Id is new Nat;
99 No_Ada_Naming_Exception : constant Ada_Naming_Exception_Id := 0;
101 type Unit_Info is record
104 Next : Ada_Naming_Exception_Id := No_Ada_Naming_Exception;
106 -- No_Unit : constant Unit_Info :=
107 -- (Specification, No_Name, No_Ada_Naming_Exception);
109 package Ada_Naming_Exception_Table is new Table.Table
110 (Table_Component_Type => Unit_Info,
111 Table_Index_Type => Ada_Naming_Exception_Id,
112 Table_Low_Bound => 1,
114 Table_Increment => 100,
115 Table_Name => "Prj.Nmsc.Ada_Naming_Exception_Table");
117 package Ada_Naming_Exceptions is new GNAT.HTable.Simple_HTable
118 (Header_Num => Header_Num,
119 Element => Ada_Naming_Exception_Id,
120 No_Element => No_Ada_Naming_Exception,
124 -- A hash table to store naming exceptions for Ada. For each file name
125 -- there is one or several unit in table Ada_Naming_Exception_Table.
127 function Hash (Unit : Unit_Info) return Header_Num;
129 type Name_And_Index is record
130 Name : Name_Id := No_Name;
133 No_Name_And_Index : constant Name_And_Index :=
134 (Name => No_Name, Index => 0);
136 package Reverse_Ada_Naming_Exceptions is new GNAT.HTable.Simple_HTable
137 (Header_Num => Header_Num,
138 Element => Name_And_Index,
139 No_Element => No_Name_And_Index,
143 -- A table to check if a unit with an exceptional name will hide
144 -- a source with a file name following the naming convention.
146 function ALI_File_Name (Source : String) return String;
147 -- Return the ALI file name corresponding to a source
149 procedure Check_Ada_Name (Name : String; Unit : out Name_Id);
150 -- Check that a name is a valid Ada unit name
152 procedure Check_Naming_Scheme
153 (Data : in out Project_Data;
154 Project : Project_Id;
155 In_Tree : Project_Tree_Ref);
156 -- Check the naming scheme part of Data
158 procedure Check_Ada_Naming_Scheme_Validity
159 (Project : Project_Id;
160 In_Tree : Project_Tree_Ref;
161 Naming : Naming_Data);
162 -- Check that the package Naming is correct
164 procedure Check_For_Source
165 (File_Name : Name_Id;
167 Project : Project_Id;
168 In_Tree : Project_Tree_Ref;
169 Data : in out Project_Data;
170 Location : Source_Ptr;
171 Language : Language_Index;
173 Naming_Exception : Boolean);
174 -- Check if a file, with name File_Name and path Path_Name, in a source
175 -- directory is a source for language Language in project Project of
176 -- project tree In_Tree. ???
178 procedure Check_If_Externally_Built
179 (Project : Project_Id;
180 In_Tree : Project_Tree_Ref;
181 Data : in out Project_Data);
182 -- Check attribute Externally_Built of project Project in project tree
183 -- In_Tree and modify its data Data if it has the value "true".
185 procedure Check_Library_Attributes
186 (Project : Project_Id;
187 In_Tree : Project_Tree_Ref;
188 Data : in out Project_Data);
189 -- Check the library attributes of project Project in project tree In_Tree
190 -- and modify its data Data accordingly.
192 procedure Check_Package_Naming
193 (Project : Project_Id;
194 In_Tree : Project_Tree_Ref;
195 Data : in out Project_Data);
196 -- Check package Naming of project Project in project tree In_Tree and
197 -- modify its data Data accordingly.
199 procedure Check_Programming_Languages
200 (In_Tree : Project_Tree_Ref; Data : in out Project_Data);
201 -- Check attribute Languages for the project with data Data in project
202 -- tree In_Tree and set the components of Data for all the programming
203 -- languages indicated in attribute Languages, if any.
205 function Check_Project
207 Root_Project : Project_Id;
208 In_Tree : Project_Tree_Ref;
209 Extending : Boolean) return Boolean;
210 -- Returns True if P is Root_Project or, if Extending is True, a project
211 -- extended by Root_Project.
213 procedure Check_Stand_Alone_Library
214 (Project : Project_Id;
215 In_Tree : Project_Tree_Ref;
216 Data : in out Project_Data;
217 Extending : Boolean);
218 -- Check if project Project in project tree In_Tree is a Stand-Alone
219 -- Library project, and modify its data Data accordingly if it is one.
221 function Compute_Directory_Last (Dir : String) return Natural;
222 -- Return the index of the last significant character in Dir. This is used
223 -- to avoid duplicates '/' at the end of directory names
225 function Body_Suffix_Of
226 (Language : Language_Index;
227 In_Project : Project_Data;
228 In_Tree : Project_Tree_Ref)
230 -- Returns the suffix of sources of language Language in project In_Project
231 -- in project tree In_Tree.
234 (Project : Project_Id;
235 In_Tree : Project_Tree_Ref;
237 Flag_Location : Source_Ptr);
238 -- Output an error message. If Error_Report is null, simply call
239 -- Prj.Err.Error_Msg. Otherwise, disregard Flag_Location and use
242 procedure Find_Sources
243 (Project : Project_Id;
244 In_Tree : Project_Tree_Ref;
245 Data : in out Project_Data;
246 For_Language : Language_Index;
247 Follow_Links : Boolean := False);
248 -- Find all the sources in all of the source directories of a project for
249 -- a specified language.
251 procedure Free_Ada_Naming_Exceptions;
252 -- Free the internal hash tables used for checking naming exceptions
254 procedure Get_Directories
255 (Project : Project_Id;
256 In_Tree : Project_Tree_Ref;
257 Data : in out Project_Data);
258 -- Get the object directory, the exec directory and the source directories
262 (Project : Project_Id;
263 In_Tree : Project_Tree_Ref;
264 Data : in out Project_Data);
265 -- Get the mains of a project from attribute Main, if it exists, and put
266 -- them in the project data.
268 procedure Get_Sources_From_File
270 Location : Source_Ptr;
271 Project : Project_Id;
272 In_Tree : Project_Tree_Ref);
273 -- Get the list of sources from a text file and put them in hash table
277 (Canonical_File_Name : Name_Id;
278 Naming : Naming_Data;
279 Exception_Id : out Ada_Naming_Exception_Id;
280 Unit_Name : out Name_Id;
281 Unit_Kind : out Spec_Or_Body;
282 Needs_Pragma : out Boolean);
283 -- Find out, from a file name, the unit name, the unit kind and if a
284 -- specific SFN pragma is needed. If the file name corresponds to no
285 -- unit, then Unit_Name will be No_Name. If the file is a multi-unit source
286 -- or an exception to the naming scheme, then Exception_Id is set to
287 -- the unit or units that the source contains.
289 function Is_Illegal_Suffix
291 Dot_Replacement_Is_A_Single_Dot : Boolean) return Boolean;
292 -- Returns True if the string Suffix cannot be used as
293 -- a spec suffix, a body suffix or a separate suffix.
295 procedure Locate_Directory
299 Display : out Name_Id);
300 -- Locate a directory (returns No_Name for Dir and Display if directory
301 -- does not exist). Name is the directory name. Parent is the root
302 -- directory, if Name is a relative path name. Dir is the canonical case
303 -- path name of the directory, Display is the directory path name for
306 procedure Look_For_Sources
307 (Project : Project_Id;
308 In_Tree : Project_Tree_Ref;
309 Data : in out Project_Data;
310 Follow_Links : Boolean);
311 -- Find all the sources of a project
313 function Path_Name_Of
314 (File_Name : Name_Id;
315 Directory : Name_Id) return String;
316 -- Returns the path name of a (non project) file.
317 -- Returns an empty string if file cannot be found.
319 procedure Prepare_Ada_Naming_Exceptions
320 (List : Array_Element_Id;
321 In_Tree : Project_Tree_Ref;
322 Kind : Spec_Or_Body);
323 -- Prepare the internal hash tables used for checking naming exceptions
324 -- for Ada. Insert all elements of List in the tables.
326 function Project_Extends
327 (Extending : Project_Id;
328 Extended : Project_Id;
329 In_Tree : Project_Tree_Ref) return Boolean;
330 -- Returns True if Extending is extending Extended either directly or
333 procedure Record_Ada_Source
334 (File_Name : Name_Id;
336 Project : Project_Id;
337 In_Tree : Project_Tree_Ref;
338 Data : in out Project_Data;
339 Location : Source_Ptr;
340 Current_Source : in out String_List_Id;
341 Source_Recorded : in out Boolean;
342 Follow_Links : Boolean);
343 -- Put a unit in the list of units of a project, if the file name
344 -- corresponds to a valid unit name.
346 procedure Record_Other_Sources
347 (Project : Project_Id;
348 In_Tree : Project_Tree_Ref;
349 Data : in out Project_Data;
350 Language : Language_Index;
351 Naming_Exceptions : Boolean);
352 -- Record the sources of a language in a project.
353 -- When Naming_Exceptions is True, mark the found sources as such, to
354 -- later remove those that are not named in a list of sources.
356 procedure Show_Source_Dirs
357 (Project : Project_Id; In_Tree : Project_Tree_Ref);
358 -- List all the source directories of a project
361 (Language : Language_Index;
362 Naming : Naming_Data;
363 In_Tree : Project_Tree_Ref) return Name_Id;
364 -- Get the suffix for the source of a language from a package naming.
365 -- If not specified, return the default for the language.
367 procedure Warn_If_Not_Sources
368 (Project : Project_Id;
369 In_Tree : Project_Tree_Ref;
370 Conventions : Array_Element_Id;
372 Extending : Boolean);
373 -- Check that individual naming conventions apply to immediate
374 -- sources of the project; if not, issue a warning.
380 function ALI_File_Name (Source : String) return String is
382 -- If the source name has an extension, then replace it with
385 for Index in reverse Source'First + 1 .. Source'Last loop
386 if Source (Index) = '.' then
387 return Source (Source'First .. Index - 1) & ALI_Suffix;
391 -- If there is no dot, or if it is the first character, just add the
394 return Source & ALI_Suffix;
402 (Project : Project_Id;
403 In_Tree : Project_Tree_Ref;
404 Report_Error : Put_Line_Access;
405 Follow_Links : Boolean)
407 Data : Project_Data := In_Tree.Projects.Table (Project);
408 Extending : Boolean := False;
411 Error_Report := Report_Error;
413 Recursive_Dirs.Reset;
415 -- Object, exec and source directories
417 Get_Directories (Project, In_Tree, Data);
419 -- Get the programming languages
421 Check_Programming_Languages (In_Tree, Data);
423 -- Library attributes
425 Check_Library_Attributes (Project, In_Tree, Data);
427 Check_If_Externally_Built (Project, In_Tree, Data);
429 if Current_Verbosity = High then
430 Show_Source_Dirs (Project, In_Tree);
433 Check_Package_Naming (Project, In_Tree, Data);
435 Extending := Data.Extends /= No_Project;
437 Check_Naming_Scheme (Data, Project, In_Tree);
439 Prepare_Ada_Naming_Exceptions
440 (Data.Naming.Bodies, In_Tree, Body_Part);
441 Prepare_Ada_Naming_Exceptions
442 (Data.Naming.Specs, In_Tree, Specification);
446 if Data.Source_Dirs /= Nil_String then
447 Look_For_Sources (Project, In_Tree, Data, Follow_Links);
450 if Data.Ada_Sources_Present then
452 -- Check that all individual naming conventions apply to sources of
453 -- this project file.
456 (Project, In_Tree, Data.Naming.Bodies,
458 Extending => Extending);
460 (Project, In_Tree, Data.Naming.Specs,
462 Extending => Extending);
465 -- If it is a library project file, check if it is a standalone library
468 Check_Stand_Alone_Library (Project, In_Tree, Data, Extending);
471 -- Put the list of Mains, if any, in the project data
473 Get_Mains (Project, In_Tree, Data);
475 -- Update the project data in the Projects table
477 In_Tree.Projects.Table (Project) := Data;
479 Free_Ada_Naming_Exceptions;
486 procedure Check_Ada_Name (Name : String; Unit : out Name_Id) is
487 The_Name : String := Name;
489 Need_Letter : Boolean := True;
490 Last_Underscore : Boolean := False;
491 OK : Boolean := The_Name'Length > 0;
496 Name_Len := The_Name'Length;
497 Name_Buffer (1 .. Name_Len) := The_Name;
498 Real_Name := Name_Find;
500 -- Check first that the given name is not an Ada reserved word
502 if Get_Name_Table_Byte (Real_Name) /= 0
503 and then Real_Name /= Name_Project
504 and then Real_Name /= Name_Extends
505 and then Real_Name /= Name_External
509 if Current_Verbosity = High then
510 Write_Str (The_Name);
511 Write_Line (" is an Ada reserved word.");
517 for Index in The_Name'Range loop
520 -- We need a letter (at the beginning, and following a dot),
521 -- but we don't have one.
523 if Is_Letter (The_Name (Index)) then
524 Need_Letter := False;
529 if Current_Verbosity = High then
530 Write_Int (Types.Int (Index));
532 Write_Char (The_Name (Index));
533 Write_Line ("' is not a letter.");
539 elsif Last_Underscore
540 and then (The_Name (Index) = '_' or else The_Name (Index) = '.')
542 -- Two underscores are illegal, and a dot cannot follow
547 if Current_Verbosity = High then
548 Write_Int (Types.Int (Index));
550 Write_Char (The_Name (Index));
551 Write_Line ("' is illegal here.");
556 elsif The_Name (Index) = '.' then
558 -- We need a letter after a dot
562 elsif The_Name (Index) = '_' then
563 Last_Underscore := True;
566 -- We need an letter or a digit
568 Last_Underscore := False;
570 if not Is_Alphanumeric (The_Name (Index)) then
573 if Current_Verbosity = High then
574 Write_Int (Types.Int (Index));
576 Write_Char (The_Name (Index));
577 Write_Line ("' is not alphanumeric.");
585 -- Cannot end with an underscore or a dot
587 OK := OK and then not Need_Letter and then not Last_Underscore;
593 -- Signal a problem with No_Name
599 --------------------------------------
600 -- Check_Ada_Naming_Scheme_Validity --
601 --------------------------------------
603 procedure Check_Ada_Naming_Scheme_Validity
604 (Project : Project_Id;
605 In_Tree : Project_Tree_Ref;
606 Naming : Naming_Data)
609 -- Only check if we are not using the Default naming scheme
611 if Naming /= In_Tree.Private_Part.Default_Naming then
613 Dot_Replacement : constant String :=
615 (Naming.Dot_Replacement);
617 Spec_Suffix : constant String :=
619 (Naming.Ada_Spec_Suffix);
621 Body_Suffix : constant String :=
623 (Naming.Ada_Body_Suffix);
625 Separate_Suffix : constant String :=
627 (Naming.Separate_Suffix);
630 -- Dot_Replacement cannot
632 -- - start or end with an alphanumeric
634 -- - start with an '_' followed by an alphanumeric
635 -- - contain a '.' except if it is "."
637 if Dot_Replacement'Length = 0
638 or else Is_Alphanumeric
639 (Dot_Replacement (Dot_Replacement'First))
640 or else Is_Alphanumeric
641 (Dot_Replacement (Dot_Replacement'Last))
642 or else (Dot_Replacement (Dot_Replacement'First) = '_'
644 (Dot_Replacement'Length = 1
647 (Dot_Replacement (Dot_Replacement'First + 1))))
648 or else (Dot_Replacement'Length > 1
650 Index (Source => Dot_Replacement,
651 Pattern => ".") /= 0)
655 '"' & Dot_Replacement &
656 """ is illegal for Dot_Replacement.",
657 Naming.Dot_Repl_Loc);
664 (Spec_Suffix, Dot_Replacement = ".")
666 Err_Vars.Error_Msg_Name_1 := Naming.Ada_Spec_Suffix;
669 "{ is illegal for Spec_Suffix",
670 Naming.Spec_Suffix_Loc);
674 (Body_Suffix, Dot_Replacement = ".")
676 Err_Vars.Error_Msg_Name_1 := Naming.Ada_Body_Suffix;
679 "{ is illegal for Body_Suffix",
680 Naming.Body_Suffix_Loc);
683 if Body_Suffix /= Separate_Suffix then
685 (Separate_Suffix, Dot_Replacement = ".")
687 Err_Vars.Error_Msg_Name_1 := Naming.Separate_Suffix;
690 "{ is illegal for Separate_Suffix",
691 Naming.Sep_Suffix_Loc);
695 -- Spec_Suffix cannot have the same termination as
696 -- Body_Suffix or Separate_Suffix
698 if Spec_Suffix'Length <= Body_Suffix'Length
700 Body_Suffix (Body_Suffix'Last -
701 Spec_Suffix'Length + 1 ..
702 Body_Suffix'Last) = Spec_Suffix
708 """) cannot end with" &
710 Spec_Suffix & """).",
711 Naming.Body_Suffix_Loc);
714 if Body_Suffix /= Separate_Suffix
715 and then Spec_Suffix'Length <= Separate_Suffix'Length
718 (Separate_Suffix'Last - Spec_Suffix'Length + 1
720 Separate_Suffix'Last) = Spec_Suffix
724 "Separate_Suffix (""" &
726 """) cannot end with" &
728 Spec_Suffix & """).",
729 Naming.Sep_Suffix_Loc);
733 end Check_Ada_Naming_Scheme_Validity;
735 ----------------------
736 -- Check_For_Source --
737 ----------------------
739 procedure Check_For_Source
740 (File_Name : Name_Id;
742 Project : Project_Id;
743 In_Tree : Project_Tree_Ref;
744 Data : in out Project_Data;
745 Location : Source_Ptr;
746 Language : Language_Index;
748 Naming_Exception : Boolean)
750 Name : String := Get_Name_String (File_Name);
751 Real_Location : Source_Ptr := Location;
754 Canonical_Case_File_Name (Name);
756 -- A file is a source of a language if Naming_Exception is True (case
757 -- of naming exceptions) or if its file name ends with the suffix.
759 if Naming_Exception or else
760 (Name'Length > Suffix'Length and then
761 Name (Name'Last - Suffix'Length + 1 .. Name'Last) = Suffix)
763 if Real_Location = No_Location then
764 Real_Location := Data.Location;
768 Path : String := Get_Name_String (Path_Name);
771 -- The path name id (in canonical case)
774 -- The file name id (in canonical case)
777 -- The object file name
779 Obj_Path_Id : Name_Id;
780 -- The object path name
783 -- The dependency file name
785 Dep_Path_Id : Name_Id;
786 -- The dependency path name
788 Dot_Pos : Natural := 0;
789 -- Position of the last dot in Name
791 Source : Other_Source;
792 Source_Id : Other_Source_Id := Data.First_Other_Source;
795 Canonical_Case_File_Name (Path);
797 -- Get the file name id
799 Name_Len := Name'Length;
800 Name_Buffer (1 .. Name_Len) := Name;
801 File_Id := Name_Find;
803 -- Get the path name id
805 Name_Len := Path'Length;
806 Name_Buffer (1 .. Name_Len) := Path;
807 Path_Id := Name_Find;
809 -- Find the position of the last dot
811 for J in reverse Name'Range loop
812 if Name (J) = '.' then
818 if Dot_Pos <= Name'First then
819 Dot_Pos := Name'Last + 1;
822 -- Compute the object file name
824 Get_Name_String (File_Id);
825 Name_Len := Dot_Pos - Name'First;
827 for J in Object_Suffix'Range loop
828 Name_Len := Name_Len + 1;
829 Name_Buffer (Name_Len) := Object_Suffix (J);
834 -- Compute the object path name
836 Get_Name_String (Data.Object_Directory);
838 if Name_Buffer (Name_Len) /= Directory_Separator and then
839 Name_Buffer (Name_Len) /= '/'
841 Name_Len := Name_Len + 1;
842 Name_Buffer (Name_Len) := Directory_Separator;
845 Add_Str_To_Name_Buffer (Get_Name_String (Obj_Id));
846 Obj_Path_Id := Name_Find;
848 -- Compute the dependency file name
850 Get_Name_String (File_Id);
851 Name_Len := Dot_Pos - Name'First + 1;
852 Name_Buffer (Name_Len) := '.';
853 Name_Len := Name_Len + 1;
854 Name_Buffer (Name_Len) := 'd';
857 -- Compute the dependency path name
859 Get_Name_String (Data.Object_Directory);
861 if Name_Buffer (Name_Len) /= Directory_Separator and then
862 Name_Buffer (Name_Len) /= '/'
864 Name_Len := Name_Len + 1;
865 Name_Buffer (Name_Len) := Directory_Separator;
868 Add_Str_To_Name_Buffer (Get_Name_String (Dep_Id));
869 Dep_Path_Id := Name_Find;
871 -- Check if source is already in the list of source for this
872 -- project: it may have already been specified as a naming
873 -- exception for the same language or an other language, or
874 -- they may be two identical file names in different source
877 while Source_Id /= No_Other_Source loop
878 Source := In_Tree.Other_Sources.Table (Source_Id);
879 Source_Id := Source.Next;
881 if Source.File_Name = File_Id then
883 -- Two sources of different languages cannot have the same
886 if Source.Language /= Language then
887 Error_Msg_Name_1 := File_Name;
890 "{ cannot be a source of several languages",
894 -- No problem if a file has already been specified as
895 -- a naming exception of this language.
897 elsif Source.Path_Name = Path_Id then
899 -- Reset the naming exception flag, if this is not a
902 if not Naming_Exception then
903 In_Tree.Other_Sources.Table
904 (Source_Id).Naming_Exception := False;
909 -- There are several files with the same names, but the
910 -- order of the source directories is known (no /**):
911 -- only the first one encountered is kept, the other ones
914 elsif Data.Known_Order_Of_Source_Dirs then
917 -- But it is an error if the order of the source directories
921 Error_Msg_Name_1 := File_Name;
924 "{ is found in several source directories",
929 -- Two sources with different file names cannot have the same
932 elsif Source.Object_Name = Obj_Id then
933 Error_Msg_Name_1 := File_Id;
934 Error_Msg_Name_2 := Source.File_Name;
935 Error_Msg_Name_3 := Obj_Id;
938 "{ and { have the same object file {",
944 if Current_Verbosity = High then
945 Write_Str (" found ");
946 Display_Language_Name (Language);
947 Write_Str (" source """);
948 Write_Str (Get_Name_String (File_Name));
950 Write_Str (" object path = ");
951 Write_Line (Get_Name_String (Obj_Path_Id));
954 -- Create the Other_Source record
957 (Language => Language,
958 File_Name => File_Id,
959 Path_Name => Path_Id,
960 Source_TS => File_Stamp (Path_Id),
961 Object_Name => Obj_Id,
962 Object_Path => Obj_Path_Id,
963 Object_TS => File_Stamp (Obj_Path_Id),
965 Dep_Path => Dep_Path_Id,
966 Dep_TS => File_Stamp (Dep_Path_Id),
967 Naming_Exception => Naming_Exception,
968 Next => No_Other_Source);
970 -- And add it to the Other_Sources table
972 Other_Source_Table.Increment_Last
973 (In_Tree.Other_Sources);
974 In_Tree.Other_Sources.Table
975 (Other_Source_Table.Last (In_Tree.Other_Sources)) :=
978 -- There are sources of languages other than Ada in this project
980 Data.Other_Sources_Present := True;
982 -- And there are sources of this language in this project
984 Set (Language, True, Data, In_Tree);
986 -- Add this source to the list of sources of languages other than
987 -- Ada of the project.
989 if Data.First_Other_Source = No_Other_Source then
990 Data.First_Other_Source :=
991 Other_Source_Table.Last (In_Tree.Other_Sources);
994 In_Tree.Other_Sources.Table (Data.Last_Other_Source).Next :=
995 Other_Source_Table.Last (In_Tree.Other_Sources);
998 Data.Last_Other_Source :=
999 Other_Source_Table.Last (In_Tree.Other_Sources);
1002 end Check_For_Source;
1004 -------------------------------
1005 -- Check_If_Externally_Built --
1006 -------------------------------
1008 procedure Check_If_Externally_Built
1009 (Project : Project_Id;
1010 In_Tree : Project_Tree_Ref;
1011 Data : in out Project_Data)
1013 Externally_Built : constant Variable_Value :=
1015 (Name_Externally_Built,
1016 Data.Decl.Attributes, In_Tree);
1019 if not Externally_Built.Default then
1020 Get_Name_String (Externally_Built.Value);
1021 To_Lower (Name_Buffer (1 .. Name_Len));
1023 if Name_Buffer (1 .. Name_Len) = "true" then
1024 Data.Externally_Built := True;
1026 elsif Name_Buffer (1 .. Name_Len) /= "false" then
1027 Error_Msg (Project, In_Tree,
1028 "Externally_Built may only be true or false",
1029 Externally_Built.Location);
1033 if Current_Verbosity = High then
1034 Write_Str ("Project is ");
1036 if not Data.Externally_Built then
1040 Write_Line ("externally built.");
1042 end Check_If_Externally_Built;
1044 -----------------------------
1045 -- Check_Naming_Scheme --
1046 -----------------------------
1048 procedure Check_Naming_Scheme
1049 (Data : in out Project_Data;
1050 Project : Project_Id;
1051 In_Tree : Project_Tree_Ref)
1053 Naming_Id : constant Package_Id :=
1054 Util.Value_Of (Name_Naming, Data.Decl.Packages, In_Tree);
1056 Naming : Package_Element;
1058 procedure Check_Unit_Names (List : Array_Element_Id);
1059 -- Check that a list of unit names contains only valid names
1061 ----------------------
1062 -- Check_Unit_Names --
1063 ----------------------
1065 procedure Check_Unit_Names (List : Array_Element_Id) is
1066 Current : Array_Element_Id := List;
1067 Element : Array_Element;
1068 Unit_Name : Name_Id;
1071 -- Loop through elements of the string list
1073 while Current /= No_Array_Element loop
1074 Element := In_Tree.Array_Elements.Table (Current);
1076 -- Put file name in canonical case
1078 Get_Name_String (Element.Value.Value);
1079 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
1080 Element.Value.Value := Name_Find;
1082 -- Check that it contains a valid unit name
1084 Get_Name_String (Element.Index);
1085 Check_Ada_Name (Name_Buffer (1 .. Name_Len), Unit_Name);
1087 if Unit_Name = No_Name then
1088 Err_Vars.Error_Msg_Name_1 := Element.Index;
1091 "{ is not a valid unit name.",
1092 Element.Value.Location);
1095 if Current_Verbosity = High then
1096 Write_Str (" Unit (""");
1097 Write_Str (Get_Name_String (Unit_Name));
1101 Element.Index := Unit_Name;
1102 In_Tree.Array_Elements.Table (Current) := Element;
1105 Current := Element.Next;
1107 end Check_Unit_Names;
1109 -- Start of processing for Check_Naming_Scheme
1112 -- If there is a package Naming, we will put in Data.Naming what is in
1113 -- this package Naming.
1115 if Naming_Id /= No_Package then
1116 Naming := In_Tree.Packages.Table (Naming_Id);
1118 if Current_Verbosity = High then
1119 Write_Line ("Checking ""Naming"" for Ada.");
1123 Bodies : constant Array_Element_Id :=
1124 Util.Value_Of (Name_Body, Naming.Decl.Arrays, In_Tree);
1126 Specs : constant Array_Element_Id :=
1127 Util.Value_Of (Name_Spec, Naming.Decl.Arrays, In_Tree);
1130 if Bodies /= No_Array_Element then
1132 -- We have elements in the array Body_Part
1134 if Current_Verbosity = High then
1135 Write_Line ("Found Bodies.");
1138 Data.Naming.Bodies := Bodies;
1139 Check_Unit_Names (Bodies);
1142 if Current_Verbosity = High then
1143 Write_Line ("No Bodies.");
1147 if Specs /= No_Array_Element then
1149 -- We have elements in the array Specs
1151 if Current_Verbosity = High then
1152 Write_Line ("Found Specs.");
1155 Data.Naming.Specs := Specs;
1156 Check_Unit_Names (Specs);
1159 if Current_Verbosity = High then
1160 Write_Line ("No Specs.");
1165 -- We are now checking if variables Dot_Replacement, Casing,
1166 -- Spec_Suffix, Body_Suffix and/or Separate_Suffix
1169 -- For each variable, if it does not exist, we do nothing,
1170 -- because we already have the default.
1172 -- Check Dot_Replacement
1175 Dot_Replacement : constant Variable_Value :=
1177 (Name_Dot_Replacement,
1178 Naming.Decl.Attributes, In_Tree);
1181 pragma Assert (Dot_Replacement.Kind = Single,
1182 "Dot_Replacement is not a single string");
1184 if not Dot_Replacement.Default then
1185 Get_Name_String (Dot_Replacement.Value);
1187 if Name_Len = 0 then
1190 "Dot_Replacement cannot be empty",
1191 Dot_Replacement.Location);
1194 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
1195 Data.Naming.Dot_Replacement := Name_Find;
1196 Data.Naming.Dot_Repl_Loc := Dot_Replacement.Location;
1201 if Current_Verbosity = High then
1202 Write_Str (" Dot_Replacement = """);
1203 Write_Str (Get_Name_String (Data.Naming.Dot_Replacement));
1211 Casing_String : constant Variable_Value :=
1213 (Name_Casing, Naming.Decl.Attributes, In_Tree);
1216 pragma Assert (Casing_String.Kind = Single,
1217 "Casing is not a single string");
1219 if not Casing_String.Default then
1221 Casing_Image : constant String :=
1222 Get_Name_String (Casing_String.Value);
1225 Casing_Value : constant Casing_Type :=
1226 Value (Casing_Image);
1228 Data.Naming.Casing := Casing_Value;
1232 when Constraint_Error =>
1233 if Casing_Image'Length = 0 then
1236 "Casing cannot be an empty string",
1237 Casing_String.Location);
1240 Name_Len := Casing_Image'Length;
1241 Name_Buffer (1 .. Name_Len) := Casing_Image;
1242 Err_Vars.Error_Msg_Name_1 := Name_Find;
1245 "{ is not a correct Casing",
1246 Casing_String.Location);
1252 if Current_Verbosity = High then
1253 Write_Str (" Casing = ");
1254 Write_Str (Image (Data.Naming.Casing));
1259 -- Check Spec_Suffix
1262 Ada_Spec_Suffix : constant Variable_Value :=
1266 In_Array => Data.Naming.Spec_Suffix,
1267 In_Tree => In_Tree);
1270 if Ada_Spec_Suffix.Kind = Single
1271 and then Get_Name_String (Ada_Spec_Suffix.Value) /= ""
1273 Get_Name_String (Ada_Spec_Suffix.Value);
1274 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
1275 Data.Naming.Ada_Spec_Suffix := Name_Find;
1276 Data.Naming.Spec_Suffix_Loc := Ada_Spec_Suffix.Location;
1279 Data.Naming.Ada_Spec_Suffix := Default_Ada_Spec_Suffix;
1283 if Current_Verbosity = High then
1284 Write_Str (" Spec_Suffix = """);
1285 Write_Str (Get_Name_String (Data.Naming.Ada_Spec_Suffix));
1290 -- Check Body_Suffix
1293 Ada_Body_Suffix : constant Variable_Value :=
1297 In_Array => Data.Naming.Body_Suffix,
1298 In_Tree => In_Tree);
1301 if Ada_Body_Suffix.Kind = Single
1302 and then Get_Name_String (Ada_Body_Suffix.Value) /= ""
1304 Get_Name_String (Ada_Body_Suffix.Value);
1305 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
1306 Data.Naming.Ada_Body_Suffix := Name_Find;
1307 Data.Naming.Body_Suffix_Loc := Ada_Body_Suffix.Location;
1310 Data.Naming.Ada_Body_Suffix := Default_Ada_Body_Suffix;
1314 if Current_Verbosity = High then
1315 Write_Str (" Body_Suffix = """);
1316 Write_Str (Get_Name_String (Data.Naming.Ada_Body_Suffix));
1321 -- Check Separate_Suffix
1324 Ada_Sep_Suffix : constant Variable_Value :=
1326 (Variable_Name => Name_Separate_Suffix,
1327 In_Variables => Naming.Decl.Attributes,
1328 In_Tree => In_Tree);
1331 if Ada_Sep_Suffix.Default then
1332 Data.Naming.Separate_Suffix :=
1333 Data.Naming.Ada_Body_Suffix;
1336 Get_Name_String (Ada_Sep_Suffix.Value);
1338 if Name_Len = 0 then
1341 "Separate_Suffix cannot be empty",
1342 Ada_Sep_Suffix.Location);
1345 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
1346 Data.Naming.Separate_Suffix := Name_Find;
1347 Data.Naming.Sep_Suffix_Loc := Ada_Sep_Suffix.Location;
1352 if Current_Verbosity = High then
1353 Write_Str (" Separate_Suffix = """);
1354 Write_Str (Get_Name_String (Data.Naming.Separate_Suffix));
1359 -- Check if Data.Naming is valid
1361 Check_Ada_Naming_Scheme_Validity (Project, In_Tree, Data.Naming);
1364 Data.Naming.Ada_Spec_Suffix := Default_Ada_Spec_Suffix;
1365 Data.Naming.Ada_Body_Suffix := Default_Ada_Body_Suffix;
1366 Data.Naming.Separate_Suffix := Default_Ada_Body_Suffix;
1368 end Check_Naming_Scheme;
1370 ------------------------------
1371 -- Check_Library_Attributes --
1372 ------------------------------
1374 procedure Check_Library_Attributes
1375 (Project : Project_Id;
1376 In_Tree : Project_Tree_Ref;
1377 Data : in out Project_Data)
1379 Attributes : constant Prj.Variable_Id := Data.Decl.Attributes;
1381 Lib_Dir : constant Prj.Variable_Value :=
1383 (Snames.Name_Library_Dir, Attributes, In_Tree);
1385 Lib_Name : constant Prj.Variable_Value :=
1387 (Snames.Name_Library_Name, Attributes, In_Tree);
1389 Lib_Version : constant Prj.Variable_Value :=
1391 (Snames.Name_Library_Version, Attributes, In_Tree);
1393 The_Lib_Kind : constant Prj.Variable_Value :=
1395 (Snames.Name_Library_Kind, Attributes, In_Tree);
1398 -- Special case of extending project
1400 if Data.Extends /= No_Project then
1402 Extended_Data : constant Project_Data :=
1403 In_Tree.Projects.Table (Data.Extends);
1406 -- If the project extended is a library project, we inherit
1407 -- the library name, if it is not redefined; we check that
1408 -- the library directory is specified; and we reset the
1409 -- library flag for the extended project.
1411 if Extended_Data.Library then
1412 if Lib_Name.Default then
1413 Data.Library_Name := Extended_Data.Library_Name;
1416 if Lib_Dir.Default then
1417 if not Data.Virtual then
1420 "a project extending a library project must " &
1421 "specify an attribute Library_Dir",
1426 In_Tree.Projects.Table (Data.Extends).Library :=
1432 pragma Assert (Lib_Dir.Kind = Single);
1434 if Lib_Dir.Value = Empty_String then
1435 if Current_Verbosity = High then
1436 Write_Line ("No library directory");
1440 -- Find path name, check that it is a directory
1443 (Lib_Dir.Value, Data.Display_Directory,
1444 Data.Library_Dir, Data.Display_Library_Dir);
1446 if Data.Library_Dir = No_Name then
1448 -- Get the absolute name of the library directory that
1449 -- does not exist, to report an error.
1452 Dir_Name : constant String := Get_Name_String (Lib_Dir.Value);
1455 if Is_Absolute_Path (Dir_Name) then
1456 Err_Vars.Error_Msg_Name_1 := Lib_Dir.Value;
1459 Get_Name_String (Data.Display_Directory);
1461 if Name_Buffer (Name_Len) /= Directory_Separator then
1462 Name_Len := Name_Len + 1;
1463 Name_Buffer (Name_Len) := Directory_Separator;
1467 (Name_Len + 1 .. Name_Len + Dir_Name'Length) :=
1469 Name_Len := Name_Len + Dir_Name'Length;
1470 Err_Vars.Error_Msg_Name_1 := Name_Find;
1477 "library directory { does not exist",
1481 -- The library directory cannot be the same as the Object directory
1483 elsif Data.Library_Dir = Data.Object_Directory then
1486 "library directory cannot be the same " &
1487 "as object directory",
1489 Data.Library_Dir := No_Name;
1490 Data.Display_Library_Dir := No_Name;
1492 -- Display the Library directory in high verbosity
1495 if Current_Verbosity = High then
1496 Write_Str ("Library directory =""");
1497 Write_Str (Get_Name_String (Data.Display_Library_Dir));
1503 pragma Assert (Lib_Name.Kind = Single);
1505 if Lib_Name.Value = Empty_String then
1506 if Current_Verbosity = High
1507 and then Data.Library_Name = No_Name
1509 Write_Line ("No library name");
1513 -- There is no restriction on the syntax of library names
1515 Data.Library_Name := Lib_Name.Value;
1518 if Data.Library_Name /= No_Name
1519 and then Current_Verbosity = High
1521 Write_Str ("Library name = """);
1522 Write_Str (Get_Name_String (Data.Library_Name));
1527 Data.Library_Dir /= No_Name
1529 Data.Library_Name /= No_Name;
1531 if Data.Library then
1532 if MLib.Tgt.Support_For_Libraries = MLib.Tgt.None then
1535 "?libraries are not supported on this platform",
1537 Data.Library := False;
1540 pragma Assert (Lib_Version.Kind = Single);
1542 if Lib_Version.Value = Empty_String then
1543 if Current_Verbosity = High then
1544 Write_Line ("No library version specified");
1548 Data.Lib_Internal_Name := Lib_Version.Value;
1551 pragma Assert (The_Lib_Kind.Kind = Single);
1553 if The_Lib_Kind.Value = Empty_String then
1554 if Current_Verbosity = High then
1555 Write_Line ("No library kind specified");
1559 Get_Name_String (The_Lib_Kind.Value);
1562 Kind_Name : constant String :=
1563 To_Lower (Name_Buffer (1 .. Name_Len));
1565 OK : Boolean := True;
1568 if Kind_Name = "static" then
1569 Data.Library_Kind := Static;
1571 elsif Kind_Name = "dynamic" then
1572 Data.Library_Kind := Dynamic;
1574 elsif Kind_Name = "relocatable" then
1575 Data.Library_Kind := Relocatable;
1580 "illegal value for Library_Kind",
1581 The_Lib_Kind.Location);
1585 if Current_Verbosity = High and then OK then
1586 Write_Str ("Library kind = ");
1587 Write_Line (Kind_Name);
1590 if Data.Library_Kind /= Static and then
1591 MLib.Tgt.Support_For_Libraries = MLib.Tgt.Static_Only
1595 "only static libraries are supported " &
1597 The_Lib_Kind.Location);
1598 Data.Library := False;
1603 if Data.Library and then Current_Verbosity = High then
1604 Write_Line ("This is a library project file");
1609 end Check_Library_Attributes;
1611 --------------------------
1612 -- Check_Package_Naming --
1613 --------------------------
1615 procedure Check_Package_Naming
1616 (Project : Project_Id;
1617 In_Tree : Project_Tree_Ref;
1618 Data : in out Project_Data)
1620 Naming_Id : constant Package_Id :=
1621 Util.Value_Of (Name_Naming, Data.Decl.Packages, In_Tree);
1623 Naming : Package_Element;
1626 -- If there is a package Naming, we will put in Data.Naming
1627 -- what is in this package Naming.
1629 if Naming_Id /= No_Package then
1630 Naming := In_Tree.Packages.Table (Naming_Id);
1632 if Current_Verbosity = High then
1633 Write_Line ("Checking ""Naming"".");
1636 -- Check Spec_Suffix
1639 Spec_Suffixs : Array_Element_Id :=
1645 Suffix : Array_Element_Id;
1646 Element : Array_Element;
1647 Suffix2 : Array_Element_Id;
1650 -- If some suffixs have been specified, we make sure that
1651 -- for each language for which a default suffix has been
1652 -- specified, there is a suffix specified, either the one
1653 -- in the project file or if there were none, the default.
1655 if Spec_Suffixs /= No_Array_Element then
1656 Suffix := Data.Naming.Spec_Suffix;
1658 while Suffix /= No_Array_Element loop
1660 In_Tree.Array_Elements.Table (Suffix);
1661 Suffix2 := Spec_Suffixs;
1663 while Suffix2 /= No_Array_Element loop
1664 exit when In_Tree.Array_Elements.Table
1665 (Suffix2).Index = Element.Index;
1666 Suffix2 := In_Tree.Array_Elements.Table
1670 -- There is a registered default suffix, but no
1671 -- suffix specified in the project file.
1672 -- Add the default to the array.
1674 if Suffix2 = No_Array_Element then
1675 Array_Element_Table.Increment_Last
1676 (In_Tree.Array_Elements);
1677 In_Tree.Array_Elements.Table
1678 (Array_Element_Table.Last
1679 (In_Tree.Array_Elements)) :=
1680 (Index => Element.Index,
1681 Src_Index => Element.Src_Index,
1682 Index_Case_Sensitive => False,
1683 Value => Element.Value,
1684 Next => Spec_Suffixs);
1685 Spec_Suffixs := Array_Element_Table.Last
1686 (In_Tree.Array_Elements);
1689 Suffix := Element.Next;
1692 -- Put the resulting array as the specification suffixs
1694 Data.Naming.Spec_Suffix := Spec_Suffixs;
1699 Current : Array_Element_Id := Data.Naming.Spec_Suffix;
1700 Element : Array_Element;
1703 while Current /= No_Array_Element loop
1704 Element := In_Tree.Array_Elements.Table (Current);
1705 Get_Name_String (Element.Value.Value);
1707 if Name_Len = 0 then
1710 "Spec_Suffix cannot be empty",
1711 Element.Value.Location);
1714 In_Tree.Array_Elements.Table (Current) := Element;
1715 Current := Element.Next;
1719 -- Check Body_Suffix
1722 Impl_Suffixs : Array_Element_Id :=
1728 Suffix : Array_Element_Id;
1729 Element : Array_Element;
1730 Suffix2 : Array_Element_Id;
1733 -- If some suffixes have been specified, we make sure that
1734 -- for each language for which a default suffix has been
1735 -- specified, there is a suffix specified, either the one
1736 -- in the project file or if there were noe, the default.
1738 if Impl_Suffixs /= No_Array_Element then
1739 Suffix := Data.Naming.Body_Suffix;
1741 while Suffix /= No_Array_Element loop
1743 In_Tree.Array_Elements.Table (Suffix);
1744 Suffix2 := Impl_Suffixs;
1746 while Suffix2 /= No_Array_Element loop
1747 exit when In_Tree.Array_Elements.Table
1748 (Suffix2).Index = Element.Index;
1749 Suffix2 := In_Tree.Array_Elements.Table
1753 -- There is a registered default suffix, but no suffix was
1754 -- specified in the project file. Add the default to the
1757 if Suffix2 = No_Array_Element then
1758 Array_Element_Table.Increment_Last
1759 (In_Tree.Array_Elements);
1760 In_Tree.Array_Elements.Table
1761 (Array_Element_Table.Last
1762 (In_Tree.Array_Elements)) :=
1763 (Index => Element.Index,
1764 Src_Index => Element.Src_Index,
1765 Index_Case_Sensitive => False,
1766 Value => Element.Value,
1767 Next => Impl_Suffixs);
1768 Impl_Suffixs := Array_Element_Table.Last
1769 (In_Tree.Array_Elements);
1772 Suffix := Element.Next;
1775 -- Put the resulting array as the implementation suffixs
1777 Data.Naming.Body_Suffix := Impl_Suffixs;
1782 Current : Array_Element_Id := Data.Naming.Body_Suffix;
1783 Element : Array_Element;
1786 while Current /= No_Array_Element loop
1787 Element := In_Tree.Array_Elements.Table (Current);
1788 Get_Name_String (Element.Value.Value);
1790 if Name_Len = 0 then
1793 "Body_Suffix cannot be empty",
1794 Element.Value.Location);
1797 In_Tree.Array_Elements.Table (Current) := Element;
1798 Current := Element.Next;
1802 -- Get the exceptions, if any
1804 Data.Naming.Specification_Exceptions :=
1806 (Name_Specification_Exceptions,
1807 In_Arrays => Naming.Decl.Arrays,
1808 In_Tree => In_Tree);
1810 Data.Naming.Implementation_Exceptions :=
1812 (Name_Implementation_Exceptions,
1813 In_Arrays => Naming.Decl.Arrays,
1814 In_Tree => In_Tree);
1816 end Check_Package_Naming;
1818 ---------------------------------
1819 -- Check_Programming_Languages --
1820 ---------------------------------
1822 procedure Check_Programming_Languages
1823 (In_Tree : Project_Tree_Ref;
1824 Data : in out Project_Data)
1826 Languages : Variable_Value := Nil_Variable_Value;
1830 Prj.Util.Value_Of (Name_Languages, Data.Decl.Attributes, In_Tree);
1831 Data.Ada_Sources_Present := Data.Source_Dirs /= Nil_String;
1832 Data.Other_Sources_Present := Data.Source_Dirs /= Nil_String;
1834 if Data.Source_Dirs /= Nil_String then
1836 -- Check if languages are specified in this project
1838 if Languages.Default then
1840 -- Attribute Languages is not specified. So, it defaults to
1841 -- a project of language Ada only.
1843 Data.Languages (Ada_Language_Index) := True;
1845 -- No sources of languages other than Ada
1847 Data.Other_Sources_Present := False;
1851 Current : String_List_Id := Languages.Values;
1852 Element : String_Element;
1853 Lang_Name : Name_Id;
1854 Index : Language_Index;
1857 -- Assume that there is no language specified yet
1859 Data.Other_Sources_Present := False;
1860 Data.Ada_Sources_Present := False;
1862 -- Look through all the languages specified in attribute
1863 -- Languages, if any
1865 while Current /= Nil_String loop
1867 In_Tree.String_Elements.Table (Current);
1868 Get_Name_String (Element.Value);
1869 To_Lower (Name_Buffer (1 .. Name_Len));
1870 Lang_Name := Name_Find;
1871 Index := Language_Indexes.Get (Lang_Name);
1873 if Index = No_Language_Index then
1874 Add_Language_Name (Lang_Name);
1875 Index := Last_Language_Index;
1878 Set (Index, True, Data, In_Tree);
1879 Set (Language_Processing => Default_Language_Processing_Data,
1880 For_Language => Index,
1882 In_Tree => In_Tree);
1884 if Index = Ada_Language_Index then
1885 Data.Ada_Sources_Present := True;
1888 Data.Other_Sources_Present := True;
1891 Current := Element.Next;
1896 end Check_Programming_Languages;
1902 function Check_Project
1904 Root_Project : Project_Id;
1905 In_Tree : Project_Tree_Ref;
1906 Extending : Boolean) return Boolean
1909 if P = Root_Project then
1912 elsif Extending then
1914 Data : Project_Data := In_Tree.Projects.Table (Root_Project);
1917 while Data.Extends /= No_Project loop
1918 if P = Data.Extends then
1922 Data := In_Tree.Projects.Table (Data.Extends);
1930 -------------------------------
1931 -- Check_Stand_Alone_Library --
1932 -------------------------------
1934 procedure Check_Stand_Alone_Library
1935 (Project : Project_Id;
1936 In_Tree : Project_Tree_Ref;
1937 Data : in out Project_Data;
1938 Extending : Boolean)
1940 Lib_Interfaces : constant Prj.Variable_Value :=
1942 (Snames.Name_Library_Interface,
1943 Data.Decl.Attributes,
1946 Lib_Auto_Init : constant Prj.Variable_Value :=
1948 (Snames.Name_Library_Auto_Init,
1949 Data.Decl.Attributes,
1952 Lib_Src_Dir : constant Prj.Variable_Value :=
1954 (Snames.Name_Library_Src_Dir,
1955 Data.Decl.Attributes,
1958 Lib_Symbol_File : constant Prj.Variable_Value :=
1960 (Snames.Name_Library_Symbol_File,
1961 Data.Decl.Attributes,
1964 Lib_Symbol_Policy : constant Prj.Variable_Value :=
1966 (Snames.Name_Library_Symbol_Policy,
1967 Data.Decl.Attributes,
1970 Lib_Ref_Symbol_File : constant Prj.Variable_Value :=
1972 (Snames.Name_Library_Reference_Symbol_File,
1973 Data.Decl.Attributes,
1976 Auto_Init_Supported : constant Boolean :=
1978 Standalone_Library_Auto_Init_Is_Supported;
1980 OK : Boolean := True;
1983 pragma Assert (Lib_Interfaces.Kind = List);
1985 -- It is a stand-alone library project file if attribute
1986 -- Library_Interface is defined.
1988 if not Lib_Interfaces.Default then
1989 SAL_Library : declare
1990 Interfaces : String_List_Id := Lib_Interfaces.Values;
1991 Interface_ALIs : String_List_Id := Nil_String;
1993 The_Unit_Id : Unit_Id;
1994 The_Unit_Data : Unit_Data;
1996 procedure Add_ALI_For (Source : Name_Id);
1997 -- Add an ALI file name to the list of Interface ALIs
2003 procedure Add_ALI_For (Source : Name_Id) is
2005 Get_Name_String (Source);
2008 ALI : constant String :=
2009 ALI_File_Name (Name_Buffer (1 .. Name_Len));
2010 ALI_Name_Id : Name_Id;
2012 Name_Len := ALI'Length;
2013 Name_Buffer (1 .. Name_Len) := ALI;
2014 ALI_Name_Id := Name_Find;
2016 String_Element_Table.Increment_Last
2017 (In_Tree.String_Elements);
2018 In_Tree.String_Elements.Table
2019 (String_Element_Table.Last
2020 (In_Tree.String_Elements)) :=
2021 (Value => ALI_Name_Id,
2023 Display_Value => ALI_Name_Id,
2025 In_Tree.String_Elements.Table
2026 (Interfaces).Location,
2028 Next => Interface_ALIs);
2029 Interface_ALIs := String_Element_Table.Last
2030 (In_Tree.String_Elements);
2034 -- Start of processing for SAL_Library
2037 Data.Standalone_Library := True;
2039 -- Library_Interface cannot be an empty list
2041 if Interfaces = Nil_String then
2044 "Library_Interface cannot be an empty list",
2045 Lib_Interfaces.Location);
2048 -- Process each unit name specified in the attribute
2049 -- Library_Interface.
2051 while Interfaces /= Nil_String loop
2053 (In_Tree.String_Elements.Table
2054 (Interfaces).Value);
2055 To_Lower (Name_Buffer (1 .. Name_Len));
2057 if Name_Len = 0 then
2060 "an interface cannot be an empty string",
2061 In_Tree.String_Elements.Table
2062 (Interfaces).Location);
2066 Error_Msg_Name_1 := Unit;
2068 Units_Htable.Get (In_Tree.Units_HT, Unit);
2070 if The_Unit_Id = No_Unit then
2074 In_Tree.String_Elements.Table
2075 (Interfaces).Location);
2078 -- Check that the unit is part of the project
2081 In_Tree.Units.Table (The_Unit_Id);
2083 if The_Unit_Data.File_Names (Body_Part).Name /= No_Name
2084 and then The_Unit_Data.File_Names (Body_Part).Path /=
2088 (The_Unit_Data.File_Names (Body_Part).Project,
2089 Project, In_Tree, Extending)
2091 -- There is a body for this unit.
2092 -- If there is no spec, we need to check
2093 -- that it is not a subunit.
2095 if The_Unit_Data.File_Names
2096 (Specification).Name = No_Name
2099 Src_Ind : Source_File_Index;
2102 Src_Ind := Sinput.P.Load_Project_File
2104 (The_Unit_Data.File_Names
2107 if Sinput.P.Source_File_Is_Subunit
2112 "{ is a subunit; " &
2113 "it cannot be an interface",
2115 String_Elements.Table
2116 (Interfaces).Location);
2121 -- The unit is not a subunit, so we add
2122 -- to the Interface ALIs the ALI file
2123 -- corresponding to the body.
2126 (The_Unit_Data.File_Names (Body_Part).Name);
2131 "{ is not an unit of this project",
2132 In_Tree.String_Elements.Table
2133 (Interfaces).Location);
2136 elsif The_Unit_Data.File_Names
2137 (Specification).Name /= No_Name
2138 and then The_Unit_Data.File_Names
2139 (Specification).Path /= Slash
2140 and then Check_Project
2141 (The_Unit_Data.File_Names
2142 (Specification).Project,
2143 Project, In_Tree, Extending)
2146 -- The unit is part of the project, it has
2147 -- a spec, but no body. We add to the Interface
2148 -- ALIs the ALI file corresponding to the spec.
2151 (The_Unit_Data.File_Names (Specification).Name);
2156 "{ is not an unit of this project",
2157 In_Tree.String_Elements.Table
2158 (Interfaces).Location);
2165 In_Tree.String_Elements.Table (Interfaces).Next;
2168 -- Put the list of Interface ALIs in the project data
2170 Data.Lib_Interface_ALIs := Interface_ALIs;
2172 -- Check value of attribute Library_Auto_Init and set
2173 -- Lib_Auto_Init accordingly.
2175 if Lib_Auto_Init.Default then
2177 -- If no attribute Library_Auto_Init is declared, then
2178 -- set auto init only if it is supported.
2180 Data.Lib_Auto_Init := Auto_Init_Supported;
2183 Get_Name_String (Lib_Auto_Init.Value);
2184 To_Lower (Name_Buffer (1 .. Name_Len));
2186 if Name_Buffer (1 .. Name_Len) = "false" then
2187 Data.Lib_Auto_Init := False;
2189 elsif Name_Buffer (1 .. Name_Len) = "true" then
2190 if Auto_Init_Supported then
2191 Data.Lib_Auto_Init := True;
2194 -- Library_Auto_Init cannot be "true" if auto init
2199 "library auto init not supported " &
2201 Lib_Auto_Init.Location);
2207 "invalid value for attribute Library_Auto_Init",
2208 Lib_Auto_Init.Location);
2213 -- If attribute Library_Src_Dir is defined and not the
2214 -- empty string, check if the directory exist and is not
2215 -- the object directory or one of the source directories.
2216 -- This is the directory where copies of the interface
2217 -- sources will be copied. Note that this directory may be
2218 -- the library directory.
2220 if Lib_Src_Dir.Value /= Empty_String then
2222 Dir_Id : constant Name_Id := Lib_Src_Dir.Value;
2226 (Dir_Id, Data.Display_Directory,
2227 Data.Library_Src_Dir,
2228 Data.Display_Library_Src_Dir);
2230 -- If directory does not exist, report an error
2232 if Data.Library_Src_Dir = No_Name then
2234 -- Get the absolute name of the library directory
2235 -- that does not exist, to report an error.
2238 Dir_Name : constant String :=
2239 Get_Name_String (Dir_Id);
2242 if Is_Absolute_Path (Dir_Name) then
2243 Err_Vars.Error_Msg_Name_1 := Dir_Id;
2246 Get_Name_String (Data.Directory);
2248 if Name_Buffer (Name_Len) /=
2251 Name_Len := Name_Len + 1;
2252 Name_Buffer (Name_Len) :=
2253 Directory_Separator;
2258 Name_Len + Dir_Name'Length) :=
2260 Name_Len := Name_Len + Dir_Name'Length;
2261 Err_Vars.Error_Msg_Name_1 := Name_Find;
2268 "Directory { does not exist",
2269 Lib_Src_Dir.Location);
2272 -- Report an error if it is the same as the object
2275 elsif Data.Library_Src_Dir = Data.Object_Directory then
2278 "directory to copy interfaces cannot be " &
2279 "the object directory",
2280 Lib_Src_Dir.Location);
2281 Data.Library_Src_Dir := No_Name;
2283 -- Check if it is same as one of the source directories
2287 Src_Dirs : String_List_Id := Data.Source_Dirs;
2288 Src_Dir : String_Element;
2291 while Src_Dirs /= Nil_String loop
2292 Src_Dir := In_Tree.String_Elements.Table
2294 Src_Dirs := Src_Dir.Next;
2296 -- Report error if it is one of the source directories
2298 if Data.Library_Src_Dir = Src_Dir.Value then
2301 "directory to copy interfaces cannot " &
2302 "be one of the source directories",
2303 Lib_Src_Dir.Location);
2304 Data.Library_Src_Dir := No_Name;
2310 -- In high verbosity, if there is a valid Library_Src_Dir,
2311 -- display its path name.
2313 if Data.Library_Src_Dir /= No_Name
2314 and then Current_Verbosity = High
2316 Write_Str ("Directory to copy interfaces =""");
2317 Write_Str (Get_Name_String (Data.Library_Src_Dir));
2324 -- Check the symbol related attributes
2326 -- First, the symbol policy
2328 if not Lib_Symbol_Policy.Default then
2330 Value : constant String :=
2332 (Get_Name_String (Lib_Symbol_Policy.Value));
2335 -- Symbol policy must hove one of a limited number of values
2337 if Value = "autonomous" or else Value = "default" then
2338 Data.Symbol_Data.Symbol_Policy := Autonomous;
2340 elsif Value = "compliant" then
2341 Data.Symbol_Data.Symbol_Policy := Compliant;
2343 elsif Value = "controlled" then
2344 Data.Symbol_Data.Symbol_Policy := Controlled;
2346 elsif Value = "restricted" then
2347 Data.Symbol_Data.Symbol_Policy := Restricted;
2352 "illegal value for Library_Symbol_Policy",
2353 Lib_Symbol_Policy.Location);
2358 -- If attribute Library_Symbol_File is not specified, symbol policy
2359 -- cannot be Restricted.
2361 if Lib_Symbol_File.Default then
2362 if Data.Symbol_Data.Symbol_Policy = Restricted then
2365 "Library_Symbol_File needs to be defined when " &
2366 "symbol policy is Restricted",
2367 Lib_Symbol_Policy.Location);
2371 -- Library_Symbol_File is defined. Check that the file exists.
2373 Data.Symbol_Data.Symbol_File := Lib_Symbol_File.Value;
2375 Get_Name_String (Lib_Symbol_File.Value);
2377 if Name_Len = 0 then
2380 "symbol file name cannot be an empty string",
2381 Lib_Symbol_File.Location);
2384 OK := not Is_Absolute_Path (Name_Buffer (1 .. Name_Len));
2387 for J in 1 .. Name_Len loop
2388 if Name_Buffer (J) = '/'
2389 or else Name_Buffer (J) = Directory_Separator
2398 Error_Msg_Name_1 := Lib_Symbol_File.Value;
2401 "symbol file name { is illegal. " &
2402 "Name canot include directory info.",
2403 Lib_Symbol_File.Location);
2408 -- If attribute Library_Reference_Symbol_File is not defined,
2409 -- symbol policy cannot be Compilant or Controlled.
2411 if Lib_Ref_Symbol_File.Default then
2412 if Data.Symbol_Data.Symbol_Policy = Compliant
2413 or else Data.Symbol_Data.Symbol_Policy = Controlled
2417 "a reference symbol file need to be defined",
2418 Lib_Symbol_Policy.Location);
2422 -- Library_Reference_Symbol_File is defined, check file exists
2424 Data.Symbol_Data.Reference := Lib_Ref_Symbol_File.Value;
2426 Get_Name_String (Lib_Ref_Symbol_File.Value);
2428 if Name_Len = 0 then
2431 "reference symbol file name cannot be an empty string",
2432 Lib_Symbol_File.Location);
2435 OK := not Is_Absolute_Path (Name_Buffer (1 .. Name_Len));
2438 for J in 1 .. Name_Len loop
2439 if Name_Buffer (J) = '/'
2440 or else Name_Buffer (J) = Directory_Separator
2449 Error_Msg_Name_1 := Lib_Ref_Symbol_File.Value;
2452 "reference symbol file { name is illegal. " &
2453 "Name canot include directory info.",
2454 Lib_Ref_Symbol_File.Location);
2457 if not Is_Regular_File
2458 (Get_Name_String (Data.Object_Directory) &
2459 Directory_Separator &
2460 Get_Name_String (Lib_Ref_Symbol_File.Value))
2462 Error_Msg_Name_1 := Lib_Ref_Symbol_File.Value;
2464 -- For controlled symbol policy, it is an error
2465 -- if the reference symbol file does not exist.
2467 if Data.Symbol_Data.Symbol_Policy = Controlled then
2470 "library reference symbol file { does not exist",
2471 Lib_Ref_Symbol_File.Location);
2474 -- For other symbol policies, this is just a warning
2478 "?library reference symbol file { does not exist",
2479 Lib_Ref_Symbol_File.Location);
2481 -- In addition, if symbol policy is Compliant, it is
2482 -- changed to Autonomous, because there is no reference
2483 -- to check against, and we don't want to fail in this
2486 if Data.Symbol_Data.Symbol_Policy = Compliant then
2487 Data.Symbol_Data.Symbol_Policy := Autonomous;
2495 end Check_Stand_Alone_Library;
2497 ----------------------------
2498 -- Compute_Directory_Last --
2499 ----------------------------
2501 function Compute_Directory_Last (Dir : String) return Natural is
2504 and then (Dir (Dir'Last - 1) = Directory_Separator
2505 or else Dir (Dir'Last - 1) = '/')
2507 return Dir'Last - 1;
2511 end Compute_Directory_Last;
2513 --------------------
2514 -- Body_Suffix_Of --
2515 --------------------
2517 function Body_Suffix_Of
2518 (Language : Language_Index;
2519 In_Project : Project_Data;
2520 In_Tree : Project_Tree_Ref) return String
2522 Suffix_Id : constant Name_Id :=
2523 Suffix_Of (Language, In_Project, In_Tree);
2525 if Suffix_Id /= No_Name then
2526 return Get_Name_String (Suffix_Id);
2528 return "." & Get_Name_String (Language_Names.Table (Language));
2537 (Project : Project_Id;
2538 In_Tree : Project_Tree_Ref;
2540 Flag_Location : Source_Ptr)
2542 Error_Buffer : String (1 .. 5_000);
2543 Error_Last : Natural := 0;
2544 Msg_Name : Natural := 0;
2545 First : Positive := Msg'First;
2547 procedure Add (C : Character);
2548 -- Add a character to the buffer
2550 procedure Add (S : String);
2551 -- Add a string to the buffer
2553 procedure Add (Id : Name_Id);
2554 -- Add a name to the buffer
2560 procedure Add (C : Character) is
2562 Error_Last := Error_Last + 1;
2563 Error_Buffer (Error_Last) := C;
2566 procedure Add (S : String) is
2568 Error_Buffer (Error_Last + 1 .. Error_Last + S'Length) := S;
2569 Error_Last := Error_Last + S'Length;
2572 procedure Add (Id : Name_Id) is
2574 Get_Name_String (Id);
2575 Add (Name_Buffer (1 .. Name_Len));
2578 -- Start of processing for Error_Msg
2581 if Error_Report = null then
2582 Prj.Err.Error_Msg (Msg, Flag_Location);
2586 -- Ignore continuation character
2588 if Msg (First) = '\' then
2591 -- Warniung character is always the first one in this package
2593 elsif Msg (First) = '?' then
2598 for Index in First .. Msg'Last loop
2599 if Msg (Index) = '{' or else Msg (Index) = '%' then
2601 -- Include a name between double quotes
2603 Msg_Name := Msg_Name + 1;
2607 when 1 => Add (Err_Vars.Error_Msg_Name_1);
2608 when 2 => Add (Err_Vars.Error_Msg_Name_2);
2609 when 3 => Add (Err_Vars.Error_Msg_Name_3);
2611 when others => null;
2622 Error_Report (Error_Buffer (1 .. Error_Last), Project, In_Tree);
2629 procedure Find_Sources
2630 (Project : Project_Id;
2631 In_Tree : Project_Tree_Ref;
2632 Data : in out Project_Data;
2633 For_Language : Language_Index;
2634 Follow_Links : Boolean := False)
2636 Source_Dir : String_List_Id := Data.Source_Dirs;
2637 Element : String_Element;
2639 Current_Source : String_List_Id := Nil_String;
2640 Source_Recorded : Boolean := False;
2643 if Current_Verbosity = High then
2644 Write_Line ("Looking for sources:");
2647 -- For each subdirectory
2649 while Source_Dir /= Nil_String loop
2651 Source_Recorded := False;
2652 Element := In_Tree.String_Elements.Table (Source_Dir);
2653 if Element.Value /= No_Name then
2654 Get_Name_String (Element.Display_Value);
2657 Source_Directory : constant String :=
2658 Name_Buffer (1 .. Name_Len) & Directory_Separator;
2659 Dir_Last : constant Natural :=
2660 Compute_Directory_Last (Source_Directory);
2663 if Current_Verbosity = High then
2664 Write_Str ("Source_Dir = ");
2665 Write_Line (Source_Directory);
2668 -- We look to every entry in the source directory
2670 Open (Dir, Source_Directory
2671 (Source_Directory'First .. Dir_Last));
2674 Read (Dir, Name_Buffer, Name_Len);
2676 if Current_Verbosity = High then
2677 Write_Str (" Checking ");
2678 Write_Line (Name_Buffer (1 .. Name_Len));
2681 exit when Name_Len = 0;
2684 File_Name : constant Name_Id := Name_Find;
2685 Path : constant String :=
2687 (Name => Name_Buffer (1 .. Name_Len),
2688 Directory => Source_Directory
2689 (Source_Directory'First .. Dir_Last),
2690 Resolve_Links => Follow_Links,
2691 Case_Sensitive => True);
2692 Path_Name : Name_Id;
2695 Name_Len := Path'Length;
2696 Name_Buffer (1 .. Name_Len) := Path;
2697 Path_Name := Name_Find;
2699 if For_Language = Ada_Language_Index then
2701 -- We attempt to register it as a source. However,
2702 -- there is no error if the file does not contain
2703 -- a valid source. But there is an error if we have
2704 -- a duplicate unit name.
2707 (File_Name => File_Name,
2708 Path_Name => Path_Name,
2712 Location => No_Location,
2713 Current_Source => Current_Source,
2714 Source_Recorded => Source_Recorded,
2715 Follow_Links => Follow_Links);
2719 (File_Name => File_Name,
2720 Path_Name => Path_Name,
2724 Location => No_Location,
2725 Language => For_Language,
2727 Body_Suffix_Of (For_Language, Data, In_Tree),
2728 Naming_Exception => False);
2738 when Directory_Error =>
2742 if Source_Recorded then
2743 In_Tree.String_Elements.Table (Source_Dir).Flag :=
2747 Source_Dir := Element.Next;
2750 if Current_Verbosity = High then
2751 Write_Line ("end Looking for sources.");
2754 if For_Language = Ada_Language_Index then
2756 -- If we have looked for sources and found none, then
2757 -- it is an error, except if it is an extending project.
2758 -- If a non extending project is not supposed to contain
2759 -- any source, then we never call Find_Sources.
2761 if Current_Source /= Nil_String then
2762 Data.Ada_Sources_Present := True;
2764 elsif Data.Extends = No_Project then
2767 "there are no Ada sources in this project",
2773 --------------------------------
2774 -- Free_Ada_Naming_Exceptions --
2775 --------------------------------
2777 procedure Free_Ada_Naming_Exceptions is
2779 Ada_Naming_Exception_Table.Set_Last (0);
2780 Ada_Naming_Exceptions.Reset;
2781 Reverse_Ada_Naming_Exceptions.Reset;
2782 end Free_Ada_Naming_Exceptions;
2784 ---------------------
2785 -- Get_Directories --
2786 ---------------------
2788 procedure Get_Directories
2789 (Project : Project_Id;
2790 In_Tree : Project_Tree_Ref;
2791 Data : in out Project_Data)
2793 Object_Dir : constant Variable_Value :=
2795 (Name_Object_Dir, Data.Decl.Attributes, In_Tree);
2797 Exec_Dir : constant Variable_Value :=
2799 (Name_Exec_Dir, Data.Decl.Attributes, In_Tree);
2801 Source_Dirs : constant Variable_Value :=
2803 (Name_Source_Dirs, Data.Decl.Attributes, In_Tree);
2805 Last_Source_Dir : String_List_Id := Nil_String;
2807 procedure Find_Source_Dirs (From : Name_Id; Location : Source_Ptr);
2808 -- Find one or several source directories, and add them
2809 -- to the list of source directories of the project.
2811 ----------------------
2812 -- Find_Source_Dirs --
2813 ----------------------
2815 procedure Find_Source_Dirs (From : Name_Id; Location : Source_Ptr) is
2816 Directory : constant String := Get_Name_String (From);
2817 Element : String_Element;
2819 procedure Recursive_Find_Dirs (Path : Name_Id);
2820 -- Find all the subdirectories (recursively) of Path and add them
2821 -- to the list of source directories of the project.
2823 -------------------------
2824 -- Recursive_Find_Dirs --
2825 -------------------------
2827 procedure Recursive_Find_Dirs (Path : Name_Id) is
2829 Name : String (1 .. 250);
2831 List : String_List_Id := Data.Source_Dirs;
2832 Element : String_Element;
2833 Found : Boolean := False;
2835 Non_Canonical_Path : Name_Id := No_Name;
2836 Canonical_Path : Name_Id := No_Name;
2838 The_Path : constant String :=
2839 Normalize_Pathname (Get_Name_String (Path)) &
2840 Directory_Separator;
2842 The_Path_Last : constant Natural :=
2843 Compute_Directory_Last (The_Path);
2846 Name_Len := The_Path_Last - The_Path'First + 1;
2847 Name_Buffer (1 .. Name_Len) :=
2848 The_Path (The_Path'First .. The_Path_Last);
2849 Non_Canonical_Path := Name_Find;
2850 Get_Name_String (Non_Canonical_Path);
2851 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
2852 Canonical_Path := Name_Find;
2854 -- To avoid processing the same directory several times, check
2855 -- if the directory is already in Recursive_Dirs. If it is,
2856 -- then there is nothing to do, just return. If it is not, put
2857 -- it there and continue recursive processing.
2859 if Recursive_Dirs.Get (Canonical_Path) then
2863 Recursive_Dirs.Set (Canonical_Path, True);
2866 -- Check if directory is already in list
2868 while List /= Nil_String loop
2869 Element := In_Tree.String_Elements.Table (List);
2871 if Element.Value /= No_Name then
2872 Found := Element.Value = Canonical_Path;
2876 List := Element.Next;
2879 -- If directory is not already in list, put it there
2882 if Current_Verbosity = High then
2884 Write_Line (The_Path (The_Path'First .. The_Path_Last));
2887 String_Element_Table.Increment_Last
2888 (In_Tree.String_Elements);
2890 (Value => Canonical_Path,
2891 Display_Value => Non_Canonical_Path,
2892 Location => No_Location,
2897 -- Case of first source directory
2899 if Last_Source_Dir = Nil_String then
2900 Data.Source_Dirs := String_Element_Table.Last
2901 (In_Tree.String_Elements);
2903 -- Here we already have source directories
2906 -- Link the previous last to the new one
2908 In_Tree.String_Elements.Table
2909 (Last_Source_Dir).Next :=
2910 String_Element_Table.Last
2911 (In_Tree.String_Elements);
2914 -- And register this source directory as the new last
2916 Last_Source_Dir := String_Element_Table.Last
2917 (In_Tree.String_Elements);
2918 In_Tree.String_Elements.Table (Last_Source_Dir) :=
2922 -- Now look for subdirectories. We do that even when this
2923 -- directory is already in the list, because some of its
2924 -- subdirectories may not be in the list yet.
2926 Open (Dir, The_Path (The_Path'First .. The_Path_Last));
2929 Read (Dir, Name, Last);
2932 if Name (1 .. Last) /= "."
2933 and then Name (1 .. Last) /= ".."
2935 -- Avoid . and .. directories
2937 if Current_Verbosity = High then
2938 Write_Str (" Checking ");
2939 Write_Line (Name (1 .. Last));
2943 Path_Name : constant String :=
2945 (Name => Name (1 .. Last),
2948 (The_Path'First .. The_Path_Last),
2949 Resolve_Links => False,
2950 Case_Sensitive => True);
2953 if Is_Directory (Path_Name) then
2955 -- We have found a new subdirectory, call self
2957 Name_Len := Path_Name'Length;
2958 Name_Buffer (1 .. Name_Len) := Path_Name;
2959 Recursive_Find_Dirs (Name_Find);
2968 when Directory_Error =>
2970 end Recursive_Find_Dirs;
2972 -- Start of processing for Find_Source_Dirs
2975 if Current_Verbosity = High then
2976 Write_Str ("Find_Source_Dirs (""");
2977 Write_Str (Directory);
2981 -- First, check if we are looking for a directory tree,
2982 -- indicated by "/**" at the end.
2984 if Directory'Length >= 3
2985 and then Directory (Directory'Last - 1 .. Directory'Last) = "**"
2986 and then (Directory (Directory'Last - 2) = '/'
2988 Directory (Directory'Last - 2) = Directory_Separator)
2990 Data.Known_Order_Of_Source_Dirs := False;
2992 Name_Len := Directory'Length - 3;
2994 if Name_Len = 0 then
2996 -- This is the case of "/**": all directories
2997 -- in the file system.
3000 Name_Buffer (1) := Directory (Directory'First);
3003 Name_Buffer (1 .. Name_Len) :=
3004 Directory (Directory'First .. Directory'Last - 3);
3007 if Current_Verbosity = High then
3008 Write_Str ("Looking for all subdirectories of """);
3009 Write_Str (Name_Buffer (1 .. Name_Len));
3014 Base_Dir : constant Name_Id := Name_Find;
3015 Root_Dir : constant String :=
3017 (Name => Get_Name_String (Base_Dir),
3019 Get_Name_String (Data.Display_Directory),
3020 Resolve_Links => False,
3021 Case_Sensitive => True);
3024 if Root_Dir'Length = 0 then
3025 Err_Vars.Error_Msg_Name_1 := Base_Dir;
3027 if Location = No_Location then
3030 "{ is not a valid directory.",
3035 "{ is not a valid directory.",
3040 -- We have an existing directory, we register it and all
3041 -- of its subdirectories.
3043 if Current_Verbosity = High then
3044 Write_Line ("Looking for source directories:");
3047 Name_Len := Root_Dir'Length;
3048 Name_Buffer (1 .. Name_Len) := Root_Dir;
3049 Recursive_Find_Dirs (Name_Find);
3051 if Current_Verbosity = High then
3052 Write_Line ("End of looking for source directories.");
3057 -- We have a single directory
3061 Path_Name : Name_Id;
3062 Display_Path_Name : Name_Id;
3066 (From, Data.Display_Directory, Path_Name, Display_Path_Name);
3068 if Path_Name = No_Name then
3069 Err_Vars.Error_Msg_Name_1 := From;
3071 if Location = No_Location then
3074 "{ is not a valid directory",
3079 "{ is not a valid directory",
3084 -- As it is an existing directory, we add it to
3085 -- the list of directories.
3087 String_Element_Table.Increment_Last
3088 (In_Tree.String_Elements);
3089 Element.Value := Path_Name;
3090 Element.Display_Value := Display_Path_Name;
3092 if Last_Source_Dir = Nil_String then
3094 -- This is the first source directory
3096 Data.Source_Dirs := String_Element_Table.Last
3097 (In_Tree.String_Elements);
3100 -- We already have source directories,
3101 -- link the previous last to the new one.
3103 In_Tree.String_Elements.Table
3104 (Last_Source_Dir).Next :=
3105 String_Element_Table.Last
3106 (In_Tree.String_Elements);
3109 -- And register this source directory as the new last
3111 Last_Source_Dir := String_Element_Table.Last
3112 (In_Tree.String_Elements);
3113 In_Tree.String_Elements.Table
3114 (Last_Source_Dir) := Element;
3118 end Find_Source_Dirs;
3120 -- Start of processing for Get_Directories
3123 if Current_Verbosity = High then
3124 Write_Line ("Starting to look for directories");
3127 -- Check the object directory
3129 pragma Assert (Object_Dir.Kind = Single,
3130 "Object_Dir is not a single string");
3132 -- We set the object directory to its default
3134 Data.Object_Directory := Data.Directory;
3135 Data.Display_Object_Dir := Data.Display_Directory;
3137 if Object_Dir.Value /= Empty_String then
3138 Get_Name_String (Object_Dir.Value);
3140 if Name_Len = 0 then
3143 "Object_Dir cannot be empty",
3144 Object_Dir.Location);
3147 -- We check that the specified object directory does exist
3150 (Object_Dir.Value, Data.Display_Directory,
3151 Data.Object_Directory, Data.Display_Object_Dir);
3153 if Data.Object_Directory = No_Name then
3155 -- The object directory does not exist, report an error
3157 Err_Vars.Error_Msg_Name_1 := Object_Dir.Value;
3160 "the object directory { cannot be found",
3163 -- Do not keep a nil Object_Directory. Set it to the specified
3164 -- (relative or absolute) path. This is for the benefit of
3165 -- tools that recover from errors; for example, these tools
3166 -- could create the non existent directory.
3168 Data.Display_Object_Dir := Object_Dir.Value;
3169 Get_Name_String (Object_Dir.Value);
3170 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3171 Data.Object_Directory := Name_Find;
3176 if Current_Verbosity = High then
3177 if Data.Object_Directory = No_Name then
3178 Write_Line ("No object directory");
3180 Write_Str ("Object directory: """);
3181 Write_Str (Get_Name_String (Data.Display_Object_Dir));
3186 -- Check the exec directory
3188 pragma Assert (Exec_Dir.Kind = Single,
3189 "Exec_Dir is not a single string");
3191 -- We set the object directory to its default
3193 Data.Exec_Directory := Data.Object_Directory;
3194 Data.Display_Exec_Dir := Data.Display_Object_Dir;
3196 if Exec_Dir.Value /= Empty_String then
3197 Get_Name_String (Exec_Dir.Value);
3199 if Name_Len = 0 then
3202 "Exec_Dir cannot be empty",
3206 -- We check that the specified object directory
3210 (Exec_Dir.Value, Data.Directory,
3211 Data.Exec_Directory, Data.Display_Exec_Dir);
3213 if Data.Exec_Directory = No_Name then
3214 Err_Vars.Error_Msg_Name_1 := Exec_Dir.Value;
3217 "the exec directory { cannot be found",
3223 if Current_Verbosity = High then
3224 if Data.Exec_Directory = No_Name then
3225 Write_Line ("No exec directory");
3227 Write_Str ("Exec directory: """);
3228 Write_Str (Get_Name_String (Data.Display_Exec_Dir));
3233 -- Look for the source directories
3235 if Current_Verbosity = High then
3236 Write_Line ("Starting to look for source directories");
3239 pragma Assert (Source_Dirs.Kind = List, "Source_Dirs is not a list");
3241 if Source_Dirs.Default then
3243 -- No Source_Dirs specified: the single source directory
3244 -- is the one containing the project file
3246 String_Element_Table.Increment_Last
3247 (In_Tree.String_Elements);
3248 Data.Source_Dirs := String_Element_Table.Last
3249 (In_Tree.String_Elements);
3250 In_Tree.String_Elements.Table (Data.Source_Dirs) :=
3251 (Value => Data.Directory,
3252 Display_Value => Data.Display_Directory,
3253 Location => No_Location,
3258 if Current_Verbosity = High then
3259 Write_Line ("Single source directory:");
3261 Write_Str (Get_Name_String (Data.Display_Directory));
3265 elsif Source_Dirs.Values = Nil_String then
3267 -- If Source_Dirs is an empty string list, this means
3268 -- that this project contains no source. For projects that
3269 -- don't extend other projects, this also means that there is no
3270 -- need for an object directory, if not specified.
3272 if Data.Extends = No_Project
3273 and then Data.Object_Directory = Data.Directory
3275 Data.Object_Directory := No_Name;
3278 Data.Source_Dirs := Nil_String;
3279 Data.Ada_Sources_Present := False;
3280 Data.Other_Sources_Present := False;
3284 Source_Dir : String_List_Id := Source_Dirs.Values;
3285 Element : String_Element;
3288 -- We will find the source directories for each
3289 -- element of the list
3291 while Source_Dir /= Nil_String loop
3293 In_Tree.String_Elements.Table (Source_Dir);
3294 Find_Source_Dirs (Element.Value, Element.Location);
3295 Source_Dir := Element.Next;
3300 if Current_Verbosity = High then
3301 Write_Line ("Putting source directories in canonical cases");
3305 Current : String_List_Id := Data.Source_Dirs;
3306 Element : String_Element;
3309 while Current /= Nil_String loop
3310 Element := In_Tree.String_Elements.Table (Current);
3311 if Element.Value /= No_Name then
3312 Get_Name_String (Element.Value);
3313 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3314 Element.Value := Name_Find;
3315 In_Tree.String_Elements.Table (Current) := Element;
3318 Current := Element.Next;
3322 end Get_Directories;
3329 (Project : Project_Id;
3330 In_Tree : Project_Tree_Ref;
3331 Data : in out Project_Data) is
3332 Mains : constant Variable_Value :=
3333 Prj.Util.Value_Of (Name_Main, Data.Decl.Attributes, In_Tree);
3336 Data.Mains := Mains.Values;
3338 -- If no Mains were specified, and if we are an extending
3339 -- project, inherit the Mains from the project we are extending.
3341 if Mains.Default then
3342 if Data.Extends /= No_Project then
3344 In_Tree.Projects.Table (Data.Extends).Mains;
3347 -- In a library project file, Main cannot be specified
3349 elsif Data.Library then
3352 "a library project file cannot have Main specified",
3357 ---------------------------
3358 -- Get_Sources_From_File --
3359 ---------------------------
3361 procedure Get_Sources_From_File
3363 Location : Source_Ptr;
3364 Project : Project_Id;
3365 In_Tree : Project_Tree_Ref)
3367 File : Prj.Util.Text_File;
3368 Line : String (1 .. 250);
3370 Source_Name : Name_Id;
3375 if Current_Verbosity = High then
3376 Write_Str ("Opening """);
3383 Prj.Util.Open (File, Path);
3385 if not Prj.Util.Is_Valid (File) then
3386 Error_Msg (Project, In_Tree, "file does not exist", Location);
3388 -- Read the lines one by one
3390 while not Prj.Util.End_Of_File (File) loop
3391 Prj.Util.Get_Line (File, Line, Last);
3393 -- A non empty, non comment line should contain a file name
3396 and then (Last = 1 or else Line (1 .. 2) /= "--")
3398 -- ??? we should check that there is no directory information
3401 Name_Buffer (1 .. Name_Len) := Line (1 .. Last);
3402 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3403 Source_Name := Name_Find;
3407 (Name => Source_Name,
3408 Location => Location,
3413 Prj.Util.Close (File);
3416 end Get_Sources_From_File;
3423 (Canonical_File_Name : Name_Id;
3424 Naming : Naming_Data;
3425 Exception_Id : out Ada_Naming_Exception_Id;
3426 Unit_Name : out Name_Id;
3427 Unit_Kind : out Spec_Or_Body;
3428 Needs_Pragma : out Boolean)
3430 Info_Id : Ada_Naming_Exception_Id
3431 := Ada_Naming_Exceptions.Get (Canonical_File_Name);
3435 if Info_Id = No_Ada_Naming_Exception then
3436 if Hostparm.OpenVMS then
3437 VMS_Name := Canonical_File_Name;
3438 Get_Name_String (VMS_Name);
3440 if Name_Buffer (Name_Len) = '.' then
3441 Name_Len := Name_Len - 1;
3442 VMS_Name := Name_Find;
3445 Info_Id := Ada_Naming_Exceptions.Get (VMS_Name);
3450 if Info_Id /= No_Ada_Naming_Exception then
3451 Exception_Id := Info_Id;
3452 Unit_Name := No_Name;
3453 Unit_Kind := Specification;
3454 Needs_Pragma := True;
3458 Needs_Pragma := False;
3459 Exception_Id := No_Ada_Naming_Exception;
3461 Get_Name_String (Canonical_File_Name);
3464 File : String := Name_Buffer (1 .. Name_Len);
3465 First : constant Positive := File'First;
3466 Last : Natural := File'Last;
3467 Standard_GNAT : Boolean;
3471 Naming.Ada_Spec_Suffix = Default_Ada_Spec_Suffix
3472 and then Naming.Ada_Body_Suffix = Default_Ada_Body_Suffix;
3474 -- Check if the end of the file name is Specification_Append
3476 Get_Name_String (Naming.Ada_Spec_Suffix);
3478 if File'Length > Name_Len
3479 and then File (Last - Name_Len + 1 .. Last) =
3480 Name_Buffer (1 .. Name_Len)
3484 Unit_Kind := Specification;
3485 Last := Last - Name_Len;
3487 if Current_Verbosity = High then
3488 Write_Str (" Specification: ");
3489 Write_Line (File (First .. Last));
3493 Get_Name_String (Naming.Ada_Body_Suffix);
3495 -- Check if the end of the file name is Body_Append
3497 if File'Length > Name_Len
3498 and then File (Last - Name_Len + 1 .. Last) =
3499 Name_Buffer (1 .. Name_Len)
3503 Unit_Kind := Body_Part;
3504 Last := Last - Name_Len;
3506 if Current_Verbosity = High then
3507 Write_Str (" Body: ");
3508 Write_Line (File (First .. Last));
3511 elsif Naming.Separate_Suffix /= Naming.Ada_Spec_Suffix then
3512 Get_Name_String (Naming.Separate_Suffix);
3514 -- Check if the end of the file name is Separate_Append
3516 if File'Length > Name_Len
3517 and then File (Last - Name_Len + 1 .. Last) =
3518 Name_Buffer (1 .. Name_Len)
3520 -- We have a separate (a body)
3522 Unit_Kind := Body_Part;
3523 Last := Last - Name_Len;
3525 if Current_Verbosity = High then
3526 Write_Str (" Separate: ");
3527 Write_Line (File (First .. Last));
3541 -- This is not a source file
3543 Unit_Name := No_Name;
3544 Unit_Kind := Specification;
3546 if Current_Verbosity = High then
3547 Write_Line (" Not a valid file name.");
3553 Get_Name_String (Naming.Dot_Replacement);
3555 Standard_GNAT and then Name_Buffer (1 .. Name_Len) = "-";
3557 if Name_Buffer (1 .. Name_Len) /= "." then
3559 -- If Dot_Replacement is not a single dot, then there should
3560 -- not be any dot in the name.
3562 for Index in First .. Last loop
3563 if File (Index) = '.' then
3564 if Current_Verbosity = High then
3566 (" Not a valid file name (some dot not replaced).");
3569 Unit_Name := No_Name;
3575 -- Replace the substring Dot_Replacement with dots
3578 Index : Positive := First;
3581 while Index <= Last - Name_Len + 1 loop
3583 if File (Index .. Index + Name_Len - 1) =
3584 Name_Buffer (1 .. Name_Len)
3586 File (Index) := '.';
3588 if Name_Len > 1 and then Index < Last then
3589 File (Index + 1 .. Last - Name_Len + 1) :=
3590 File (Index + Name_Len .. Last);
3593 Last := Last - Name_Len + 1;
3601 -- Check if the casing is right
3604 Src : String := File (First .. Last);
3607 case Naming.Casing is
3608 when All_Lower_Case =>
3611 Mapping => Lower_Case_Map);
3613 when All_Upper_Case =>
3616 Mapping => Upper_Case_Map);
3618 when Mixed_Case | Unknown =>
3622 if Src /= File (First .. Last) then
3623 if Current_Verbosity = High then
3624 Write_Line (" Not a valid file name (casing).");
3627 Unit_Name := No_Name;
3631 -- We put the name in lower case
3635 Mapping => Lower_Case_Map);
3637 -- In the standard GNAT naming scheme, check for special cases:
3638 -- children or separates of A, G, I or S, and run time sources.
3640 if Standard_GNAT and then Src'Length >= 3 then
3642 S1 : constant Character := Src (Src'First);
3643 S2 : constant Character := Src (Src'First + 1);
3646 if S1 = 'a' or else S1 = 'g'
3647 or else S1 = 'i' or else S1 = 's'
3649 -- Children or separates of packages A, G, I or S
3651 if (Hostparm.OpenVMS and then S2 = '$')
3652 or else (not Hostparm.OpenVMS and then S2 = '~')
3654 Src (Src'First + 1) := '.';
3656 -- If it is potentially a run time source, disable
3657 -- filling of the mapping file to avoid warnings.
3660 Set_Mapping_File_Initial_State_To_Empty;
3667 if Current_Verbosity = High then
3672 -- Now, we check if this name is a valid unit name
3674 Check_Ada_Name (Name => Src, Unit => Unit_Name);
3684 function Hash (Unit : Unit_Info) return Header_Num is
3686 return Header_Num (Unit.Unit mod 2048);
3689 -----------------------
3690 -- Is_Illegal_Suffix --
3691 -----------------------
3693 function Is_Illegal_Suffix
3695 Dot_Replacement_Is_A_Single_Dot : Boolean) return Boolean
3698 if Suffix'Length = 0 or else Index (Suffix, ".") = 0 then
3702 -- If dot replacement is a single dot, and first character of
3703 -- suffix is also a dot
3705 if Dot_Replacement_Is_A_Single_Dot
3706 and then Suffix (Suffix'First) = '.'
3708 for Index in Suffix'First + 1 .. Suffix'Last loop
3710 -- If there is another dot
3712 if Suffix (Index) = '.' then
3714 -- It is illegal to have a letter following the initial dot
3716 return Is_Letter (Suffix (Suffix'First + 1));
3724 end Is_Illegal_Suffix;
3726 ----------------------
3727 -- Locate_Directory --
3728 ----------------------
3730 procedure Locate_Directory
3734 Display : out Name_Id)
3736 The_Name : constant String := Get_Name_String (Name);
3738 The_Parent : constant String :=
3739 Get_Name_String (Parent) & Directory_Separator;
3741 The_Parent_Last : constant Natural :=
3742 Compute_Directory_Last (The_Parent);
3745 if Current_Verbosity = High then
3746 Write_Str ("Locate_Directory (""");
3747 Write_Str (The_Name);
3748 Write_Str (""", """);
3749 Write_Str (The_Parent);
3756 if Is_Absolute_Path (The_Name) then
3757 if Is_Directory (The_Name) then
3759 Normed : constant String :=
3762 Resolve_Links => False,
3763 Case_Sensitive => True);
3765 Canonical_Path : constant String :=
3768 Resolve_Links => True,
3769 Case_Sensitive => False);
3772 Name_Len := Normed'Length;
3773 Name_Buffer (1 .. Name_Len) := Normed;
3774 Display := Name_Find;
3776 Name_Len := Canonical_Path'Length;
3777 Name_Buffer (1 .. Name_Len) := Canonical_Path;
3784 Full_Path : constant String :=
3785 The_Parent (The_Parent'First .. The_Parent_Last) &
3789 if Is_Directory (Full_Path) then
3791 Normed : constant String :=
3794 Resolve_Links => False,
3795 Case_Sensitive => True);
3797 Canonical_Path : constant String :=
3800 Resolve_Links => True,
3801 Case_Sensitive => False);
3804 Name_Len := Normed'Length;
3805 Name_Buffer (1 .. Name_Len) := Normed;
3806 Display := Name_Find;
3808 Name_Len := Canonical_Path'Length;
3809 Name_Buffer (1 .. Name_Len) := Canonical_Path;
3815 end Locate_Directory;
3817 ----------------------
3818 -- Look_For_Sources --
3819 ----------------------
3821 procedure Look_For_Sources
3822 (Project : Project_Id;
3823 In_Tree : Project_Tree_Ref;
3824 Data : in out Project_Data;
3825 Follow_Links : Boolean)
3827 procedure Get_Path_Names_And_Record_Sources (Follow_Links : Boolean);
3828 -- Find the path names of the source files in the Source_Names table
3829 -- in the source directories and record those that are Ada sources.
3831 procedure Get_Sources_From_File
3833 Location : Source_Ptr);
3834 -- Get the sources of a project from a text file
3836 ---------------------------------------
3837 -- Get_Path_Names_And_Record_Sources --
3838 ---------------------------------------
3840 procedure Get_Path_Names_And_Record_Sources (Follow_Links : Boolean) is
3841 Source_Dir : String_List_Id := Data.Source_Dirs;
3842 Element : String_Element;
3847 Canonical_Name : Name_Id;
3848 Name_Str : String (1 .. 1_024);
3849 Last : Natural := 0;
3852 Current_Source : String_List_Id := Nil_String;
3854 First_Error : Boolean := True;
3856 Source_Recorded : Boolean := False;
3859 -- We look in all source directories for the file names in the
3860 -- hash table Source_Names
3862 while Source_Dir /= Nil_String loop
3863 Source_Recorded := False;
3864 Element := In_Tree.String_Elements.Table (Source_Dir);
3867 Dir_Path : constant String := Get_Name_String (Element.Value);
3869 if Current_Verbosity = High then
3870 Write_Str ("checking directory """);
3871 Write_Str (Dir_Path);
3875 Open (Dir, Dir_Path);
3878 Read (Dir, Name_Str, Last);
3881 Name_Buffer (1 .. Name_Len) := Name_Str (1 .. Last);
3883 Canonical_Case_File_Name (Name_Str (1 .. Last));
3885 Name_Buffer (1 .. Name_Len) := Name_Str (1 .. Last);
3886 Canonical_Name := Name_Find;
3887 NL := Source_Names.Get (Canonical_Name);
3889 if NL /= No_Name_Location and then not NL.Found then
3891 Source_Names.Set (Canonical_Name, NL);
3892 Name_Len := Dir_Path'Length;
3893 Name_Buffer (1 .. Name_Len) := Dir_Path;
3895 if Name_Buffer (Name_Len) /= Directory_Separator then
3896 Add_Char_To_Name_Buffer (Directory_Separator);
3899 Add_Str_To_Name_Buffer (Name_Str (1 .. Last));
3902 if Current_Verbosity = High then
3903 Write_Str (" found ");
3904 Write_Line (Get_Name_String (Name));
3907 -- Register the source if it is an Ada compilation unit
3915 Location => NL.Location,
3916 Current_Source => Current_Source,
3917 Source_Recorded => Source_Recorded,
3918 Follow_Links => Follow_Links);
3925 if Source_Recorded then
3926 In_Tree.String_Elements.Table (Source_Dir).Flag :=
3930 Source_Dir := Element.Next;
3933 -- It is an error if a source file name in a source list or
3934 -- in a source list file is not found.
3936 NL := Source_Names.Get_First;
3938 while NL /= No_Name_Location loop
3939 if not NL.Found then
3940 Err_Vars.Error_Msg_Name_1 := NL.Name;
3945 "source file { cannot be found",
3947 First_Error := False;
3952 "\source file { cannot be found",
3957 NL := Source_Names.Get_Next;
3959 end Get_Path_Names_And_Record_Sources;
3961 ---------------------------
3962 -- Get_Sources_From_File --
3963 ---------------------------
3965 procedure Get_Sources_From_File
3967 Location : Source_Ptr)
3970 -- Get the list of sources from the file and put them in hash table
3973 Get_Sources_From_File (Path, Location, Project, In_Tree);
3975 -- Look in the source directories to find those sources
3977 Get_Path_Names_And_Record_Sources (Follow_Links);
3979 -- We should have found at least one source.
3980 -- If not, report an error.
3982 if Data.Sources = Nil_String then
3983 Error_Msg (Project, In_Tree,
3984 "there are no Ada sources in this project",
3987 end Get_Sources_From_File;
3990 if Data.Ada_Sources_Present then
3992 Sources : constant Variable_Value :=
3995 Data.Decl.Attributes,
3998 Source_List_File : constant Variable_Value :=
4000 (Name_Source_List_File,
4001 Data.Decl.Attributes,
4004 Locally_Removed : constant Variable_Value :=
4006 (Name_Locally_Removed_Files,
4007 Data.Decl.Attributes,
4012 (Sources.Kind = List,
4013 "Source_Files is not a list");
4016 (Source_List_File.Kind = Single,
4017 "Source_List_File is not a single string");
4019 if not Sources.Default then
4020 if not Source_List_File.Default then
4023 "?both variables source_files and " &
4024 "source_list_file are present",
4025 Source_List_File.Location);
4028 -- Sources is a list of file names
4031 Current : String_List_Id := Sources.Values;
4032 Element : String_Element;
4033 Location : Source_Ptr;
4039 Data.Ada_Sources_Present := Current /= Nil_String;
4041 while Current /= Nil_String loop
4043 In_Tree.String_Elements.Table (Current);
4044 Get_Name_String (Element.Value);
4045 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
4048 -- If the element has no location, then use the
4049 -- location of Sources to report possible errors.
4051 if Element.Location = No_Location then
4052 Location := Sources.Location;
4054 Location := Element.Location;
4061 Location => Location,
4064 Current := Element.Next;
4067 Get_Path_Names_And_Record_Sources (Follow_Links);
4070 -- No source_files specified
4072 -- We check Source_List_File has been specified
4074 elsif not Source_List_File.Default then
4076 -- Source_List_File is the name of the file
4077 -- that contains the source file names
4080 Source_File_Path_Name : constant String :=
4082 (Source_List_File.Value,
4086 if Source_File_Path_Name'Length = 0 then
4087 Err_Vars.Error_Msg_Name_1 := Source_List_File.Value;
4090 "file with sources { does not exist",
4091 Source_List_File.Location);
4094 Get_Sources_From_File
4095 (Source_File_Path_Name,
4096 Source_List_File.Location);
4101 -- Neither Source_Files nor Source_List_File has been
4102 -- specified. Find all the files that satisfy the naming
4103 -- scheme in all the source directories.
4106 (Project, In_Tree, Data, Ada_Language_Index, Follow_Links);
4109 -- If there are sources that are locally removed, mark them as
4110 -- such in the Units table.
4112 if not Locally_Removed.Default then
4114 -- Sources can be locally removed only in extending
4117 if Data.Extends = No_Project then
4120 "Locally_Removed_Files can only be used " &
4121 "in an extending project file",
4122 Locally_Removed.Location);
4126 Current : String_List_Id := Locally_Removed.Values;
4127 Element : String_Element;
4128 Location : Source_Ptr;
4132 Extended : Project_Id;
4135 while Current /= Nil_String loop
4137 In_Tree.String_Elements.Table (Current);
4138 Get_Name_String (Element.Value);
4139 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
4142 -- If the element has no location, then use the
4143 -- location of Locally_Removed to report
4146 if Element.Location = No_Location then
4147 Location := Locally_Removed.Location;
4149 Location := Element.Location;
4154 for Index in Unit_Table.First ..
4155 Unit_Table.Last (In_Tree.Units)
4157 Unit := In_Tree.Units.Table (Index);
4159 if Unit.File_Names (Specification).Name = Name then
4162 -- Check that this is from a project that
4163 -- the current project extends, but not the
4166 Extended := Unit.File_Names
4167 (Specification).Project;
4169 if Extended = Project then
4172 "cannot remove a source " &
4173 "of the same project",
4177 Project_Extends (Project, Extended, In_Tree)
4180 (Specification).Path := Slash;
4182 (Specification).Needs_Pragma := False;
4183 In_Tree.Units.Table (Index) :=
4185 Add_Forbidden_File_Name
4186 (Unit.File_Names (Specification).Name);
4192 "cannot remove a source from " &
4198 Unit.File_Names (Body_Part).Name = Name
4202 -- Check that this is from a project that
4203 -- the current project extends, but not the
4206 Extended := Unit.File_Names
4207 (Body_Part).Project;
4209 if Extended = Project then
4212 "cannot remove a source " &
4213 "of the same project",
4217 Project_Extends (Project, Extended, In_Tree)
4219 Unit.File_Names (Body_Part).Path := Slash;
4220 Unit.File_Names (Body_Part).Needs_Pragma
4222 In_Tree.Units.Table (Index) :=
4224 Add_Forbidden_File_Name
4225 (Unit.File_Names (Body_Part).Name);
4233 Err_Vars.Error_Msg_Name_1 := Name;
4235 (Project, In_Tree, "unknown file {", Location);
4238 Current := Element.Next;
4246 if Data.Other_Sources_Present then
4248 -- Set Source_Present to False. It will be set back to True
4249 -- whenever a source is found.
4251 Data.Other_Sources_Present := False;
4252 for Lang in Ada_Language_Index + 1 .. Last_Language_Index loop
4254 -- For each language (other than Ada) in the project file
4256 if Is_Present (Lang, Data, In_Tree) then
4258 -- Reset the indication that there are sources of this
4259 -- language. It will be set back to True whenever we find a
4260 -- source of the language.
4262 Set (Lang, False, Data, In_Tree);
4264 -- First, get the source suffix for the language
4266 Set (Suffix => Suffix_For (Lang, Data.Naming, In_Tree),
4267 For_Language => Lang,
4269 In_Tree => In_Tree);
4271 -- Then, deal with the naming exceptions, if any
4276 Naming_Exceptions : constant Variable_Value :=
4278 (Index => Language_Names.Table (Lang),
4280 In_Array => Data.Naming.Implementation_Exceptions,
4281 In_Tree => In_Tree);
4282 Element_Id : String_List_Id;
4283 Element : String_Element;
4285 Source_Found : Boolean := False;
4288 -- If there are naming exceptions, look through them one
4291 if Naming_Exceptions /= Nil_Variable_Value then
4292 Element_Id := Naming_Exceptions.Values;
4294 while Element_Id /= Nil_String loop
4295 Element := In_Tree.String_Elements.Table
4297 Get_Name_String (Element.Value);
4298 Canonical_Case_File_Name
4299 (Name_Buffer (1 .. Name_Len));
4300 File_Id := Name_Find;
4302 -- Put each naming exception in the Source_Names
4303 -- hash table, but if there are repetition, don't
4304 -- bother after the first instance.
4307 Source_Names.Get (File_Id) = No_Name_Location
4309 Source_Found := True;
4313 Location => Element.Location,
4317 Element_Id := Element.Next;
4320 -- If there is at least one naming exception, record
4321 -- those that are found in the source directories.
4323 if Source_Found then
4324 Record_Other_Sources
4325 (Project => Project,
4329 Naming_Exceptions => True);
4335 -- Now, check if a list of sources is declared either through
4336 -- a string list (attribute Source_Files) or a text file
4337 -- (attribute Source_List_File). If a source list is declared,
4338 -- we will consider only those naming exceptions that are
4342 Sources : constant Variable_Value :=
4345 Data.Decl.Attributes,
4348 Source_List_File : constant Variable_Value :=
4350 (Name_Source_List_File,
4351 Data.Decl.Attributes,
4356 (Sources.Kind = List,
4357 "Source_Files is not a list");
4360 (Source_List_File.Kind = Single,
4361 "Source_List_File is not a single string");
4363 if not Sources.Default then
4364 if not Source_List_File.Default then
4367 "?both variables source_files and " &
4368 "source_list_file are present",
4369 Source_List_File.Location);
4372 -- Sources is a list of file names
4375 Current : String_List_Id := Sources.Values;
4376 Element : String_Element;
4377 Location : Source_Ptr;
4383 -- Put all the sources in the Source_Names hash table
4385 while Current /= Nil_String loop
4387 In_Tree.String_Elements.Table
4389 Get_Name_String (Element.Value);
4390 Canonical_Case_File_Name
4391 (Name_Buffer (1 .. Name_Len));
4394 -- If the element has no location, then use the
4395 -- location of Sources to report possible errors.
4397 if Element.Location = No_Location then
4398 Location := Sources.Location;
4400 Location := Element.Location;
4407 Location => Location,
4410 Current := Element.Next;
4413 -- And look for their directories
4415 Record_Other_Sources
4416 (Project => Project,
4420 Naming_Exceptions => False);
4423 -- No source_files specified
4425 -- We check if Source_List_File has been specified
4427 elsif not Source_List_File.Default then
4429 -- Source_List_File is the name of the file
4430 -- that contains the source file names
4433 Source_File_Path_Name : constant String :=
4435 (Source_List_File.Value,
4439 if Source_File_Path_Name'Length = 0 then
4440 Err_Vars.Error_Msg_Name_1 :=
4441 Source_List_File.Value;
4444 "file with sources { does not exist",
4445 Source_List_File.Location);
4448 -- Read the file, putting each source in the
4449 -- Source_Names hash table.
4451 Get_Sources_From_File
4452 (Source_File_Path_Name,
4453 Source_List_File.Location,
4456 -- And look for their directories
4458 Record_Other_Sources
4459 (Project => Project,
4463 Naming_Exceptions => False);
4467 -- Neither Source_Files nor Source_List_File was specified
4470 -- Find all the files that satisfy the naming scheme in
4471 -- all the source directories. All the naming exceptions
4472 -- that effectively exist are also part of the source
4473 -- of this language.
4475 Find_Sources (Project, In_Tree, Data, Lang);
4481 end Look_For_Sources;
4487 function Path_Name_Of
4488 (File_Name : Name_Id;
4489 Directory : Name_Id) return String
4491 Result : String_Access;
4493 The_Directory : constant String := Get_Name_String (Directory);
4496 Get_Name_String (File_Name);
4497 Result := Locate_Regular_File
4498 (File_Name => Name_Buffer (1 .. Name_Len),
4499 Path => The_Directory);
4501 if Result = null then
4504 Canonical_Case_File_Name (Result.all);
4509 -------------------------------
4510 -- Prepare_Ada_Naming_Exceptions --
4511 -------------------------------
4513 procedure Prepare_Ada_Naming_Exceptions
4514 (List : Array_Element_Id;
4515 In_Tree : Project_Tree_Ref;
4516 Kind : Spec_Or_Body)
4518 Current : Array_Element_Id := List;
4519 Element : Array_Element;
4524 -- Traverse the list
4526 while Current /= No_Array_Element loop
4527 Element := In_Tree.Array_Elements.Table (Current);
4529 if Element.Index /= No_Name then
4532 Unit => Element.Index,
4533 Next => No_Ada_Naming_Exception);
4534 Reverse_Ada_Naming_Exceptions.Set
4535 (Unit, (Element.Value.Value, Element.Value.Index));
4536 Unit.Next := Ada_Naming_Exceptions.Get (Element.Value.Value);
4537 Ada_Naming_Exception_Table.Increment_Last;
4538 Ada_Naming_Exception_Table.Table
4539 (Ada_Naming_Exception_Table.Last) := Unit;
4540 Ada_Naming_Exceptions.Set
4541 (Element.Value.Value, Ada_Naming_Exception_Table.Last);
4544 Current := Element.Next;
4546 end Prepare_Ada_Naming_Exceptions;
4548 ---------------------
4549 -- Project_Extends --
4550 ---------------------
4552 function Project_Extends
4553 (Extending : Project_Id;
4554 Extended : Project_Id;
4555 In_Tree : Project_Tree_Ref) return Boolean
4557 Current : Project_Id := Extending;
4560 if Current = No_Project then
4563 elsif Current = Extended then
4567 Current := In_Tree.Projects.Table (Current).Extends;
4569 end Project_Extends;
4571 -----------------------
4572 -- Record_Ada_Source --
4573 -----------------------
4575 procedure Record_Ada_Source
4576 (File_Name : Name_Id;
4577 Path_Name : Name_Id;
4578 Project : Project_Id;
4579 In_Tree : Project_Tree_Ref;
4580 Data : in out Project_Data;
4581 Location : Source_Ptr;
4582 Current_Source : in out String_List_Id;
4583 Source_Recorded : in out Boolean;
4584 Follow_Links : Boolean)
4586 Canonical_File_Name : Name_Id;
4587 Canonical_Path_Name : Name_Id;
4589 Exception_Id : Ada_Naming_Exception_Id;
4590 Unit_Name : Name_Id;
4591 Unit_Kind : Spec_Or_Body;
4592 Unit_Index : Int := 0;
4594 Name_Index : Name_And_Index;
4595 Needs_Pragma : Boolean;
4597 The_Location : Source_Ptr := Location;
4598 Previous_Source : constant String_List_Id := Current_Source;
4599 Except_Name : Name_And_Index := No_Name_And_Index;
4601 Unit_Prj : Unit_Project;
4603 File_Name_Recorded : Boolean := False;
4606 Get_Name_String (File_Name);
4607 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
4608 Canonical_File_Name := Name_Find;
4611 Canonical_Path : constant String :=
4613 (Get_Name_String (Path_Name),
4614 Resolve_Links => Follow_Links,
4615 Case_Sensitive => False);
4618 Add_Str_To_Name_Buffer (Canonical_Path);
4619 Canonical_Path_Name := Name_Find;
4622 -- Find out the unit name, the unit kind and if it needs
4623 -- a specific SFN pragma.
4626 (Canonical_File_Name => Canonical_File_Name,
4627 Naming => Data.Naming,
4628 Exception_Id => Exception_Id,
4629 Unit_Name => Unit_Name,
4630 Unit_Kind => Unit_Kind,
4631 Needs_Pragma => Needs_Pragma);
4633 if Exception_Id = No_Ada_Naming_Exception and then
4636 if Current_Verbosity = High then
4638 Write_Str (Get_Name_String (Canonical_File_Name));
4639 Write_Line (""" is not a valid source file name (ignored).");
4643 -- Check to see if the source has been hidden by an exception,
4644 -- but only if it is not an exception.
4646 if not Needs_Pragma then
4648 Reverse_Ada_Naming_Exceptions.Get
4649 ((Unit_Kind, Unit_Name, No_Ada_Naming_Exception));
4651 if Except_Name /= No_Name_And_Index then
4652 if Current_Verbosity = High then
4654 Write_Str (Get_Name_String (Canonical_File_Name));
4655 Write_Str (""" contains a unit that is found in """);
4656 Write_Str (Get_Name_String (Except_Name.Name));
4657 Write_Line (""" (ignored).");
4660 -- The file is not included in the source of the project,
4661 -- because it is hidden by the exception.
4662 -- So, there is nothing else to do.
4669 if Exception_Id /= No_Ada_Naming_Exception then
4670 Info := Ada_Naming_Exception_Table.Table (Exception_Id);
4671 Exception_Id := Info.Next;
4672 Info.Next := No_Ada_Naming_Exception;
4673 Name_Index := Reverse_Ada_Naming_Exceptions.Get (Info);
4675 Unit_Name := Info.Unit;
4676 Unit_Index := Name_Index.Index;
4677 Unit_Kind := Info.Kind;
4680 -- Put the file name in the list of sources of the project
4682 if not File_Name_Recorded then
4683 String_Element_Table.Increment_Last
4684 (In_Tree.String_Elements);
4685 In_Tree.String_Elements.Table
4686 (String_Element_Table.Last
4687 (In_Tree.String_Elements)) :=
4688 (Value => Canonical_File_Name,
4689 Display_Value => File_Name,
4690 Location => No_Location,
4693 Index => Unit_Index);
4696 if Current_Source = Nil_String then
4697 Data.Sources := String_Element_Table.Last
4698 (In_Tree.String_Elements);
4700 In_Tree.String_Elements.Table
4701 (Current_Source).Next :=
4702 String_Element_Table.Last
4703 (In_Tree.String_Elements);
4706 Current_Source := String_Element_Table.Last
4707 (In_Tree.String_Elements);
4709 -- Put the unit in unit list
4712 The_Unit : Unit_Id :=
4713 Units_Htable.Get (In_Tree.Units_HT, Unit_Name);
4714 The_Unit_Data : Unit_Data;
4717 if Current_Verbosity = High then
4718 Write_Str ("Putting ");
4719 Write_Str (Get_Name_String (Unit_Name));
4720 Write_Line (" in the unit list.");
4723 -- The unit is already in the list, but may be it is
4724 -- only the other unit kind (spec or body), or what is
4725 -- in the unit list is a unit of a project we are extending.
4727 if The_Unit /= No_Unit then
4728 The_Unit_Data := In_Tree.Units.Table (The_Unit);
4730 if The_Unit_Data.File_Names (Unit_Kind).Name = No_Name
4731 or else Project_Extends
4733 The_Unit_Data.File_Names (Unit_Kind).Project,
4736 if The_Unit_Data.File_Names (Unit_Kind).Path = Slash then
4737 Remove_Forbidden_File_Name
4738 (The_Unit_Data.File_Names (Unit_Kind).Name);
4741 -- Record the file name in the hash table Files_Htable
4743 Unit_Prj := (Unit => The_Unit, Project => Project);
4746 Canonical_File_Name,
4749 The_Unit_Data.File_Names (Unit_Kind) :=
4750 (Name => Canonical_File_Name,
4751 Index => Unit_Index,
4752 Display_Name => File_Name,
4753 Path => Canonical_Path_Name,
4754 Display_Path => Path_Name,
4756 Needs_Pragma => Needs_Pragma);
4757 In_Tree.Units.Table (The_Unit) :=
4759 Source_Recorded := True;
4761 elsif The_Unit_Data.File_Names (Unit_Kind).Project = Project
4762 and then (Data.Known_Order_Of_Source_Dirs or else
4763 The_Unit_Data.File_Names (Unit_Kind).Path =
4764 Canonical_Path_Name)
4766 if Previous_Source = Nil_String then
4767 Data.Sources := Nil_String;
4769 In_Tree.String_Elements.Table
4770 (Previous_Source).Next := Nil_String;
4771 String_Element_Table.Decrement_Last
4772 (In_Tree.String_Elements);
4775 Current_Source := Previous_Source;
4778 -- It is an error to have two units with the same name
4779 -- and the same kind (spec or body).
4781 if The_Location = No_Location then
4783 In_Tree.Projects.Table
4787 Err_Vars.Error_Msg_Name_1 := Unit_Name;
4789 (Project, In_Tree, "duplicate source {", The_Location);
4791 Err_Vars.Error_Msg_Name_1 :=
4792 In_Tree.Projects.Table
4793 (The_Unit_Data.File_Names (Unit_Kind).Project).Name;
4794 Err_Vars.Error_Msg_Name_2 :=
4795 The_Unit_Data.File_Names (Unit_Kind).Path;
4798 "\ project file {, {", The_Location);
4800 Err_Vars.Error_Msg_Name_1 :=
4801 In_Tree.Projects.Table (Project).Name;
4802 Err_Vars.Error_Msg_Name_2 := Canonical_Path_Name;
4805 "\ project file {, {", The_Location);
4808 -- It is a new unit, create a new record
4811 -- First, check if there is no other unit with this file
4812 -- name in another project. If it is, report an error.
4813 -- Of course, we do that only for the first unit in the
4816 Unit_Prj := Files_Htable.Get
4817 (In_Tree.Files_HT, Canonical_File_Name);
4819 if not File_Name_Recorded and then
4820 Unit_Prj /= No_Unit_Project
4822 Error_Msg_Name_1 := File_Name;
4824 In_Tree.Projects.Table
4825 (Unit_Prj.Project).Name;
4828 "{ is already a source of project {",
4832 Unit_Table.Increment_Last (In_Tree.Units);
4833 The_Unit := Unit_Table.Last (In_Tree.Units);
4835 (In_Tree.Units_HT, Unit_Name, The_Unit);
4836 Unit_Prj := (Unit => The_Unit, Project => Project);
4839 Canonical_File_Name,
4841 The_Unit_Data.Name := Unit_Name;
4842 The_Unit_Data.File_Names (Unit_Kind) :=
4843 (Name => Canonical_File_Name,
4844 Index => Unit_Index,
4845 Display_Name => File_Name,
4846 Path => Canonical_Path_Name,
4847 Display_Path => Path_Name,
4849 Needs_Pragma => Needs_Pragma);
4850 In_Tree.Units.Table (The_Unit) :=
4852 Source_Recorded := True;
4857 exit when Exception_Id = No_Ada_Naming_Exception;
4858 File_Name_Recorded := True;
4861 end Record_Ada_Source;
4863 --------------------------
4864 -- Record_Other_Sources --
4865 --------------------------
4867 procedure Record_Other_Sources
4868 (Project : Project_Id;
4869 In_Tree : Project_Tree_Ref;
4870 Data : in out Project_Data;
4871 Language : Language_Index;
4872 Naming_Exceptions : Boolean)
4874 Source_Dir : String_List_Id := Data.Source_Dirs;
4875 Element : String_Element;
4879 Canonical_Name : Name_Id;
4881 Name_Str : String (1 .. 1_024);
4882 Last : Natural := 0;
4885 First_Error : Boolean := True;
4887 Suffix : constant String := Body_Suffix_Of (Language, Data, In_Tree);
4890 while Source_Dir /= Nil_String loop
4891 Element := In_Tree.String_Elements.Table (Source_Dir);
4894 Dir_Path : constant String := Get_Name_String (Element.Value);
4897 if Current_Verbosity = High then
4898 Write_Str ("checking directory """);
4899 Write_Str (Dir_Path);
4900 Write_Str (""" for ");
4902 if Naming_Exceptions then
4903 Write_Str ("naming exceptions");
4906 Write_Str ("sources");
4909 Write_Str (" of Language ");
4910 Display_Language_Name (Language);
4913 Open (Dir, Dir_Path);
4916 Read (Dir, Name_Str, Last);
4920 (Dir_Path & Directory_Separator & Name_Str (1 .. Last))
4923 Name_Buffer (1 .. Name_Len) := Name_Str (1 .. Last);
4924 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
4925 Canonical_Name := Name_Find;
4926 NL := Source_Names.Get (Canonical_Name);
4928 if NL /= No_Name_Location then
4930 if not Data.Known_Order_Of_Source_Dirs then
4931 Error_Msg_Name_1 := Canonical_Name;
4934 "{ is found in several source directories",
4940 Source_Names.Set (Canonical_Name, NL);
4941 Name_Len := Dir_Path'Length;
4942 Name_Buffer (1 .. Name_Len) := Dir_Path;
4943 Add_Char_To_Name_Buffer (Directory_Separator);
4944 Add_Str_To_Name_Buffer (Name_Str (1 .. Last));
4948 (File_Name => Canonical_Name,
4953 Location => NL.Location,
4954 Language => Language,
4956 Naming_Exception => Naming_Exceptions);
4965 Source_Dir := Element.Next;
4968 if not Naming_Exceptions then
4969 NL := Source_Names.Get_First;
4971 -- It is an error if a source file name in a source list or
4972 -- in a source list file is not found.
4974 while NL /= No_Name_Location loop
4975 if not NL.Found then
4976 Err_Vars.Error_Msg_Name_1 := NL.Name;
4981 "source file { cannot be found",
4983 First_Error := False;
4988 "\source file { cannot be found",
4993 NL := Source_Names.Get_Next;
4996 -- Any naming exception of this language that is not in a list
4997 -- of sources must be removed.
5000 Source_Id : Other_Source_Id := Data.First_Other_Source;
5001 Prev_Id : Other_Source_Id := No_Other_Source;
5002 Source : Other_Source;
5005 while Source_Id /= No_Other_Source loop
5006 Source := In_Tree.Other_Sources.Table (Source_Id);
5008 if Source.Language = Language
5009 and then Source.Naming_Exception
5011 if Current_Verbosity = High then
5012 Write_Str ("Naming exception """);
5013 Write_Str (Get_Name_String (Source.File_Name));
5014 Write_Str (""" is not in the list of sources,");
5015 Write_Line (" so it is removed.");
5018 if Prev_Id = No_Other_Source then
5019 Data.First_Other_Source := Source.Next;
5022 In_Tree.Other_Sources.Table
5023 (Prev_Id).Next := Source.Next;
5026 Source_Id := Source.Next;
5028 if Source_Id = No_Other_Source then
5029 Data.Last_Other_Source := Prev_Id;
5033 Prev_Id := Source_Id;
5034 Source_Id := Source.Next;
5039 end Record_Other_Sources;
5041 ----------------------
5042 -- Show_Source_Dirs --
5043 ----------------------
5045 procedure Show_Source_Dirs
5046 (Project : Project_Id;
5047 In_Tree : Project_Tree_Ref)
5049 Current : String_List_Id;
5050 Element : String_Element;
5053 Write_Line ("Source_Dirs:");
5055 Current := In_Tree.Projects.Table (Project).Source_Dirs;
5056 while Current /= Nil_String loop
5057 Element := In_Tree.String_Elements.Table (Current);
5059 Write_Line (Get_Name_String (Element.Value));
5060 Current := Element.Next;
5063 Write_Line ("end Source_Dirs.");
5064 end Show_Source_Dirs;
5071 (Language : Language_Index;
5072 Naming : Naming_Data;
5073 In_Tree : Project_Tree_Ref) return Name_Id
5075 Suffix : constant Variable_Value :=
5077 (Index => Language_Names.Table (Language),
5079 In_Array => Naming.Body_Suffix,
5080 In_Tree => In_Tree);
5082 -- If no suffix for this language in package Naming, use the default
5084 if Suffix = Nil_Variable_Value then
5088 when Ada_Language_Index =>
5089 Add_Str_To_Name_Buffer (".adb");
5091 when C_Language_Index =>
5092 Add_Str_To_Name_Buffer (".c");
5094 when C_Plus_Plus_Language_Index =>
5095 Add_Str_To_Name_Buffer (".cpp");
5101 -- Otherwise use the one specified
5104 Get_Name_String (Suffix.Value);
5107 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
5111 -------------------------
5112 -- Warn_If_Not_Sources --
5113 -------------------------
5115 -- comments needed in this body ???
5117 procedure Warn_If_Not_Sources
5118 (Project : Project_Id;
5119 In_Tree : Project_Tree_Ref;
5120 Conventions : Array_Element_Id;
5122 Extending : Boolean)
5124 Conv : Array_Element_Id := Conventions;
5126 The_Unit_Id : Unit_Id;
5127 The_Unit_Data : Unit_Data;
5128 Location : Source_Ptr;
5131 while Conv /= No_Array_Element loop
5132 Unit := In_Tree.Array_Elements.Table (Conv).Index;
5133 Error_Msg_Name_1 := Unit;
5134 Get_Name_String (Unit);
5135 To_Lower (Name_Buffer (1 .. Name_Len));
5137 The_Unit_Id := Units_Htable.Get
5138 (In_Tree.Units_HT, Unit);
5139 Location := In_Tree.Array_Elements.Table
5140 (Conv).Value.Location;
5142 if The_Unit_Id = No_Unit then
5149 The_Unit_Data := In_Tree.Units.Table (The_Unit_Id);
5152 if not Check_Project
5153 (The_Unit_Data.File_Names (Specification).Project,
5154 Project, In_Tree, Extending)
5158 "?unit{ has no spec in this project",
5163 if not Check_Project
5164 (The_Unit_Data.File_Names (Body_Part).Project,
5165 Project, In_Tree, Extending)
5169 "?unit{ has no body in this project",
5175 Conv := In_Tree.Array_Elements.Table (Conv).Next;
5177 end Warn_If_Not_Sources;