1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2000-2008, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with GNAT.Case_Util; use GNAT.Case_Util;
27 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
30 with Err_Vars; use Err_Vars;
35 with Osint; use Osint;
36 with Output; use Output;
37 with Prj.Env; use Prj.Env;
39 with Prj.Util; use Prj.Util;
41 with Snames; use Snames;
42 with Table; use Table;
43 with Targparm; use Targparm;
45 with Ada.Characters.Handling; use Ada.Characters.Handling;
46 with Ada.Directories; use Ada.Directories;
47 with Ada.Strings; use Ada.Strings;
48 with Ada.Strings.Fixed; use Ada.Strings.Fixed;
49 with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
51 package body Prj.Nmsc is
53 No_Continuation_String : aliased String := "";
54 Continuation_String : aliased String := "\";
55 -- Used in Check_Library for continuation error messages at the same
58 Error_Report : Put_Line_Access := null;
59 -- Set to point to error reporting procedure
61 When_No_Sources : Error_Warning := Error;
62 -- Indicates what should be done when there is no Ada sources in a non
63 -- extending Ada project.
65 ALI_Suffix : constant String := ".ali";
66 -- File suffix for ali files
68 type Name_Location is record
69 Name : File_Name_Type;
70 Location : Source_Ptr;
71 Source : Source_Id := No_Source;
72 Except : Boolean := False;
73 Found : Boolean := False;
75 -- Information about file names found in string list attribute
76 -- Source_Files or in a source list file, stored in hash table
77 -- Source_Names, used by procedure Get_Path_Names_And_Record_Sources.
79 No_Name_Location : constant Name_Location :=
81 Location => No_Location,
86 package Source_Names is new GNAT.HTable.Simple_HTable
87 (Header_Num => Header_Num,
88 Element => Name_Location,
89 No_Element => No_Name_Location,
90 Key => File_Name_Type,
93 -- Hash table to store file names found in string list attribute
94 -- Source_Files or in a source list file, stored in hash table
95 -- Source_Names, used by procedure Get_Path_Names_And_Record_Sources.
97 -- More documentation needed on what unit exceptions are about ???
99 type Unit_Exception is record
101 Spec : File_Name_Type;
102 Impl : File_Name_Type;
105 No_Unit_Exception : constant Unit_Exception :=
110 package Unit_Exceptions is new GNAT.HTable.Simple_HTable
111 (Header_Num => Header_Num,
112 Element => Unit_Exception,
113 No_Element => No_Unit_Exception,
117 -- Hash table to store the unit exceptions
119 package Recursive_Dirs is new GNAT.HTable.Simple_HTable
120 (Header_Num => Header_Num,
126 -- Hash table to store recursive source directories, to avoid looking
127 -- several times, and to avoid cycles that may be introduced by symbolic
130 type Ada_Naming_Exception_Id is new Nat;
131 No_Ada_Naming_Exception : constant Ada_Naming_Exception_Id := 0;
133 type Unit_Info is record
136 Next : Ada_Naming_Exception_Id := No_Ada_Naming_Exception;
140 -- Why is the following commented out ???
141 -- No_Unit : constant Unit_Info :=
142 -- (Specification, No_Name, No_Ada_Naming_Exception);
144 package Ada_Naming_Exception_Table is new Table.Table
145 (Table_Component_Type => Unit_Info,
146 Table_Index_Type => Ada_Naming_Exception_Id,
147 Table_Low_Bound => 1,
149 Table_Increment => 100,
150 Table_Name => "Prj.Nmsc.Ada_Naming_Exception_Table");
152 package Ada_Naming_Exceptions is new GNAT.HTable.Simple_HTable
153 (Header_Num => Header_Num,
154 Element => Ada_Naming_Exception_Id,
155 No_Element => No_Ada_Naming_Exception,
156 Key => File_Name_Type,
159 -- A hash table to store naming exceptions for Ada. For each file name
160 -- there is one or several unit in table Ada_Naming_Exception_Table.
162 package Object_File_Names is new GNAT.HTable.Simple_HTable
163 (Header_Num => Header_Num,
164 Element => File_Name_Type,
165 No_Element => No_File,
166 Key => File_Name_Type,
169 -- A hash table to store the object file names for a project, to check that
170 -- two different sources have different object file names.
172 type File_Found is record
173 File : File_Name_Type := No_File;
174 Found : Boolean := False;
175 Location : Source_Ptr := No_Location;
177 No_File_Found : constant File_Found := (No_File, False, No_Location);
178 -- Comments needed ???
180 package Excluded_Sources_Htable is new GNAT.HTable.Simple_HTable
181 (Header_Num => Header_Num,
182 Element => File_Found,
183 No_Element => No_File_Found,
184 Key => File_Name_Type,
187 -- A hash table to store the excluded files, if any. This is filled by
188 -- Find_Excluded_Sources below.
190 procedure Find_Excluded_Sources
191 (Project : Project_Id;
192 In_Tree : Project_Tree_Ref;
193 Data : Project_Data);
194 -- Find the list of files that should not be considered as source files
195 -- for this project. Sets the list in the Excluded_Sources_Htable.
197 function Hash (Unit : Unit_Info) return Header_Num;
199 type Name_And_Index is record
200 Name : Name_Id := No_Name;
203 No_Name_And_Index : constant Name_And_Index :=
204 (Name => No_Name, Index => 0);
206 package Reverse_Ada_Naming_Exceptions is new GNAT.HTable.Simple_HTable
207 (Header_Num => Header_Num,
208 Element => Name_And_Index,
209 No_Element => No_Name_And_Index,
213 -- A table to check if a unit with an exceptional name will hide a source
214 -- with a file name following the naming convention.
218 Data : in out Project_Data;
219 In_Tree : Project_Tree_Ref;
220 Project : Project_Id;
222 Lang_Id : Language_Index;
224 File_Name : File_Name_Type;
225 Display_File : File_Name_Type;
226 Lang_Kind : Language_Kind;
227 Naming_Exception : Boolean := False;
228 Path : Path_Name_Type := No_Path;
229 Display_Path : Path_Name_Type := No_Path;
230 Alternate_Languages : Alternate_Language_Id := No_Alternate_Language;
231 Other_Part : Source_Id := No_Source;
232 Unit : Name_Id := No_Name;
234 Source_To_Replace : Source_Id := No_Source);
235 -- Add a new source to the different lists: list of all sources in the
236 -- project tree, list of source of a project and list of sources of a
239 -- If Path is specified, the file is also added to Source_Paths_HT.
240 -- If Source_To_Replace is specified, it points to the source in the
241 -- extended project that the new file is overriding.
243 function ALI_File_Name (Source : String) return String;
244 -- Return the ALI file name corresponding to a source
246 procedure Check_Ada_Name (Name : String; Unit : out Name_Id);
247 -- Check that a name is a valid Ada unit name
249 procedure Check_Naming_Schemes
250 (Data : in out Project_Data;
251 Project : Project_Id;
252 In_Tree : Project_Tree_Ref);
253 -- Check the naming scheme part of Data
255 procedure Check_Ada_Naming_Scheme_Validity
256 (Project : Project_Id;
257 In_Tree : Project_Tree_Ref;
258 Naming : Naming_Data);
259 -- Check that the package Naming is correct
261 procedure Check_Configuration
262 (Project : Project_Id;
263 In_Tree : Project_Tree_Ref;
264 Data : in out Project_Data);
265 -- Check the configuration attributes for the project
267 procedure Check_If_Externally_Built
268 (Project : Project_Id;
269 In_Tree : Project_Tree_Ref;
270 Data : in out Project_Data);
271 -- Check attribute Externally_Built of project Project in project tree
272 -- In_Tree and modify its data Data if it has the value "true".
274 procedure Check_Interfaces
275 (Project : Project_Id;
276 In_Tree : Project_Tree_Ref;
277 Data : in out Project_Data);
278 -- If a list of sources is specified in attribute Interfaces, set
279 -- In_Interfaces only for the sources specified in the list.
281 procedure Check_Library_Attributes
282 (Project : Project_Id;
283 In_Tree : Project_Tree_Ref;
284 Current_Dir : String;
285 Data : in out Project_Data);
286 -- Check the library attributes of project Project in project tree In_Tree
287 -- and modify its data Data accordingly.
288 -- Current_Dir should represent the current directory, and is passed for
289 -- efficiency to avoid system calls to recompute it.
291 procedure Check_Package_Naming
292 (Project : Project_Id;
293 In_Tree : Project_Tree_Ref;
294 Data : in out Project_Data);
295 -- Check package Naming of project Project in project tree In_Tree and
296 -- modify its data Data accordingly.
298 procedure Check_Programming_Languages
299 (In_Tree : Project_Tree_Ref;
300 Project : Project_Id;
301 Data : in out Project_Data);
302 -- Check attribute Languages for the project with data Data in project
303 -- tree In_Tree and set the components of Data for all the programming
304 -- languages indicated in attribute Languages, if any.
306 function Check_Project
308 Root_Project : Project_Id;
309 In_Tree : Project_Tree_Ref;
310 Extending : Boolean) return Boolean;
311 -- Returns True if P is Root_Project or, if Extending is True, a project
312 -- extended by Root_Project.
314 procedure Check_Stand_Alone_Library
315 (Project : Project_Id;
316 In_Tree : Project_Tree_Ref;
317 Data : in out Project_Data;
318 Current_Dir : String;
319 Extending : Boolean);
320 -- Check if project Project in project tree In_Tree is a Stand-Alone
321 -- Library project, and modify its data Data accordingly if it is one.
322 -- Current_Dir should represent the current directory, and is passed for
323 -- efficiency to avoid system calls to recompute it.
325 procedure Get_Path_Names_And_Record_Ada_Sources
326 (Project : Project_Id;
327 In_Tree : Project_Tree_Ref;
328 Data : in out Project_Data;
329 Current_Dir : String);
330 -- Find the path names of the source files in the Source_Names table
331 -- in the source directories and record those that are Ada sources.
333 function Compute_Directory_Last (Dir : String) return Natural;
334 -- Return the index of the last significant character in Dir. This is used
335 -- to avoid duplicate '/' (slash) characters at the end of directory names.
338 (Project : Project_Id;
339 In_Tree : Project_Tree_Ref;
341 Flag_Location : Source_Ptr);
342 -- Output an error message. If Error_Report is null, simply call
343 -- Prj.Err.Error_Msg. Otherwise, disregard Flag_Location and use
346 procedure Find_Ada_Sources
347 (Project : Project_Id;
348 In_Tree : Project_Tree_Ref;
349 Data : in out Project_Data;
350 Current_Dir : String);
351 -- Find all the Ada sources in all of the source directories of a project
352 -- Current_Dir should represent the current directory, and is passed for
353 -- efficiency to avoid system calls to recompute it.
355 procedure Search_Directories
356 (Project : Project_Id;
357 In_Tree : Project_Tree_Ref;
358 Data : in out Project_Data;
359 For_All_Sources : Boolean);
360 -- Search the source directories to find the sources.
361 -- If For_All_Sources is True, check each regular file name against the
362 -- naming schemes of the different languages. Otherwise consider only the
363 -- file names in the hash table Source_Names.
366 (Project : Project_Id;
367 In_Tree : Project_Tree_Ref;
368 Data : in out Project_Data;
370 File_Name : File_Name_Type;
371 Display_File_Name : File_Name_Type;
372 Source_Directory : String;
373 For_All_Sources : Boolean);
374 -- Check if file File_Name is a valid source of the project. This is used
375 -- in multi-language mode only.
376 -- When the file matches one of the naming schemes, it is added to
377 -- various htables through Add_Source and to Source_Paths_Htable.
379 -- Name is the name of the candidate file. It hasn't been normalized yet
380 -- and is the direct result of readdir().
382 -- File_Name is the same as Name, but has been normalized.
383 -- Display_File_Name, however, has not been normalized.
385 -- Source_Directory is the directory in which the file
386 -- was found. It hasn't been normalized (nor has had links resolved).
387 -- It should not end with a directory separator, to avoid duplicates
390 -- If For_All_Sources is True, then all possible file names are analyzed
391 -- otherwise only those currently set in the Source_Names htable.
393 procedure Check_Naming_Schemes
394 (In_Tree : Project_Tree_Ref;
395 Data : in out Project_Data;
397 File_Name : File_Name_Type;
398 Alternate_Languages : out Alternate_Language_Id;
399 Language : out Language_Index;
400 Language_Name : out Name_Id;
401 Display_Language_Name : out Name_Id;
403 Lang_Kind : out Language_Kind;
404 Kind : out Source_Kind);
405 -- Check if the file name File_Name conforms to one of the naming
406 -- schemes of the project.
408 -- If the file does not match one of the naming schemes, set Language
409 -- to No_Language_Index.
411 -- Filename is the name of the file being investigated. It has been
412 -- normalized (case-folded). File_Name is the same value.
414 procedure Free_Ada_Naming_Exceptions;
415 -- Free the internal hash tables used for checking naming exceptions
417 procedure Get_Directories
418 (Project : Project_Id;
419 In_Tree : Project_Tree_Ref;
420 Current_Dir : String;
421 Data : in out Project_Data);
422 -- Get the object directory, the exec directory and the source directories
425 -- Current_Dir should represent the current directory, and is passed for
426 -- efficiency to avoid system calls to recompute it.
429 (Project : Project_Id;
430 In_Tree : Project_Tree_Ref;
431 Data : in out Project_Data);
432 -- Get the mains of a project from attribute Main, if it exists, and put
433 -- them in the project data.
435 procedure Get_Sources_From_File
437 Location : Source_Ptr;
438 Project : Project_Id;
439 In_Tree : Project_Tree_Ref);
440 -- Get the list of sources from a text file and put them in hash table
443 procedure Find_Explicit_Sources
444 (Current_Dir : String;
445 Project : Project_Id;
446 In_Tree : Project_Tree_Ref;
447 Data : in out Project_Data);
448 -- Process the Source_Files and Source_List_File attributes, and store
449 -- the list of source files into the Source_Names htable.
451 -- Lang indicates which language is being processed when in Ada_Only mode
452 -- (all languages are processed anyway when in Multi_Language mode).
455 (In_Tree : Project_Tree_Ref;
456 Canonical_File_Name : File_Name_Type;
457 Naming : Naming_Data;
458 Exception_Id : out Ada_Naming_Exception_Id;
459 Unit_Name : out Name_Id;
460 Unit_Kind : out Spec_Or_Body;
461 Needs_Pragma : out Boolean);
462 -- Find out, from a file name, the unit name, the unit kind and if a
463 -- specific SFN pragma is needed. If the file name corresponds to no unit,
464 -- then Unit_Name will be No_Name. If the file is a multi-unit source or an
465 -- exception to the naming scheme, then Exception_Id is set to the unit or
466 -- units that the source contains.
468 function Is_Illegal_Suffix
470 Dot_Replacement_Is_A_Single_Dot : Boolean) return Boolean;
471 -- Returns True if the string Suffix cannot be used as a spec suffix, a
472 -- body suffix or a separate suffix.
474 procedure Locate_Directory
475 (Project : Project_Id;
476 In_Tree : Project_Tree_Ref;
477 Name : File_Name_Type;
478 Parent : Path_Name_Type;
479 Dir : out Path_Name_Type;
480 Display : out Path_Name_Type;
481 Create : String := "";
482 Current_Dir : String;
483 Location : Source_Ptr := No_Location);
484 -- Locate a directory. Name is the directory name. Parent is the root
485 -- directory, if Name a relative path name. Dir is set to the canonical
486 -- case path name of the directory, and Display is the directory path name
487 -- for display purposes. If the directory does not exist and Project_Setup
488 -- is True and Create is a non null string, an attempt is made to create
489 -- the directory. If the directory does not exist and Project_Setup is
490 -- false, then Dir and Display are set to No_Name.
492 -- Current_Dir should represent the current directory, and is passed for
493 -- efficiency to avoid system calls to recompute it.
495 procedure Look_For_Sources
496 (Project : Project_Id;
497 In_Tree : Project_Tree_Ref;
498 Data : in out Project_Data;
499 Current_Dir : String);
500 -- Find all the sources of project Project in project tree In_Tree and
501 -- update its Data accordingly.
503 -- Current_Dir should represent the current directory, and is passed for
504 -- efficiency to avoid system calls to recompute it.
506 function Path_Name_Of
507 (File_Name : File_Name_Type;
508 Directory : Path_Name_Type) return String;
509 -- Returns the path name of a (non project) file. Returns an empty string
510 -- if file cannot be found.
512 procedure Prepare_Ada_Naming_Exceptions
513 (List : Array_Element_Id;
514 In_Tree : Project_Tree_Ref;
515 Kind : Spec_Or_Body);
516 -- Prepare the internal hash tables used for checking naming exceptions
517 -- for Ada. Insert all elements of List in the tables.
519 function Project_Extends
520 (Extending : Project_Id;
521 Extended : Project_Id;
522 In_Tree : Project_Tree_Ref) return Boolean;
523 -- Returns True if Extending is extending Extended either directly or
526 procedure Record_Ada_Source
527 (File_Name : File_Name_Type;
528 Path_Name : Path_Name_Type;
529 Project : Project_Id;
530 In_Tree : Project_Tree_Ref;
531 Data : in out Project_Data;
532 Location : Source_Ptr;
533 Current_Source : in out String_List_Id;
534 Source_Recorded : in out Boolean;
535 Current_Dir : String);
536 -- Put a unit in the list of units of a project, if the file name
537 -- corresponds to a valid unit name.
539 -- Current_Dir should represent the current directory, and is passed for
540 -- efficiency to avoid system calls to recompute it.
542 procedure Remove_Source
544 Replaced_By : Source_Id;
545 Project : Project_Id;
546 Data : in out Project_Data;
547 In_Tree : Project_Tree_Ref);
550 procedure Report_No_Sources
551 (Project : Project_Id;
553 In_Tree : Project_Tree_Ref;
554 Location : Source_Ptr;
555 Continuation : Boolean := False);
556 -- Report an error or a warning depending on the value of When_No_Sources
557 -- when there are no sources for language Lang_Name.
559 procedure Show_Source_Dirs
560 (Data : Project_Data; In_Tree : Project_Tree_Ref);
561 -- List all the source directories of a project
563 procedure Warn_If_Not_Sources
564 (Project : Project_Id;
565 In_Tree : Project_Tree_Ref;
566 Conventions : Array_Element_Id;
568 Extending : Boolean);
569 -- Check that individual naming conventions apply to immediate sources of
570 -- the project. If not, issue a warning.
578 Data : in out Project_Data;
579 In_Tree : Project_Tree_Ref;
580 Project : Project_Id;
582 Lang_Id : Language_Index;
584 File_Name : File_Name_Type;
585 Display_File : File_Name_Type;
586 Lang_Kind : Language_Kind;
587 Naming_Exception : Boolean := False;
588 Path : Path_Name_Type := No_Path;
589 Display_Path : Path_Name_Type := No_Path;
590 Alternate_Languages : Alternate_Language_Id := No_Alternate_Language;
591 Other_Part : Source_Id := No_Source;
592 Unit : Name_Id := No_Name;
594 Source_To_Replace : Source_Id := No_Source)
596 Source : constant Source_Id := Data.Last_Source;
597 Src_Data : Source_Data := No_Source_Data;
598 Config : constant Language_Config :=
599 In_Tree.Languages_Data.Table (Lang_Id).Config;
602 -- This is a new source so create an entry for it in the Sources table
604 Source_Data_Table.Increment_Last (In_Tree.Sources);
605 Id := Source_Data_Table.Last (In_Tree.Sources);
607 if Current_Verbosity = High then
608 Write_Str ("Adding source #");
610 Write_Str (", File : ");
611 Write_Str (Get_Name_String (File_Name));
613 if Lang_Kind = Unit_Based then
614 Write_Str (", Unit : ");
615 Write_Str (Get_Name_String (Unit));
621 Src_Data.Project := Project;
622 Src_Data.Language_Name := Lang;
623 Src_Data.Language := Lang_Id;
624 Src_Data.Lang_Kind := Lang_Kind;
625 Src_Data.Compiled := In_Tree.Languages_Data.Table
626 (Lang_Id).Config.Compiler_Driver /=
628 Src_Data.Kind := Kind;
629 Src_Data.Alternate_Languages := Alternate_Languages;
630 Src_Data.Other_Part := Other_Part;
632 Src_Data.Object_Exists := Config.Object_Generated;
633 Src_Data.Object_Linked := Config.Objects_Linked;
635 if Other_Part /= No_Source then
636 In_Tree.Sources.Table (Other_Part).Other_Part := Id;
639 Src_Data.Unit := Unit;
640 Src_Data.Index := Index;
641 Src_Data.File := File_Name;
642 Src_Data.Display_File := Display_File;
643 Src_Data.Dependency := In_Tree.Languages_Data.Table
644 (Lang_Id).Config.Dependency_Kind;
645 Src_Data.Naming_Exception := Naming_Exception;
647 if Src_Data.Compiled and then Src_Data.Object_Exists then
648 Src_Data.Object := Object_Name (File_Name);
650 Dependency_Name (File_Name, Src_Data.Dependency);
651 Src_Data.Switches := Switches_Name (File_Name);
654 if Path /= No_Path then
655 Src_Data.Path := (Path, Display_Path);
656 Source_Paths_Htable.Set (In_Tree.Source_Paths_HT, Path, Id);
659 -- Add the source to the global list
661 Src_Data.Next_In_Sources := In_Tree.First_Source;
662 In_Tree.First_Source := Id;
664 -- Add the source to the project list
666 if Source = No_Source then
667 Data.First_Source := Id;
669 In_Tree.Sources.Table (Source).Next_In_Project := Id;
672 Data.Last_Source := Id;
674 -- Add the source to the language list
676 Src_Data.Next_In_Lang :=
677 In_Tree.Languages_Data.Table (Lang_Id).First_Source;
678 In_Tree.Languages_Data.Table (Lang_Id).First_Source := Id;
680 In_Tree.Sources.Table (Id) := Src_Data;
682 if Source_To_Replace /= No_Source then
683 Remove_Source (Source_To_Replace, Id, Project, Data, In_Tree);
691 function ALI_File_Name (Source : String) return String is
693 -- If the source name has an extension, then replace it with
696 for Index in reverse Source'First + 1 .. Source'Last loop
697 if Source (Index) = '.' then
698 return Source (Source'First .. Index - 1) & ALI_Suffix;
702 -- If there is no dot, or if it is the first character, just add the
705 return Source & ALI_Suffix;
713 (Project : Project_Id;
714 In_Tree : Project_Tree_Ref;
715 Report_Error : Put_Line_Access;
716 When_No_Sources : Error_Warning;
717 Current_Dir : String)
719 Data : Project_Data := In_Tree.Projects.Table (Project);
720 Extending : Boolean := False;
723 Nmsc.When_No_Sources := When_No_Sources;
724 Error_Report := Report_Error;
726 Recursive_Dirs.Reset;
728 Check_If_Externally_Built (Project, In_Tree, Data);
730 -- Object, exec and source directories
732 Get_Directories (Project, In_Tree, Current_Dir, Data);
734 -- Get the programming languages
736 Check_Programming_Languages (In_Tree, Project, Data);
738 if Data.Qualifier = Dry and then Data.Source_Dirs /= Nil_String then
741 "an abstract project need to have no language, no sources or no " &
742 "source directories",
746 -- Check configuration in multi language mode
748 if Must_Check_Configuration then
749 Check_Configuration (Project, In_Tree, Data);
752 -- Library attributes
754 Check_Library_Attributes (Project, In_Tree, Current_Dir, Data);
756 if Current_Verbosity = High then
757 Show_Source_Dirs (Data, In_Tree);
760 Check_Package_Naming (Project, In_Tree, Data);
762 Extending := Data.Extends /= No_Project;
764 Check_Naming_Schemes (Data, Project, In_Tree);
766 if Get_Mode = Ada_Only then
767 Prepare_Ada_Naming_Exceptions
768 (Data.Naming.Bodies, In_Tree, Body_Part);
769 Prepare_Ada_Naming_Exceptions
770 (Data.Naming.Specs, In_Tree, Specification);
775 if Data.Source_Dirs /= Nil_String then
776 Look_For_Sources (Project, In_Tree, Data, Current_Dir);
778 if Get_Mode = Ada_Only then
780 -- Check that all individual naming conventions apply to sources
781 -- of this project file.
784 (Project, In_Tree, Data.Naming.Bodies,
786 Extending => Extending);
788 (Project, In_Tree, Data.Naming.Specs,
790 Extending => Extending);
792 elsif Get_Mode = Multi_Language and then
793 (not Data.Externally_Built) and then
797 Language : Language_Index;
799 Src_Data : Source_Data;
800 Alt_Lang : Alternate_Language_Id;
801 Alt_Lang_Data : Alternate_Language_Data;
802 Continuation : Boolean := False;
805 Language := Data.First_Language_Processing;
806 while Language /= No_Language_Index loop
807 Source := Data.First_Source;
808 Source_Loop : while Source /= No_Source loop
809 Src_Data := In_Tree.Sources.Table (Source);
811 exit Source_Loop when Src_Data.Language = Language;
813 Alt_Lang := Src_Data.Alternate_Languages;
816 while Alt_Lang /= No_Alternate_Language loop
818 In_Tree.Alt_Langs.Table (Alt_Lang);
820 when Alt_Lang_Data.Language = Language;
821 Alt_Lang := Alt_Lang_Data.Next;
822 end loop Alternate_Loop;
824 Source := Src_Data.Next_In_Project;
825 end loop Source_Loop;
827 if Source = No_Source then
831 (In_Tree.Languages_Data.Table
832 (Language).Display_Name),
836 Continuation := True;
839 Language := In_Tree.Languages_Data.Table (Language).Next;
845 if Get_Mode = Multi_Language then
847 -- If a list of sources is specified in attribute Interfaces, set
848 -- In_Interfaces only for the sources specified in the list.
850 Check_Interfaces (Project, In_Tree, Data);
853 -- If it is a library project file, check if it is a standalone library
856 Check_Stand_Alone_Library
857 (Project, In_Tree, Data, Current_Dir, Extending);
860 -- Put the list of Mains, if any, in the project data
862 Get_Mains (Project, In_Tree, Data);
864 -- Update the project data in the Projects table
866 In_Tree.Projects.Table (Project) := Data;
868 Free_Ada_Naming_Exceptions;
875 procedure Check_Ada_Name (Name : String; Unit : out Name_Id) is
876 The_Name : String := Name;
878 Need_Letter : Boolean := True;
879 Last_Underscore : Boolean := False;
880 OK : Boolean := The_Name'Length > 0;
883 function Is_Reserved (Name : Name_Id) return Boolean;
884 function Is_Reserved (S : String) return Boolean;
885 -- Check that the given name is not an Ada 95 reserved word. The reason
886 -- for the Ada 95 here is that we do not want to exclude the case of an
887 -- Ada 95 unit called Interface (for example). In Ada 2005, such a unit
888 -- name would be rejected anyway by the compiler. That means there is no
889 -- requirement that the project file parser reject this.
895 function Is_Reserved (S : String) return Boolean is
898 Add_Str_To_Name_Buffer (S);
899 return Is_Reserved (Name_Find);
906 function Is_Reserved (Name : Name_Id) return Boolean is
908 if Get_Name_Table_Byte (Name) /= 0
909 and then Name /= Name_Project
910 and then Name /= Name_Extends
911 and then Name /= Name_External
912 and then Name not in Ada_2005_Reserved_Words
916 if Current_Verbosity = High then
917 Write_Str (The_Name);
918 Write_Line (" is an Ada reserved word.");
928 -- Start of processing for Check_Ada_Name
933 Name_Len := The_Name'Length;
934 Name_Buffer (1 .. Name_Len) := The_Name;
936 -- Special cases of children of packages A, G, I and S on VMS
939 and then Name_Len > 3
940 and then Name_Buffer (2 .. 3) = "__"
942 ((Name_Buffer (1) = 'a') or else
943 (Name_Buffer (1) = 'g') or else
944 (Name_Buffer (1) = 'i') or else
945 (Name_Buffer (1) = 's'))
947 Name_Buffer (2) := '.';
948 Name_Buffer (3 .. Name_Len - 1) := Name_Buffer (4 .. Name_Len);
949 Name_Len := Name_Len - 1;
952 Real_Name := Name_Find;
954 if Is_Reserved (Real_Name) then
958 First := The_Name'First;
960 for Index in The_Name'Range loop
963 -- We need a letter (at the beginning, and following a dot),
964 -- but we don't have one.
966 if Is_Letter (The_Name (Index)) then
967 Need_Letter := False;
972 if Current_Verbosity = High then
973 Write_Int (Types.Int (Index));
975 Write_Char (The_Name (Index));
976 Write_Line ("' is not a letter.");
982 elsif Last_Underscore
983 and then (The_Name (Index) = '_' or else The_Name (Index) = '.')
985 -- Two underscores are illegal, and a dot cannot follow
990 if Current_Verbosity = High then
991 Write_Int (Types.Int (Index));
993 Write_Char (The_Name (Index));
994 Write_Line ("' is illegal here.");
999 elsif The_Name (Index) = '.' then
1001 -- First, check if the name before the dot is not a reserved word
1002 if Is_Reserved (The_Name (First .. Index - 1)) then
1008 -- We need a letter after a dot
1010 Need_Letter := True;
1012 elsif The_Name (Index) = '_' then
1013 Last_Underscore := True;
1016 -- We need an letter or a digit
1018 Last_Underscore := False;
1020 if not Is_Alphanumeric (The_Name (Index)) then
1023 if Current_Verbosity = High then
1024 Write_Int (Types.Int (Index));
1026 Write_Char (The_Name (Index));
1027 Write_Line ("' is not alphanumeric.");
1035 -- Cannot end with an underscore or a dot
1037 OK := OK and then not Need_Letter and then not Last_Underscore;
1040 if First /= Name'First and then
1041 Is_Reserved (The_Name (First .. The_Name'Last))
1049 -- Signal a problem with No_Name
1055 --------------------------------------
1056 -- Check_Ada_Naming_Scheme_Validity --
1057 --------------------------------------
1059 procedure Check_Ada_Naming_Scheme_Validity
1060 (Project : Project_Id;
1061 In_Tree : Project_Tree_Ref;
1062 Naming : Naming_Data)
1065 -- Only check if we are not using the Default naming scheme
1067 if Naming /= In_Tree.Private_Part.Default_Naming then
1069 Dot_Replacement : constant String :=
1071 (Naming.Dot_Replacement);
1073 Spec_Suffix : constant String :=
1074 Spec_Suffix_Of (In_Tree, "ada", Naming);
1076 Body_Suffix : constant String :=
1077 Body_Suffix_Of (In_Tree, "ada", Naming);
1079 Separate_Suffix : constant String :=
1081 (Naming.Separate_Suffix);
1084 -- Dot_Replacement cannot
1087 -- - start or end with an alphanumeric
1088 -- - be a single '_'
1089 -- - start with an '_' followed by an alphanumeric
1090 -- - contain a '.' except if it is "."
1092 if Dot_Replacement'Length = 0
1093 or else Is_Alphanumeric
1094 (Dot_Replacement (Dot_Replacement'First))
1095 or else Is_Alphanumeric
1096 (Dot_Replacement (Dot_Replacement'Last))
1097 or else (Dot_Replacement (Dot_Replacement'First) = '_'
1099 (Dot_Replacement'Length = 1
1102 (Dot_Replacement (Dot_Replacement'First + 1))))
1103 or else (Dot_Replacement'Length > 1
1105 Index (Source => Dot_Replacement,
1106 Pattern => ".") /= 0)
1110 '"' & Dot_Replacement &
1111 """ is illegal for Dot_Replacement.",
1112 Naming.Dot_Repl_Loc);
1118 if Is_Illegal_Suffix
1119 (Spec_Suffix, Dot_Replacement = ".")
1121 Err_Vars.Error_Msg_File_1 :=
1122 Spec_Suffix_Id_Of (In_Tree, Name_Ada, Naming);
1125 "{ is illegal for Spec_Suffix",
1126 Naming.Ada_Spec_Suffix_Loc);
1129 if Is_Illegal_Suffix
1130 (Body_Suffix, Dot_Replacement = ".")
1132 Err_Vars.Error_Msg_File_1 :=
1133 Body_Suffix_Id_Of (In_Tree, Name_Ada, Naming);
1136 "{ is illegal for Body_Suffix",
1137 Naming.Ada_Body_Suffix_Loc);
1140 if Body_Suffix /= Separate_Suffix then
1141 if Is_Illegal_Suffix
1142 (Separate_Suffix, Dot_Replacement = ".")
1144 Err_Vars.Error_Msg_File_1 := Naming.Separate_Suffix;
1147 "{ is illegal for Separate_Suffix",
1148 Naming.Sep_Suffix_Loc);
1152 -- Spec_Suffix cannot be equal to Body_Suffix Separate_Suffix,
1153 -- since that would cause a clear ambiguity. Note that we do
1154 -- allow a Spec_Suffix to have the same termination as one of
1155 -- these, which causes a potential ambiguity, but we resolve
1156 -- that my matching the longest possible suffix.
1158 if Spec_Suffix = Body_Suffix then
1163 """) cannot be the same as Spec_Suffix.",
1164 Naming.Ada_Body_Suffix_Loc);
1167 if Body_Suffix /= Separate_Suffix
1168 and then Spec_Suffix = Separate_Suffix
1172 "Separate_Suffix (""" &
1174 """) cannot be the same as Spec_Suffix.",
1175 Naming.Sep_Suffix_Loc);
1179 end Check_Ada_Naming_Scheme_Validity;
1181 -------------------------
1182 -- Check_Configuration --
1183 -------------------------
1185 procedure Check_Configuration
1186 (Project : Project_Id;
1187 In_Tree : Project_Tree_Ref;
1188 Data : in out Project_Data)
1190 Dot_Replacement : File_Name_Type := No_File;
1191 Casing : Casing_Type := All_Lower_Case;
1192 Separate_Suffix : File_Name_Type := No_File;
1194 Lang_Index : Language_Index := No_Language_Index;
1195 -- The index of the language data being checked
1197 Prev_Index : Language_Index := No_Language_Index;
1198 -- The index of the previous language
1200 Current_Language : Name_Id := No_Name;
1201 -- The name of the language
1203 Lang_Data : Language_Data;
1204 -- The data of the language being checked
1206 procedure Get_Language_Index_Of (Language : Name_Id);
1207 -- Get the language index of Language, if Language is one of the
1208 -- languages of the project.
1210 procedure Process_Project_Level_Simple_Attributes;
1211 -- Process the simple attributes at the project level
1213 procedure Process_Project_Level_Array_Attributes;
1214 -- Process the associate array attributes at the project level
1216 procedure Process_Packages;
1217 -- Read the packages of the project
1219 ---------------------------
1220 -- Get_Language_Index_Of --
1221 ---------------------------
1223 procedure Get_Language_Index_Of (Language : Name_Id) is
1224 Real_Language : Name_Id;
1227 Get_Name_String (Language);
1228 To_Lower (Name_Buffer (1 .. Name_Len));
1229 Real_Language := Name_Find;
1231 -- Nothing to do if the language is the same as the current language
1233 if Current_Language /= Real_Language then
1234 Lang_Index := Data.First_Language_Processing;
1235 while Lang_Index /= No_Language_Index loop
1236 exit when In_Tree.Languages_Data.Table (Lang_Index).Name =
1239 In_Tree.Languages_Data.Table (Lang_Index).Next;
1242 if Lang_Index = No_Language_Index then
1243 Current_Language := No_Name;
1245 Current_Language := Real_Language;
1248 end Get_Language_Index_Of;
1250 ----------------------
1251 -- Process_Packages --
1252 ----------------------
1254 procedure Process_Packages is
1255 Packages : Package_Id;
1256 Element : Package_Element;
1258 procedure Process_Binder (Arrays : Array_Id);
1259 -- Process the associate array attributes of package Binder
1261 procedure Process_Builder (Attributes : Variable_Id);
1262 -- Process the simple attributes of package Builder
1264 procedure Process_Compiler (Arrays : Array_Id);
1265 -- Process the associate array attributes of package Compiler
1267 procedure Process_Naming (Attributes : Variable_Id);
1268 -- Process the simple attributes of package Naming
1270 procedure Process_Naming (Arrays : Array_Id);
1271 -- Process the associate array attributes of package Naming
1273 procedure Process_Linker (Attributes : Variable_Id);
1274 -- Process the simple attributes of package Linker of a
1275 -- configuration project.
1277 --------------------
1278 -- Process_Binder --
1279 --------------------
1281 procedure Process_Binder (Arrays : Array_Id) is
1282 Current_Array_Id : Array_Id;
1283 Current_Array : Array_Data;
1284 Element_Id : Array_Element_Id;
1285 Element : Array_Element;
1288 -- Process the associative array attribute of package Binder
1290 Current_Array_Id := Arrays;
1291 while Current_Array_Id /= No_Array loop
1292 Current_Array := In_Tree.Arrays.Table (Current_Array_Id);
1294 Element_Id := Current_Array.Value;
1295 while Element_Id /= No_Array_Element loop
1296 Element := In_Tree.Array_Elements.Table (Element_Id);
1298 if Element.Index /= All_Other_Names then
1300 -- Get the name of the language
1302 Get_Language_Index_Of (Element.Index);
1304 if Lang_Index /= No_Language_Index then
1305 case Current_Array.Name is
1308 -- Attribute Driver (<language>)
1310 In_Tree.Languages_Data.Table
1311 (Lang_Index).Config.Binder_Driver :=
1312 File_Name_Type (Element.Value.Value);
1314 when Name_Required_Switches =>
1316 In_Tree.Languages_Data.Table
1317 (Lang_Index).Config.Binder_Required_Switches,
1318 From_List => Element.Value.Values,
1319 In_Tree => In_Tree);
1323 -- Attribute Prefix (<language>)
1325 In_Tree.Languages_Data.Table
1326 (Lang_Index).Config.Binder_Prefix :=
1327 Element.Value.Value;
1329 when Name_Objects_Path =>
1331 -- Attribute Objects_Path (<language>)
1333 In_Tree.Languages_Data.Table
1334 (Lang_Index).Config.Objects_Path :=
1335 Element.Value.Value;
1337 when Name_Objects_Path_File =>
1339 -- Attribute Objects_Path (<language>)
1341 In_Tree.Languages_Data.Table
1342 (Lang_Index).Config.Objects_Path_File :=
1343 Element.Value.Value;
1351 Element_Id := Element.Next;
1354 Current_Array_Id := Current_Array.Next;
1358 ---------------------
1359 -- Process_Builder --
1360 ---------------------
1362 procedure Process_Builder (Attributes : Variable_Id) is
1363 Attribute_Id : Variable_Id;
1364 Attribute : Variable;
1367 -- Process non associated array attribute from package Builder
1369 Attribute_Id := Attributes;
1370 while Attribute_Id /= No_Variable loop
1372 In_Tree.Variable_Elements.Table (Attribute_Id);
1374 if not Attribute.Value.Default then
1375 if Attribute.Name = Name_Executable_Suffix then
1377 -- Attribute Executable_Suffix: the suffix of the
1380 Data.Config.Executable_Suffix :=
1381 Attribute.Value.Value;
1385 Attribute_Id := Attribute.Next;
1387 end Process_Builder;
1389 ----------------------
1390 -- Process_Compiler --
1391 ----------------------
1393 procedure Process_Compiler (Arrays : Array_Id) is
1394 Current_Array_Id : Array_Id;
1395 Current_Array : Array_Data;
1396 Element_Id : Array_Element_Id;
1397 Element : Array_Element;
1398 List : String_List_Id;
1401 -- Process the associative array attribute of package Compiler
1403 Current_Array_Id := Arrays;
1404 while Current_Array_Id /= No_Array loop
1405 Current_Array := In_Tree.Arrays.Table (Current_Array_Id);
1407 Element_Id := Current_Array.Value;
1408 while Element_Id /= No_Array_Element loop
1409 Element := In_Tree.Array_Elements.Table (Element_Id);
1411 if Element.Index /= All_Other_Names then
1413 -- Get the name of the language
1415 Get_Language_Index_Of (Element.Index);
1417 if Lang_Index /= No_Language_Index then
1418 case Current_Array.Name is
1419 when Name_Dependency_Switches =>
1421 -- Attribute Dependency_Switches (<language>)
1423 if In_Tree.Languages_Data.Table
1424 (Lang_Index).Config.Dependency_Kind = None
1426 In_Tree.Languages_Data.Table
1427 (Lang_Index).Config.Dependency_Kind :=
1431 List := Element.Value.Values;
1433 if List /= Nil_String then
1435 In_Tree.Languages_Data.Table
1436 (Lang_Index).Config.Dependency_Option,
1438 In_Tree => In_Tree);
1441 when Name_Dependency_Driver =>
1443 -- Attribute Dependency_Driver (<language>)
1445 if In_Tree.Languages_Data.Table
1446 (Lang_Index).Config.Dependency_Kind = None
1448 In_Tree.Languages_Data.Table
1449 (Lang_Index).Config.Dependency_Kind :=
1453 List := Element.Value.Values;
1455 if List /= Nil_String then
1457 In_Tree.Languages_Data.Table
1458 (Lang_Index).Config.Compute_Dependency,
1460 In_Tree => In_Tree);
1463 when Name_Include_Switches =>
1465 -- Attribute Include_Switches (<language>)
1467 List := Element.Value.Values;
1469 if List = Nil_String then
1473 "include option cannot be null",
1474 Element.Value.Location);
1478 In_Tree.Languages_Data.Table
1479 (Lang_Index).Config.Include_Option,
1481 In_Tree => In_Tree);
1483 when Name_Include_Path =>
1485 -- Attribute Include_Path (<language>)
1487 In_Tree.Languages_Data.Table
1488 (Lang_Index).Config.Include_Path :=
1489 Element.Value.Value;
1491 when Name_Include_Path_File =>
1493 -- Attribute Include_Path_File (<language>)
1495 In_Tree.Languages_Data.Table
1496 (Lang_Index).Config.Include_Path_File :=
1497 Element.Value.Value;
1501 -- Attribute Driver (<language>)
1503 Get_Name_String (Element.Value.Value);
1505 In_Tree.Languages_Data.Table
1506 (Lang_Index).Config.Compiler_Driver :=
1507 File_Name_Type (Element.Value.Value);
1509 when Name_Required_Switches =>
1511 In_Tree.Languages_Data.Table
1512 (Lang_Index).Config.
1513 Compiler_Required_Switches,
1514 From_List => Element.Value.Values,
1515 In_Tree => In_Tree);
1517 when Name_Path_Syntax =>
1519 In_Tree.Languages_Data.Table
1520 (Lang_Index).Config.Path_Syntax :=
1521 Path_Syntax_Kind'Value
1522 (Get_Name_String (Element.Value.Value));
1525 when Constraint_Error =>
1529 "invalid value for Path_Syntax",
1530 Element.Value.Location);
1533 when Name_Pic_Option =>
1535 -- Attribute Compiler_Pic_Option (<language>)
1537 List := Element.Value.Values;
1539 if List = Nil_String then
1543 "compiler PIC option cannot be null",
1544 Element.Value.Location);
1548 In_Tree.Languages_Data.Table
1549 (Lang_Index).Config.Compilation_PIC_Option,
1551 In_Tree => In_Tree);
1553 when Name_Mapping_File_Switches =>
1555 -- Attribute Mapping_File_Switches (<language>)
1557 List := Element.Value.Values;
1559 if List = Nil_String then
1563 "mapping file switches cannot be null",
1564 Element.Value.Location);
1568 In_Tree.Languages_Data.Table
1569 (Lang_Index).Config.Mapping_File_Switches,
1571 In_Tree => In_Tree);
1573 when Name_Mapping_Spec_Suffix =>
1575 -- Attribute Mapping_Spec_Suffix (<language>)
1577 In_Tree.Languages_Data.Table
1578 (Lang_Index).Config.Mapping_Spec_Suffix :=
1579 File_Name_Type (Element.Value.Value);
1581 when Name_Mapping_Body_Suffix =>
1583 -- Attribute Mapping_Body_Suffix (<language>)
1585 In_Tree.Languages_Data.Table
1586 (Lang_Index).Config.Mapping_Body_Suffix :=
1587 File_Name_Type (Element.Value.Value);
1589 when Name_Config_File_Switches =>
1591 -- Attribute Config_File_Switches (<language>)
1593 List := Element.Value.Values;
1595 if List = Nil_String then
1599 "config file switches cannot be null",
1600 Element.Value.Location);
1604 In_Tree.Languages_Data.Table
1605 (Lang_Index).Config.Config_File_Switches,
1607 In_Tree => In_Tree);
1609 when Name_Objects_Path =>
1611 -- Attribute Objects_Path (<language>)
1613 In_Tree.Languages_Data.Table
1614 (Lang_Index).Config.Objects_Path :=
1615 Element.Value.Value;
1617 when Name_Objects_Path_File =>
1619 -- Attribute Objects_Path_File (<language>)
1621 In_Tree.Languages_Data.Table
1622 (Lang_Index).Config.Objects_Path_File :=
1623 Element.Value.Value;
1625 when Name_Config_Body_File_Name =>
1627 -- Attribute Config_Body_File_Name (<language>)
1629 In_Tree.Languages_Data.Table
1630 (Lang_Index).Config.Config_Body :=
1631 Element.Value.Value;
1633 when Name_Config_Body_File_Name_Pattern =>
1635 -- Attribute Config_Body_File_Name_Pattern
1638 In_Tree.Languages_Data.Table
1639 (Lang_Index).Config.Config_Body_Pattern :=
1640 Element.Value.Value;
1642 when Name_Config_Spec_File_Name =>
1644 -- Attribute Config_Spec_File_Name (<language>)
1646 In_Tree.Languages_Data.Table
1647 (Lang_Index).Config.Config_Spec :=
1648 Element.Value.Value;
1650 when Name_Config_Spec_File_Name_Pattern =>
1652 -- Attribute Config_Spec_File_Name_Pattern
1655 In_Tree.Languages_Data.Table
1656 (Lang_Index).Config.Config_Spec_Pattern :=
1657 Element.Value.Value;
1659 when Name_Config_File_Unique =>
1661 -- Attribute Config_File_Unique (<language>)
1664 In_Tree.Languages_Data.Table
1665 (Lang_Index).Config.Config_File_Unique :=
1667 (Get_Name_String (Element.Value.Value));
1669 when Constraint_Error =>
1673 "illegal value for Config_File_Unique",
1674 Element.Value.Location);
1683 Element_Id := Element.Next;
1686 Current_Array_Id := Current_Array.Next;
1688 end Process_Compiler;
1690 --------------------
1691 -- Process_Naming --
1692 --------------------
1694 procedure Process_Naming (Attributes : Variable_Id) is
1695 Attribute_Id : Variable_Id;
1696 Attribute : Variable;
1699 -- Process non associated array attribute from package Naming
1701 Attribute_Id := Attributes;
1702 while Attribute_Id /= No_Variable loop
1703 Attribute := In_Tree.Variable_Elements.Table (Attribute_Id);
1705 if not Attribute.Value.Default then
1706 if Attribute.Name = Name_Separate_Suffix then
1708 -- Attribute Separate_Suffix
1710 Separate_Suffix := File_Name_Type (Attribute.Value.Value);
1712 elsif Attribute.Name = Name_Casing then
1718 Value (Get_Name_String (Attribute.Value.Value));
1721 when Constraint_Error =>
1725 "invalid value for Casing",
1726 Attribute.Value.Location);
1729 elsif Attribute.Name = Name_Dot_Replacement then
1731 -- Attribute Dot_Replacement
1733 Dot_Replacement := File_Name_Type (Attribute.Value.Value);
1738 Attribute_Id := Attribute.Next;
1742 procedure Process_Naming (Arrays : Array_Id) is
1743 Current_Array_Id : Array_Id;
1744 Current_Array : Array_Data;
1745 Element_Id : Array_Element_Id;
1746 Element : Array_Element;
1748 -- Process the associative array attribute of package Naming
1750 Current_Array_Id := Arrays;
1751 while Current_Array_Id /= No_Array loop
1752 Current_Array := In_Tree.Arrays.Table (Current_Array_Id);
1754 Element_Id := Current_Array.Value;
1755 while Element_Id /= No_Array_Element loop
1756 Element := In_Tree.Array_Elements.Table (Element_Id);
1758 -- Get the name of the language
1760 Get_Language_Index_Of (Element.Index);
1762 if Lang_Index /= No_Language_Index then
1763 case Current_Array.Name is
1764 when Name_Specification_Suffix | Name_Spec_Suffix =>
1766 -- Attribute Spec_Suffix (<language>)
1768 In_Tree.Languages_Data.Table
1769 (Lang_Index).Config.Naming_Data.Spec_Suffix :=
1770 File_Name_Type (Element.Value.Value);
1772 when Name_Implementation_Suffix | Name_Body_Suffix =>
1774 -- Attribute Body_Suffix (<language>)
1776 In_Tree.Languages_Data.Table
1777 (Lang_Index).Config.Naming_Data.Body_Suffix :=
1778 File_Name_Type (Element.Value.Value);
1780 In_Tree.Languages_Data.Table
1781 (Lang_Index).Config.Naming_Data.Separate_Suffix :=
1782 File_Name_Type (Element.Value.Value);
1789 Element_Id := Element.Next;
1792 Current_Array_Id := Current_Array.Next;
1796 --------------------
1797 -- Process_Linker --
1798 --------------------
1800 procedure Process_Linker (Attributes : Variable_Id) is
1801 Attribute_Id : Variable_Id;
1802 Attribute : Variable;
1805 -- Process non associated array attribute from package Linker
1807 Attribute_Id := Attributes;
1808 while Attribute_Id /= No_Variable loop
1810 In_Tree.Variable_Elements.Table (Attribute_Id);
1812 if not Attribute.Value.Default then
1813 if Attribute.Name = Name_Driver then
1815 -- Attribute Linker'Driver: the default linker to use
1817 Data.Config.Linker :=
1818 Path_Name_Type (Attribute.Value.Value);
1820 elsif Attribute.Name = Name_Required_Switches then
1822 -- Attribute Required_Switches: the minimum
1823 -- options to use when invoking the linker
1826 Data.Config.Minimum_Linker_Options,
1827 From_List => Attribute.Value.Values,
1828 In_Tree => In_Tree);
1830 elsif Attribute.Name = Name_Map_File_Option then
1831 Data.Config.Map_File_Option := Attribute.Value.Value;
1835 Attribute_Id := Attribute.Next;
1839 -- Start of processing for Process_Packages
1842 Packages := Data.Decl.Packages;
1843 while Packages /= No_Package loop
1844 Element := In_Tree.Packages.Table (Packages);
1846 case Element.Name is
1849 -- Process attributes of package Binder
1851 Process_Binder (Element.Decl.Arrays);
1853 when Name_Builder =>
1855 -- Process attributes of package Builder
1857 Process_Builder (Element.Decl.Attributes);
1859 when Name_Compiler =>
1861 -- Process attributes of package Compiler
1863 Process_Compiler (Element.Decl.Arrays);
1867 -- Process attributes of package Linker
1869 Process_Linker (Element.Decl.Attributes);
1873 -- Process attributes of package Naming
1875 Process_Naming (Element.Decl.Attributes);
1876 Process_Naming (Element.Decl.Arrays);
1882 Packages := Element.Next;
1884 end Process_Packages;
1886 ---------------------------------------------
1887 -- Process_Project_Level_Simple_Attributes --
1888 ---------------------------------------------
1890 procedure Process_Project_Level_Simple_Attributes is
1891 Attribute_Id : Variable_Id;
1892 Attribute : Variable;
1893 List : String_List_Id;
1896 -- Process non associated array attribute at project level
1898 Attribute_Id := Data.Decl.Attributes;
1899 while Attribute_Id /= No_Variable loop
1901 In_Tree.Variable_Elements.Table (Attribute_Id);
1903 if not Attribute.Value.Default then
1904 if Attribute.Name = Name_Library_Builder then
1906 -- Attribute Library_Builder: the application to invoke
1907 -- to build libraries.
1909 Data.Config.Library_Builder :=
1910 Path_Name_Type (Attribute.Value.Value);
1912 elsif Attribute.Name = Name_Archive_Builder then
1914 -- Attribute Archive_Builder: the archive builder
1915 -- (usually "ar") and its minimum options (usually "cr").
1917 List := Attribute.Value.Values;
1919 if List = Nil_String then
1923 "archive builder cannot be null",
1924 Attribute.Value.Location);
1927 Put (Into_List => Data.Config.Archive_Builder,
1929 In_Tree => In_Tree);
1931 elsif Attribute.Name = Name_Archive_Builder_Append_Option then
1933 -- Attribute Archive_Builder: the archive builder
1934 -- (usually "ar") and its minimum options (usually "cr").
1936 List := Attribute.Value.Values;
1938 if List /= Nil_String then
1940 (Into_List => Data.Config.Archive_Builder_Append_Option,
1942 In_Tree => In_Tree);
1945 elsif Attribute.Name = Name_Archive_Indexer then
1947 -- Attribute Archive_Indexer: the optional archive
1948 -- indexer (usually "ranlib") with its minimum options
1951 List := Attribute.Value.Values;
1953 if List = Nil_String then
1957 "archive indexer cannot be null",
1958 Attribute.Value.Location);
1961 Put (Into_List => Data.Config.Archive_Indexer,
1963 In_Tree => In_Tree);
1965 elsif Attribute.Name = Name_Library_Partial_Linker then
1967 -- Attribute Library_Partial_Linker: the optional linker
1968 -- driver with its minimum options, to partially link
1971 List := Attribute.Value.Values;
1973 if List = Nil_String then
1977 "partial linker cannot be null",
1978 Attribute.Value.Location);
1981 Put (Into_List => Data.Config.Lib_Partial_Linker,
1983 In_Tree => In_Tree);
1985 elsif Attribute.Name = Name_Library_GCC then
1986 Data.Config.Shared_Lib_Driver :=
1987 File_Name_Type (Attribute.Value.Value);
1989 elsif Attribute.Name = Name_Archive_Suffix then
1990 Data.Config.Archive_Suffix :=
1991 File_Name_Type (Attribute.Value.Value);
1993 elsif Attribute.Name = Name_Linker_Executable_Option then
1995 -- Attribute Linker_Executable_Option: optional options
1996 -- to specify an executable name. Defaults to "-o".
1998 List := Attribute.Value.Values;
2000 if List = Nil_String then
2004 "linker executable option cannot be null",
2005 Attribute.Value.Location);
2008 Put (Into_List => Data.Config.Linker_Executable_Option,
2010 In_Tree => In_Tree);
2012 elsif Attribute.Name = Name_Linker_Lib_Dir_Option then
2014 -- Attribute Linker_Lib_Dir_Option: optional options
2015 -- to specify a library search directory. Defaults to
2018 Get_Name_String (Attribute.Value.Value);
2020 if Name_Len = 0 then
2024 "linker library directory option cannot be empty",
2025 Attribute.Value.Location);
2028 Data.Config.Linker_Lib_Dir_Option := Attribute.Value.Value;
2030 elsif Attribute.Name = Name_Linker_Lib_Name_Option then
2032 -- Attribute Linker_Lib_Name_Option: optional options
2033 -- to specify the name of a library to be linked in.
2034 -- Defaults to "-l".
2036 Get_Name_String (Attribute.Value.Value);
2038 if Name_Len = 0 then
2042 "linker library name option cannot be empty",
2043 Attribute.Value.Location);
2046 Data.Config.Linker_Lib_Name_Option := Attribute.Value.Value;
2048 elsif Attribute.Name = Name_Run_Path_Option then
2050 -- Attribute Run_Path_Option: optional options to
2051 -- specify a path for libraries.
2053 List := Attribute.Value.Values;
2055 if List /= Nil_String then
2056 Put (Into_List => Data.Config.Run_Path_Option,
2058 In_Tree => In_Tree);
2061 elsif Attribute.Name = Name_Library_Support then
2063 pragma Unsuppress (All_Checks);
2065 Data.Config.Lib_Support :=
2066 Library_Support'Value (Get_Name_String
2067 (Attribute.Value.Value));
2069 when Constraint_Error =>
2073 "invalid value """ &
2074 Get_Name_String (Attribute.Value.Value) &
2075 """ for Library_Support",
2076 Attribute.Value.Location);
2079 elsif Attribute.Name = Name_Shared_Library_Prefix then
2080 Data.Config.Shared_Lib_Prefix :=
2081 File_Name_Type (Attribute.Value.Value);
2083 elsif Attribute.Name = Name_Shared_Library_Suffix then
2084 Data.Config.Shared_Lib_Suffix :=
2085 File_Name_Type (Attribute.Value.Value);
2087 elsif Attribute.Name = Name_Symbolic_Link_Supported then
2089 pragma Unsuppress (All_Checks);
2091 Data.Config.Symbolic_Link_Supported :=
2092 Boolean'Value (Get_Name_String
2093 (Attribute.Value.Value));
2095 when Constraint_Error =>
2100 & Get_Name_String (Attribute.Value.Value)
2101 & """ for Symbolic_Link_Supported",
2102 Attribute.Value.Location);
2106 Attribute.Name = Name_Library_Major_Minor_Id_Supported
2109 pragma Unsuppress (All_Checks);
2111 Data.Config.Lib_Maj_Min_Id_Supported :=
2112 Boolean'Value (Get_Name_String
2113 (Attribute.Value.Value));
2115 when Constraint_Error =>
2119 "invalid value """ &
2120 Get_Name_String (Attribute.Value.Value) &
2121 """ for Library_Major_Minor_Id_Supported",
2122 Attribute.Value.Location);
2125 elsif Attribute.Name = Name_Library_Auto_Init_Supported then
2127 pragma Unsuppress (All_Checks);
2129 Data.Config.Auto_Init_Supported :=
2130 Boolean'Value (Get_Name_String (Attribute.Value.Value));
2132 when Constraint_Error =>
2137 & Get_Name_String (Attribute.Value.Value)
2138 & """ for Library_Auto_Init_Supported",
2139 Attribute.Value.Location);
2142 elsif Attribute.Name = Name_Shared_Library_Minimum_Switches then
2143 List := Attribute.Value.Values;
2145 if List /= Nil_String then
2146 Put (Into_List => Data.Config.Shared_Lib_Min_Options,
2148 In_Tree => In_Tree);
2151 elsif Attribute.Name = Name_Library_Version_Switches then
2152 List := Attribute.Value.Values;
2154 if List /= Nil_String then
2155 Put (Into_List => Data.Config.Lib_Version_Options,
2157 In_Tree => In_Tree);
2162 Attribute_Id := Attribute.Next;
2164 end Process_Project_Level_Simple_Attributes;
2166 --------------------------------------------
2167 -- Process_Project_Level_Array_Attributes --
2168 --------------------------------------------
2170 procedure Process_Project_Level_Array_Attributes is
2171 Current_Array_Id : Array_Id;
2172 Current_Array : Array_Data;
2173 Element_Id : Array_Element_Id;
2174 Element : Array_Element;
2175 List : String_List_Id;
2178 -- Process the associative array attributes at project level
2180 Current_Array_Id := Data.Decl.Arrays;
2181 while Current_Array_Id /= No_Array loop
2182 Current_Array := In_Tree.Arrays.Table (Current_Array_Id);
2184 Element_Id := Current_Array.Value;
2185 while Element_Id /= No_Array_Element loop
2186 Element := In_Tree.Array_Elements.Table (Element_Id);
2188 -- Get the name of the language
2190 Get_Language_Index_Of (Element.Index);
2192 if Lang_Index /= No_Language_Index then
2193 case Current_Array.Name is
2194 when Name_Inherit_Source_Path =>
2195 List := Element.Value.Values;
2197 if List /= Nil_String then
2200 In_Tree.Languages_Data.Table (Lang_Index).
2201 Config.Include_Compatible_Languages,
2204 Lower_Case => True);
2207 when Name_Toolchain_Description =>
2209 -- Attribute Toolchain_Description (<language>)
2211 In_Tree.Languages_Data.Table
2212 (Lang_Index).Config.Toolchain_Description :=
2213 Element.Value.Value;
2215 when Name_Toolchain_Version =>
2217 -- Attribute Toolchain_Version (<language>)
2219 In_Tree.Languages_Data.Table
2220 (Lang_Index).Config.Toolchain_Version :=
2221 Element.Value.Value;
2223 when Name_Runtime_Library_Dir =>
2225 -- Attribute Runtime_Library_Dir (<language>)
2227 In_Tree.Languages_Data.Table
2228 (Lang_Index).Config.Runtime_Library_Dir :=
2229 Element.Value.Value;
2231 when Name_Object_Generated =>
2233 pragma Unsuppress (All_Checks);
2239 (Get_Name_String (Element.Value.Value));
2241 In_Tree.Languages_Data.Table
2242 (Lang_Index).Config.Object_Generated := Value;
2244 -- If no object is generated, no object may be
2248 In_Tree.Languages_Data.Table
2249 (Lang_Index).Config.Objects_Linked := False;
2253 when Constraint_Error =>
2258 & Get_Name_String (Element.Value.Value)
2259 & """ for Object_Generated",
2260 Element.Value.Location);
2263 when Name_Objects_Linked =>
2265 pragma Unsuppress (All_Checks);
2271 (Get_Name_String (Element.Value.Value));
2273 -- No change if Object_Generated is False, as this
2274 -- forces Objects_Linked to be False too.
2276 if In_Tree.Languages_Data.Table
2277 (Lang_Index).Config.Object_Generated
2279 In_Tree.Languages_Data.Table
2280 (Lang_Index).Config.Objects_Linked :=
2285 when Constraint_Error =>
2290 & Get_Name_String (Element.Value.Value)
2291 & """ for Objects_Linked",
2292 Element.Value.Location);
2299 Element_Id := Element.Next;
2302 Current_Array_Id := Current_Array.Next;
2304 end Process_Project_Level_Array_Attributes;
2307 Process_Project_Level_Simple_Attributes;
2308 Process_Project_Level_Array_Attributes;
2311 -- For unit based languages, set Casing, Dot_Replacement and
2312 -- Separate_Suffix in Naming_Data.
2314 Lang_Index := Data.First_Language_Processing;
2315 while Lang_Index /= No_Language_Index loop
2316 if In_Tree.Languages_Data.Table
2317 (Lang_Index).Name = Name_Ada
2319 In_Tree.Languages_Data.Table
2320 (Lang_Index).Config.Naming_Data.Casing := Casing;
2321 In_Tree.Languages_Data.Table
2322 (Lang_Index).Config.Naming_Data.Dot_Replacement :=
2325 if Separate_Suffix /= No_File then
2326 In_Tree.Languages_Data.Table
2327 (Lang_Index).Config.Naming_Data.Separate_Suffix :=
2334 Lang_Index := In_Tree.Languages_Data.Table (Lang_Index).Next;
2337 -- Give empty names to various prefixes/suffixes, if they have not
2338 -- been specified in the configuration.
2340 if Data.Config.Archive_Suffix = No_File then
2341 Data.Config.Archive_Suffix := Empty_File;
2344 if Data.Config.Shared_Lib_Prefix = No_File then
2345 Data.Config.Shared_Lib_Prefix := Empty_File;
2348 if Data.Config.Shared_Lib_Suffix = No_File then
2349 Data.Config.Shared_Lib_Suffix := Empty_File;
2352 Lang_Index := Data.First_Language_Processing;
2353 while Lang_Index /= No_Language_Index loop
2354 Lang_Data := In_Tree.Languages_Data.Table (Lang_Index);
2356 Current_Language := Lang_Data.Display_Name;
2358 -- For all languages, Compiler_Driver needs to be specified
2360 if Lang_Data.Config.Compiler_Driver = No_File then
2361 Error_Msg_Name_1 := Current_Language;
2365 "?no compiler specified for language %%" &
2366 ", ignoring all its sources",
2369 if Lang_Index = Data.First_Language_Processing then
2370 Data.First_Language_Processing :=
2373 In_Tree.Languages_Data.Table (Prev_Index).Next :=
2377 elsif Lang_Data.Name = Name_Ada then
2378 Prev_Index := Lang_Index;
2380 -- For unit based languages, Dot_Replacement, Spec_Suffix and
2381 -- Body_Suffix need to be specified.
2383 if Lang_Data.Config.Naming_Data.Dot_Replacement = No_File then
2387 "Dot_Replacement not specified for Ada",
2391 if Lang_Data.Config.Naming_Data.Spec_Suffix = No_File then
2395 "Spec_Suffix not specified for Ada",
2399 if Lang_Data.Config.Naming_Data.Body_Suffix = No_File then
2403 "Body_Suffix not specified for Ada",
2408 Prev_Index := Lang_Index;
2410 -- For file based languages, either Spec_Suffix or Body_Suffix
2411 -- need to be specified.
2413 if Lang_Data.Config.Naming_Data.Spec_Suffix = No_File and then
2414 Lang_Data.Config.Naming_Data.Body_Suffix = No_File
2416 Error_Msg_Name_1 := Current_Language;
2420 "no suffixes specified for %%",
2425 Lang_Index := Lang_Data.Next;
2427 end Check_Configuration;
2429 -------------------------------
2430 -- Check_If_Externally_Built --
2431 -------------------------------
2433 procedure Check_If_Externally_Built
2434 (Project : Project_Id;
2435 In_Tree : Project_Tree_Ref;
2436 Data : in out Project_Data)
2438 Externally_Built : constant Variable_Value :=
2440 (Name_Externally_Built,
2441 Data.Decl.Attributes, In_Tree);
2444 if not Externally_Built.Default then
2445 Get_Name_String (Externally_Built.Value);
2446 To_Lower (Name_Buffer (1 .. Name_Len));
2448 if Name_Buffer (1 .. Name_Len) = "true" then
2449 Data.Externally_Built := True;
2451 elsif Name_Buffer (1 .. Name_Len) /= "false" then
2452 Error_Msg (Project, In_Tree,
2453 "Externally_Built may only be true or false",
2454 Externally_Built.Location);
2458 -- A virtual project extending an externally built project is itself
2459 -- externally built.
2461 if Data.Virtual and then Data.Extends /= No_Project then
2462 Data.Externally_Built :=
2463 In_Tree.Projects.Table (Data.Extends).Externally_Built;
2466 if Current_Verbosity = High then
2467 Write_Str ("Project is ");
2469 if not Data.Externally_Built then
2473 Write_Line ("externally built.");
2475 end Check_If_Externally_Built;
2477 ----------------------
2478 -- Check_Interfaces --
2479 ----------------------
2481 procedure Check_Interfaces
2482 (Project : Project_Id;
2483 In_Tree : Project_Tree_Ref;
2484 Data : in out Project_Data)
2486 Interfaces : constant Prj.Variable_Value :=
2488 (Snames.Name_Interfaces,
2489 Data.Decl.Attributes,
2492 List : String_List_Id;
2493 Element : String_Element;
2494 Name : File_Name_Type;
2497 Src_Data : Source_Data;
2499 Project_2 : Project_Id;
2500 Data_2 : Project_Data;
2503 if not Interfaces.Default then
2505 -- Set In_Interfaces to False for all sources. It will be set to True
2506 -- later for the sources in the Interfaces list.
2508 Project_2 := Project;
2511 Source := Data_2.First_Source;
2512 while Source /= No_Source loop
2513 Src_Data := In_Tree.Sources.Table (Source);
2514 Src_Data.In_Interfaces := False;
2515 In_Tree.Sources.Table (Source) := Src_Data;
2516 Source := Src_Data.Next_In_Project;
2519 Project_2 := Data_2.Extends;
2521 exit when Project_2 = No_Project;
2523 Data_2 := In_Tree.Projects.Table (Project_2);
2526 List := Interfaces.Values;
2527 while List /= Nil_String loop
2528 Element := In_Tree.String_Elements.Table (List);
2529 Get_Name_String (Element.Value);
2530 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
2533 Project_2 := Project;
2537 Source := Data_2.First_Source;
2538 while Source /= No_Source loop
2539 Src_Data := In_Tree.Sources.Table (Source);
2540 if Src_Data.File = Name then
2541 if not Src_Data.Locally_Removed then
2542 In_Tree.Sources.Table (Source).In_Interfaces := True;
2543 In_Tree.Sources.Table
2544 (Source).Declared_In_Interfaces := True;
2546 if Src_Data.Other_Part /= No_Source then
2547 In_Tree.Sources.Table
2548 (Src_Data.Other_Part).In_Interfaces := True;
2549 In_Tree.Sources.Table
2550 (Src_Data.Other_Part).Declared_In_Interfaces :=
2554 if Current_Verbosity = High then
2555 Write_Str (" interface: ");
2556 Write_Line (Get_Name_String (Src_Data.Path.Name));
2563 Source := Src_Data.Next_In_Project;
2566 Project_2 := Data_2.Extends;
2568 exit Big_Loop when Project_2 = No_Project;
2570 Data_2 := In_Tree.Projects.Table (Project_2);
2573 if Source = No_Source then
2574 Error_Msg_File_1 := File_Name_Type (Element.Value);
2575 Error_Msg_Name_1 := Data.Name;
2580 "{ cannot be an interface of project %% " &
2581 "as it is not one of its sources",
2585 List := Element.Next;
2588 Data.Interfaces_Defined := True;
2590 elsif Data.Extends /= No_Project then
2591 Data.Interfaces_Defined :=
2592 In_Tree.Projects.Table (Data.Extends).Interfaces_Defined;
2594 if Data.Interfaces_Defined then
2595 Source := Data.First_Source;
2596 while Source /= No_Source loop
2597 Src_Data := In_Tree.Sources.Table (Source);
2599 if not Src_Data.Declared_In_Interfaces then
2600 Src_Data.In_Interfaces := False;
2601 In_Tree.Sources.Table (Source) := Src_Data;
2604 Source := Src_Data.Next_In_Project;
2608 end Check_Interfaces;
2610 --------------------------
2611 -- Check_Naming_Schemes --
2612 --------------------------
2614 procedure Check_Naming_Schemes
2615 (Data : in out Project_Data;
2616 Project : Project_Id;
2617 In_Tree : Project_Tree_Ref)
2619 Naming_Id : constant Package_Id :=
2620 Util.Value_Of (Name_Naming, Data.Decl.Packages, In_Tree);
2621 Naming : Package_Element;
2623 procedure Check_Unit_Names (List : Array_Element_Id);
2624 -- Check that a list of unit names contains only valid names
2626 procedure Get_Exceptions (Kind : Source_Kind);
2628 procedure Get_Unit_Exceptions (Kind : Source_Kind);
2630 ----------------------
2631 -- Check_Unit_Names --
2632 ----------------------
2634 procedure Check_Unit_Names (List : Array_Element_Id) is
2635 Current : Array_Element_Id;
2636 Element : Array_Element;
2637 Unit_Name : Name_Id;
2640 -- Loop through elements of the string list
2643 while Current /= No_Array_Element loop
2644 Element := In_Tree.Array_Elements.Table (Current);
2646 -- Put file name in canonical case
2648 if not Osint.File_Names_Case_Sensitive then
2649 Get_Name_String (Element.Value.Value);
2650 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
2651 Element.Value.Value := Name_Find;
2654 -- Check that it contains a valid unit name
2656 Get_Name_String (Element.Index);
2657 Check_Ada_Name (Name_Buffer (1 .. Name_Len), Unit_Name);
2659 if Unit_Name = No_Name then
2660 Err_Vars.Error_Msg_Name_1 := Element.Index;
2663 "%% is not a valid unit name.",
2664 Element.Value.Location);
2667 if Current_Verbosity = High then
2668 Write_Str (" Unit (""");
2669 Write_Str (Get_Name_String (Unit_Name));
2673 Element.Index := Unit_Name;
2674 In_Tree.Array_Elements.Table (Current) := Element;
2677 Current := Element.Next;
2679 end Check_Unit_Names;
2681 --------------------
2682 -- Get_Exceptions --
2683 --------------------
2685 procedure Get_Exceptions (Kind : Source_Kind) is
2686 Exceptions : Array_Element_Id;
2687 Exception_List : Variable_Value;
2688 Element_Id : String_List_Id;
2689 Element : String_Element;
2690 File_Name : File_Name_Type;
2691 Lang_Id : Language_Index;
2693 Lang_Kind : Language_Kind;
2700 (Name_Implementation_Exceptions,
2701 In_Arrays => Naming.Decl.Arrays,
2702 In_Tree => In_Tree);
2707 (Name_Specification_Exceptions,
2708 In_Arrays => Naming.Decl.Arrays,
2709 In_Tree => In_Tree);
2712 Lang_Id := Data.First_Language_Processing;
2713 while Lang_Id /= No_Language_Index loop
2714 if In_Tree.Languages_Data.Table (Lang_Id).Config.Kind =
2717 Lang := In_Tree.Languages_Data.Table (Lang_Id).Name;
2719 In_Tree.Languages_Data.Table (Lang_Id).Config.Kind;
2721 Exception_List := Value_Of
2723 In_Array => Exceptions,
2724 In_Tree => In_Tree);
2726 if Exception_List /= Nil_Variable_Value then
2727 Element_Id := Exception_List.Values;
2728 while Element_Id /= Nil_String loop
2729 Element := In_Tree.String_Elements.Table (Element_Id);
2731 if Osint.File_Names_Case_Sensitive then
2732 File_Name := File_Name_Type (Element.Value);
2734 Get_Name_String (Element.Value);
2735 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
2736 File_Name := Name_Find;
2739 Source := Data.First_Source;
2740 while Source /= No_Source
2742 In_Tree.Sources.Table (Source).File /= File_Name
2745 In_Tree.Sources.Table (Source).Next_In_Project;
2748 if Source = No_Source then
2757 File_Name => File_Name,
2758 Display_File => File_Name_Type (Element.Value),
2759 Naming_Exception => True,
2760 Lang_Kind => Lang_Kind);
2763 -- Check if the file name is already recorded for
2764 -- another language or another kind.
2767 In_Tree.Sources.Table (Source).Language /= Lang_Id
2772 "the same file cannot be a source " &
2776 elsif In_Tree.Sources.Table (Source).Kind /= Kind then
2780 "the same file cannot be a source " &
2785 -- If the file is already recorded for the same
2786 -- language and the same kind, it means that the file
2787 -- name appears several times in the *_Exceptions
2788 -- attribute; so there is nothing to do.
2792 Element_Id := Element.Next;
2797 Lang_Id := In_Tree.Languages_Data.Table (Lang_Id).Next;
2801 -------------------------
2802 -- Get_Unit_Exceptions --
2803 -------------------------
2805 procedure Get_Unit_Exceptions (Kind : Source_Kind) is
2806 Exceptions : Array_Element_Id;
2807 Element : Array_Element;
2810 File_Name : File_Name_Type;
2811 Lang_Id : constant Language_Index :=
2812 Data.Unit_Based_Language_Index;
2813 Lang : constant Name_Id :=
2814 Data.Unit_Based_Language_Name;
2817 Source_To_Replace : Source_Id := No_Source;
2819 Other_Project : Project_Id;
2820 Other_Part : Source_Id := No_Source;
2823 if Lang_Id = No_Language_Index or else Lang = No_Name then
2828 Exceptions := Value_Of
2830 In_Arrays => Naming.Decl.Arrays,
2831 In_Tree => In_Tree);
2833 if Exceptions = No_Array_Element then
2836 (Name_Implementation,
2837 In_Arrays => Naming.Decl.Arrays,
2838 In_Tree => In_Tree);
2845 In_Arrays => Naming.Decl.Arrays,
2846 In_Tree => In_Tree);
2848 if Exceptions = No_Array_Element then
2849 Exceptions := Value_Of
2850 (Name_Specification,
2851 In_Arrays => Naming.Decl.Arrays,
2852 In_Tree => In_Tree);
2857 while Exceptions /= No_Array_Element loop
2858 Element := In_Tree.Array_Elements.Table (Exceptions);
2860 if Osint.File_Names_Case_Sensitive then
2861 File_Name := File_Name_Type (Element.Value.Value);
2863 Get_Name_String (Element.Value.Value);
2864 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
2865 File_Name := Name_Find;
2868 Get_Name_String (Element.Index);
2869 To_Lower (Name_Buffer (1 .. Name_Len));
2872 Index := Element.Value.Index;
2874 -- For Ada, check if it is a valid unit name
2876 if Lang = Name_Ada then
2877 Get_Name_String (Element.Index);
2878 Check_Ada_Name (Name_Buffer (1 .. Name_Len), Unit);
2880 if Unit = No_Name then
2881 Err_Vars.Error_Msg_Name_1 := Element.Index;
2884 "%% is not a valid unit name.",
2885 Element.Value.Location);
2889 if Unit /= No_Name then
2891 -- Check if the source already exists
2893 Source := In_Tree.First_Source;
2894 Source_To_Replace := No_Source;
2896 while Source /= No_Source and then
2897 (In_Tree.Sources.Table (Source).Unit /= Unit or else
2898 In_Tree.Sources.Table (Source).Index /= Index)
2900 Source := In_Tree.Sources.Table (Source).Next_In_Sources;
2903 if Source /= No_Source then
2904 if In_Tree.Sources.Table (Source).Kind /= Kind then
2905 Other_Part := Source;
2909 In_Tree.Sources.Table (Source).Next_In_Sources;
2911 exit when Source = No_Source or else
2912 (In_Tree.Sources.Table (Source).Unit = Unit
2914 In_Tree.Sources.Table (Source).Index = Index);
2918 if Source /= No_Source then
2919 Other_Project := In_Tree.Sources.Table (Source).Project;
2921 if Is_Extending (Project, Other_Project, In_Tree) then
2923 In_Tree.Sources.Table (Source).Other_Part;
2925 -- Record the source to be removed
2927 Source_To_Replace := Source;
2928 Source := No_Source;
2931 Error_Msg_Name_1 := Unit;
2933 In_Tree.Projects.Table (Other_Project).Name;
2937 "%% is already a source of project %%",
2938 Element.Value.Location);
2943 if Source = No_Source then
2952 File_Name => File_Name,
2953 Display_File => File_Name_Type (Element.Value.Value),
2954 Lang_Kind => Unit_Based,
2955 Other_Part => Other_Part,
2958 Naming_Exception => True,
2959 Source_To_Replace => Source_To_Replace);
2963 Exceptions := Element.Next;
2966 end Get_Unit_Exceptions;
2968 -- Start of processing for Check_Naming_Schemes
2971 if Get_Mode = Ada_Only then
2973 -- If there is a package Naming, we will put in Data.Naming what is
2974 -- in this package Naming.
2976 if Naming_Id /= No_Package then
2977 Naming := In_Tree.Packages.Table (Naming_Id);
2979 if Current_Verbosity = High then
2980 Write_Line ("Checking ""Naming"" for Ada.");
2984 Bodies : constant Array_Element_Id :=
2986 (Name_Body, Naming.Decl.Arrays, In_Tree);
2988 Specs : constant Array_Element_Id :=
2990 (Name_Spec, Naming.Decl.Arrays, In_Tree);
2993 if Bodies /= No_Array_Element then
2995 -- We have elements in the array Body_Part
2997 if Current_Verbosity = High then
2998 Write_Line ("Found Bodies.");
3001 Data.Naming.Bodies := Bodies;
3002 Check_Unit_Names (Bodies);
3005 if Current_Verbosity = High then
3006 Write_Line ("No Bodies.");
3010 if Specs /= No_Array_Element then
3012 -- We have elements in the array Specs
3014 if Current_Verbosity = High then
3015 Write_Line ("Found Specs.");
3018 Data.Naming.Specs := Specs;
3019 Check_Unit_Names (Specs);
3022 if Current_Verbosity = High then
3023 Write_Line ("No Specs.");
3028 -- We are now checking if variables Dot_Replacement, Casing,
3029 -- Spec_Suffix, Body_Suffix and/or Separate_Suffix exist.
3031 -- For each variable, if it does not exist, we do nothing,
3032 -- because we already have the default.
3034 -- Check Dot_Replacement
3037 Dot_Replacement : constant Variable_Value :=
3039 (Name_Dot_Replacement,
3040 Naming.Decl.Attributes, In_Tree);
3043 pragma Assert (Dot_Replacement.Kind = Single,
3044 "Dot_Replacement is not a single string");
3046 if not Dot_Replacement.Default then
3047 Get_Name_String (Dot_Replacement.Value);
3049 if Name_Len = 0 then
3052 "Dot_Replacement cannot be empty",
3053 Dot_Replacement.Location);
3056 if Osint.File_Names_Case_Sensitive then
3057 Data.Naming.Dot_Replacement :=
3058 File_Name_Type (Dot_Replacement.Value);
3060 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3061 Data.Naming.Dot_Replacement := Name_Find;
3063 Data.Naming.Dot_Repl_Loc := Dot_Replacement.Location;
3068 if Current_Verbosity = High then
3069 Write_Str (" Dot_Replacement = """);
3070 Write_Str (Get_Name_String (Data.Naming.Dot_Replacement));
3078 Casing_String : constant Variable_Value :=
3081 Naming.Decl.Attributes,
3085 pragma Assert (Casing_String.Kind = Single,
3086 "Casing is not a single string");
3088 if not Casing_String.Default then
3090 Casing_Image : constant String :=
3091 Get_Name_String (Casing_String.Value);
3094 Casing_Value : constant Casing_Type :=
3095 Value (Casing_Image);
3097 Data.Naming.Casing := Casing_Value;
3101 when Constraint_Error =>
3102 if Casing_Image'Length = 0 then
3105 "Casing cannot be an empty string",
3106 Casing_String.Location);
3109 Name_Len := Casing_Image'Length;
3110 Name_Buffer (1 .. Name_Len) := Casing_Image;
3111 Err_Vars.Error_Msg_Name_1 := Name_Find;
3114 "%% is not a correct Casing",
3115 Casing_String.Location);
3121 if Current_Verbosity = High then
3122 Write_Str (" Casing = ");
3123 Write_Str (Image (Data.Naming.Casing));
3128 -- Check Spec_Suffix
3131 Ada_Spec_Suffix : constant Variable_Value :=
3135 In_Array => Data.Naming.Spec_Suffix,
3136 In_Tree => In_Tree);
3139 if Ada_Spec_Suffix.Kind = Single
3140 and then Get_Name_String (Ada_Spec_Suffix.Value) /= ""
3142 Get_Name_String (Ada_Spec_Suffix.Value);
3143 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3144 Set_Spec_Suffix (In_Tree, "ada", Data.Naming, Name_Find);
3145 Data.Naming.Ada_Spec_Suffix_Loc := Ada_Spec_Suffix.Location;
3152 Default_Ada_Spec_Suffix);
3156 if Current_Verbosity = High then
3157 Write_Str (" Spec_Suffix = """);
3158 Write_Str (Spec_Suffix_Of (In_Tree, "ada", Data.Naming));
3163 -- Check Body_Suffix
3166 Ada_Body_Suffix : constant Variable_Value :=
3170 In_Array => Data.Naming.Body_Suffix,
3171 In_Tree => In_Tree);
3174 if Ada_Body_Suffix.Kind = Single
3175 and then Get_Name_String (Ada_Body_Suffix.Value) /= ""
3177 Get_Name_String (Ada_Body_Suffix.Value);
3178 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3179 Set_Body_Suffix (In_Tree, "ada", Data.Naming, Name_Find);
3180 Data.Naming.Ada_Body_Suffix_Loc := Ada_Body_Suffix.Location;
3187 Default_Ada_Body_Suffix);
3191 if Current_Verbosity = High then
3192 Write_Str (" Body_Suffix = """);
3193 Write_Str (Body_Suffix_Of (In_Tree, "ada", Data.Naming));
3198 -- Check Separate_Suffix
3201 Ada_Sep_Suffix : constant Variable_Value :=
3203 (Variable_Name => Name_Separate_Suffix,
3204 In_Variables => Naming.Decl.Attributes,
3205 In_Tree => In_Tree);
3208 if Ada_Sep_Suffix.Default then
3209 Data.Naming.Separate_Suffix :=
3210 Body_Suffix_Id_Of (In_Tree, Name_Ada, Data.Naming);
3213 Get_Name_String (Ada_Sep_Suffix.Value);
3215 if Name_Len = 0 then
3218 "Separate_Suffix cannot be empty",
3219 Ada_Sep_Suffix.Location);
3222 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3223 Data.Naming.Separate_Suffix := Name_Find;
3224 Data.Naming.Sep_Suffix_Loc := Ada_Sep_Suffix.Location;
3229 if Current_Verbosity = High then
3230 Write_Str (" Separate_Suffix = """);
3231 Write_Str (Get_Name_String (Data.Naming.Separate_Suffix));
3236 -- Check if Data.Naming is valid
3238 Check_Ada_Naming_Scheme_Validity (Project, In_Tree, Data.Naming);
3241 elsif not In_Configuration then
3243 -- Look into package Naming, if there is one
3245 if Naming_Id /= No_Package then
3246 Naming := In_Tree.Packages.Table (Naming_Id);
3248 if Current_Verbosity = High then
3249 Write_Line ("Checking package Naming.");
3252 -- We are now checking if attribute Dot_Replacement, Casing,
3253 -- and/or Separate_Suffix exist.
3255 -- For each attribute, if it does not exist, we do nothing,
3256 -- because we already have the default.
3257 -- Otherwise, for all unit-based languages, we put the declared
3258 -- value in the language config.
3261 Dot_Repl : constant Variable_Value :=
3263 (Name_Dot_Replacement,
3264 Naming.Decl.Attributes, In_Tree);
3265 Dot_Replacement : File_Name_Type := No_File;
3267 Casing_String : constant Variable_Value :=
3270 Naming.Decl.Attributes,
3272 Casing : Casing_Type;
3273 Casing_Defined : Boolean := False;
3275 Sep_Suffix : constant Variable_Value :=
3277 (Variable_Name => Name_Separate_Suffix,
3278 In_Variables => Naming.Decl.Attributes,
3279 In_Tree => In_Tree);
3280 Separate_Suffix : File_Name_Type := No_File;
3282 Lang_Id : Language_Index;
3284 -- Check attribute Dot_Replacement
3286 if not Dot_Repl.Default then
3287 Get_Name_String (Dot_Repl.Value);
3289 if Name_Len = 0 then
3292 "Dot_Replacement cannot be empty",
3296 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3297 Dot_Replacement := Name_Find;
3299 if Current_Verbosity = High then
3300 Write_Str (" Dot_Replacement = """);
3301 Write_Str (Get_Name_String (Dot_Replacement));
3308 -- Check attribute Casing
3310 if not Casing_String.Default then
3312 Casing_Image : constant String :=
3313 Get_Name_String (Casing_String.Value);
3316 Casing_Value : constant Casing_Type :=
3317 Value (Casing_Image);
3319 Casing := Casing_Value;
3320 Casing_Defined := True;
3322 if Current_Verbosity = High then
3323 Write_Str (" Casing = ");
3324 Write_Str (Image (Casing));
3331 when Constraint_Error =>
3332 if Casing_Image'Length = 0 then
3335 "Casing cannot be an empty string",
3336 Casing_String.Location);
3339 Name_Len := Casing_Image'Length;
3340 Name_Buffer (1 .. Name_Len) := Casing_Image;
3341 Err_Vars.Error_Msg_Name_1 := Name_Find;
3344 "%% is not a correct Casing",
3345 Casing_String.Location);
3350 if not Sep_Suffix.Default then
3351 Get_Name_String (Sep_Suffix.Value);
3353 if Name_Len = 0 then
3356 "Separate_Suffix cannot be empty",
3357 Sep_Suffix.Location);
3360 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3361 Separate_Suffix := Name_Find;
3363 if Current_Verbosity = High then
3364 Write_Str (" Separate_Suffix = """);
3365 Write_Str (Get_Name_String (Separate_Suffix));
3372 -- For all unit based languages, if any, set the specified
3373 -- value of Dot_Replacement, Casing and/or Separate_Suffix.
3375 if Dot_Replacement /= No_File
3376 or else Casing_Defined
3377 or else Separate_Suffix /= No_File
3379 Lang_Id := Data.First_Language_Processing;
3380 while Lang_Id /= No_Language_Index loop
3381 if In_Tree.Languages_Data.Table
3382 (Lang_Id).Config.Kind = Unit_Based
3384 if Dot_Replacement /= No_File then
3385 In_Tree.Languages_Data.Table
3386 (Lang_Id).Config.Naming_Data.Dot_Replacement :=
3390 if Casing_Defined then
3391 In_Tree.Languages_Data.Table
3392 (Lang_Id).Config.Naming_Data.Casing := Casing;
3395 if Separate_Suffix /= No_File then
3396 In_Tree.Languages_Data.Table
3397 (Lang_Id).Config.Naming_Data.Separate_Suffix :=
3403 In_Tree.Languages_Data.Table (Lang_Id).Next;
3408 -- Next, get the spec and body suffixes
3411 Suffix : Variable_Value;
3412 Lang_Id : Language_Index;
3416 Lang_Id := Data.First_Language_Processing;
3417 while Lang_Id /= No_Language_Index loop
3418 Lang := In_Tree.Languages_Data.Table (Lang_Id).Name;
3424 Attribute_Or_Array_Name => Name_Spec_Suffix,
3425 In_Package => Naming_Id,
3426 In_Tree => In_Tree);
3428 if Suffix = Nil_Variable_Value then
3431 Attribute_Or_Array_Name => Name_Specification_Suffix,
3432 In_Package => Naming_Id,
3433 In_Tree => In_Tree);
3436 if Suffix /= Nil_Variable_Value then
3437 In_Tree.Languages_Data.Table (Lang_Id).
3438 Config.Naming_Data.Spec_Suffix :=
3439 File_Name_Type (Suffix.Value);
3446 Attribute_Or_Array_Name => Name_Body_Suffix,
3447 In_Package => Naming_Id,
3448 In_Tree => In_Tree);
3450 if Suffix = Nil_Variable_Value then
3453 Attribute_Or_Array_Name => Name_Implementation_Suffix,
3454 In_Package => Naming_Id,
3455 In_Tree => In_Tree);
3458 if Suffix /= Nil_Variable_Value then
3459 In_Tree.Languages_Data.Table (Lang_Id).
3460 Config.Naming_Data.Body_Suffix :=
3461 File_Name_Type (Suffix.Value);
3464 Lang_Id := In_Tree.Languages_Data.Table (Lang_Id).Next;
3468 -- Get the exceptions for file based languages
3470 Get_Exceptions (Spec);
3471 Get_Exceptions (Impl);
3473 -- Get the exceptions for unit based languages
3475 Get_Unit_Exceptions (Spec);
3476 Get_Unit_Exceptions (Impl);
3480 end Check_Naming_Schemes;
3482 ------------------------------
3483 -- Check_Library_Attributes --
3484 ------------------------------
3486 procedure Check_Library_Attributes
3487 (Project : Project_Id;
3488 In_Tree : Project_Tree_Ref;
3489 Current_Dir : String;
3490 Data : in out Project_Data)
3492 Attributes : constant Prj.Variable_Id := Data.Decl.Attributes;
3494 Lib_Dir : constant Prj.Variable_Value :=
3496 (Snames.Name_Library_Dir, Attributes, In_Tree);
3498 Lib_Name : constant Prj.Variable_Value :=
3500 (Snames.Name_Library_Name, Attributes, In_Tree);
3502 Lib_Version : constant Prj.Variable_Value :=
3504 (Snames.Name_Library_Version, Attributes, In_Tree);
3506 Lib_ALI_Dir : constant Prj.Variable_Value :=
3508 (Snames.Name_Library_Ali_Dir, Attributes, In_Tree);
3510 The_Lib_Kind : constant Prj.Variable_Value :=
3512 (Snames.Name_Library_Kind, Attributes, In_Tree);
3514 Imported_Project_List : Project_List := Empty_Project_List;
3516 Continuation : String_Access := No_Continuation_String'Access;
3518 Support_For_Libraries : Library_Support;
3520 Library_Directory_Present : Boolean;
3522 procedure Check_Library (Proj : Project_Id; Extends : Boolean);
3523 -- Check if an imported or extended project if also a library project
3529 procedure Check_Library (Proj : Project_Id; Extends : Boolean) is
3530 Proj_Data : Project_Data;
3535 if Proj /= No_Project then
3536 Proj_Data := In_Tree.Projects.Table (Proj);
3538 if not Proj_Data.Library then
3540 -- The only not library projects that are OK are those that
3541 -- have no sources. However, header files from non-Ada
3542 -- languages are OK, as there is nothing to compile.
3544 Src_Id := Proj_Data.First_Source;
3545 while Src_Id /= No_Source loop
3546 Src := In_Tree.Sources.Table (Src_Id);
3548 exit when Src.Lang_Kind /= File_Based
3549 or else Src.Kind /= Spec;
3551 Src_Id := Src.Next_In_Project;
3554 if Src_Id /= No_Source then
3555 Error_Msg_Name_1 := Data.Name;
3556 Error_Msg_Name_2 := Proj_Data.Name;
3559 if Data.Library_Kind /= Static then
3563 "shared library project %% cannot extend " &
3564 "project %% that is not a library project",
3566 Continuation := Continuation_String'Access;
3569 elsif Data.Library_Kind /= Static then
3573 "shared library project %% cannot import project %% " &
3574 "that is not a shared library project",
3576 Continuation := Continuation_String'Access;
3580 elsif Data.Library_Kind /= Static and then
3581 Proj_Data.Library_Kind = Static
3583 Error_Msg_Name_1 := Data.Name;
3584 Error_Msg_Name_2 := Proj_Data.Name;
3590 "shared library project %% cannot extend static " &
3591 "library project %%",
3598 "shared library project %% cannot import static " &
3599 "library project %%",
3603 Continuation := Continuation_String'Access;
3608 -- Start of processing for Check_Library_Attributes
3611 Library_Directory_Present := Lib_Dir.Value /= Empty_String;
3613 -- Special case of extending project
3615 if Data.Extends /= No_Project then
3617 Extended_Data : constant Project_Data :=
3618 In_Tree.Projects.Table (Data.Extends);
3621 -- If the project extended is a library project, we inherit the
3622 -- library name, if it is not redefined; we check that the library
3623 -- directory is specified.
3625 if Extended_Data.Library then
3626 if Data.Qualifier = Standard then
3629 "a standard project cannot extend a library project",
3633 if Lib_Name.Default then
3634 Data.Library_Name := Extended_Data.Library_Name;
3637 if Lib_Dir.Default then
3638 if not Data.Virtual then
3641 "a project extending a library project must " &
3642 "specify an attribute Library_Dir",
3646 -- For a virtual project extending a library project,
3647 -- inherit library directory.
3649 Data.Library_Dir := Extended_Data.Library_Dir;
3650 Library_Directory_Present := True;
3658 pragma Assert (Lib_Name.Kind = Single);
3660 if Lib_Name.Value = Empty_String then
3661 if Current_Verbosity = High
3662 and then Data.Library_Name = No_Name
3664 Write_Line ("No library name");
3668 -- There is no restriction on the syntax of library names
3670 Data.Library_Name := Lib_Name.Value;
3673 if Data.Library_Name /= No_Name then
3674 if Current_Verbosity = High then
3675 Write_Str ("Library name = """);
3676 Write_Str (Get_Name_String (Data.Library_Name));
3680 pragma Assert (Lib_Dir.Kind = Single);
3682 if not Library_Directory_Present then
3683 if Current_Verbosity = High then
3684 Write_Line ("No library directory");
3688 -- Find path name (unless inherited), check that it is a directory
3690 if Data.Library_Dir = No_Path_Information then
3694 File_Name_Type (Lib_Dir.Value),
3695 Data.Directory.Display_Name,
3696 Data.Library_Dir.Name,
3697 Data.Library_Dir.Display_Name,
3698 Create => "library",
3699 Current_Dir => Current_Dir,
3700 Location => Lib_Dir.Location);
3703 if Data.Library_Dir = No_Path_Information then
3705 -- Get the absolute name of the library directory that
3706 -- does not exist, to report an error.
3709 Dir_Name : constant String :=
3710 Get_Name_String (Lib_Dir.Value);
3713 if Is_Absolute_Path (Dir_Name) then
3714 Err_Vars.Error_Msg_File_1 :=
3715 File_Name_Type (Lib_Dir.Value);
3718 Get_Name_String (Data.Directory.Display_Name);
3720 if Name_Buffer (Name_Len) /= Directory_Separator then
3721 Name_Len := Name_Len + 1;
3722 Name_Buffer (Name_Len) := Directory_Separator;
3726 (Name_Len + 1 .. Name_Len + Dir_Name'Length) :=
3728 Name_Len := Name_Len + Dir_Name'Length;
3729 Err_Vars.Error_Msg_File_1 := Name_Find;
3736 "library directory { does not exist",
3740 -- The library directory cannot be the same as the Object
3743 elsif Data.Library_Dir.Name = Data.Object_Directory.Name then
3746 "library directory cannot be the same " &
3747 "as object directory",
3749 Data.Library_Dir := No_Path_Information;
3753 OK : Boolean := True;
3754 Dirs_Id : String_List_Id;
3755 Dir_Elem : String_Element;
3758 -- The library directory cannot be the same as a source
3759 -- directory of the current project.
3761 Dirs_Id := Data.Source_Dirs;
3762 while Dirs_Id /= Nil_String loop
3763 Dir_Elem := In_Tree.String_Elements.Table (Dirs_Id);
3764 Dirs_Id := Dir_Elem.Next;
3767 Data.Library_Dir.Name = Path_Name_Type (Dir_Elem.Value)
3769 Err_Vars.Error_Msg_File_1 :=
3770 File_Name_Type (Dir_Elem.Value);
3773 "library directory cannot be the same " &
3774 "as source directory {",
3783 -- The library directory cannot be the same as a source
3784 -- directory of another project either.
3787 for Pid in 1 .. Project_Table.Last (In_Tree.Projects) loop
3788 if Pid /= Project then
3789 Dirs_Id := In_Tree.Projects.Table (Pid).Source_Dirs;
3791 Dir_Loop : while Dirs_Id /= Nil_String loop
3793 In_Tree.String_Elements.Table (Dirs_Id);
3794 Dirs_Id := Dir_Elem.Next;
3796 if Data.Library_Dir.Name =
3797 Path_Name_Type (Dir_Elem.Value)
3799 Err_Vars.Error_Msg_File_1 :=
3800 File_Name_Type (Dir_Elem.Value);
3801 Err_Vars.Error_Msg_Name_1 :=
3802 In_Tree.Projects.Table (Pid).Name;
3806 "library directory cannot be the same " &
3807 "as source directory { of project %%",
3814 end loop Project_Loop;
3818 Data.Library_Dir := No_Path_Information;
3820 elsif Current_Verbosity = High then
3822 -- Display the Library directory in high verbosity
3824 Write_Str ("Library directory =""");
3826 (Get_Name_String (Data.Library_Dir.Display_Name));
3836 Data.Library_Dir /= No_Path_Information
3838 Data.Library_Name /= No_Name;
3840 if Data.Extends = No_Project then
3841 case Data.Qualifier is
3843 if Data.Library then
3846 "a standard project cannot be a library project",
3851 if not Data.Library then
3854 "not a library project",
3864 if Data.Library then
3865 if Get_Mode = Multi_Language then
3866 Support_For_Libraries := Data.Config.Lib_Support;
3869 Support_For_Libraries := MLib.Tgt.Support_For_Libraries;
3872 if Support_For_Libraries = Prj.None then
3875 "?libraries are not supported on this platform",
3877 Data.Library := False;
3880 if Lib_ALI_Dir.Value = Empty_String then
3881 if Current_Verbosity = High then
3882 Write_Line ("No library ALI directory specified");
3884 Data.Library_ALI_Dir := Data.Library_Dir;
3887 -- Find path name, check that it is a directory
3892 File_Name_Type (Lib_ALI_Dir.Value),
3893 Data.Directory.Display_Name,
3894 Data.Library_ALI_Dir.Name,
3895 Data.Library_ALI_Dir.Display_Name,
3896 Create => "library ALI",
3897 Current_Dir => Current_Dir,
3898 Location => Lib_ALI_Dir.Location);
3900 if Data.Library_ALI_Dir = No_Path_Information then
3902 -- Get the absolute name of the library ALI directory that
3903 -- does not exist, to report an error.
3906 Dir_Name : constant String :=
3907 Get_Name_String (Lib_ALI_Dir.Value);
3910 if Is_Absolute_Path (Dir_Name) then
3911 Err_Vars.Error_Msg_File_1 :=
3912 File_Name_Type (Lib_Dir.Value);
3915 Get_Name_String (Data.Directory.Display_Name);
3917 if Name_Buffer (Name_Len) /= Directory_Separator then
3918 Name_Len := Name_Len + 1;
3919 Name_Buffer (Name_Len) := Directory_Separator;
3923 (Name_Len + 1 .. Name_Len + Dir_Name'Length) :=
3925 Name_Len := Name_Len + Dir_Name'Length;
3926 Err_Vars.Error_Msg_File_1 := Name_Find;
3933 "library 'A'L'I directory { does not exist",
3934 Lib_ALI_Dir.Location);
3938 if Data.Library_ALI_Dir /= Data.Library_Dir then
3940 -- The library ALI directory cannot be the same as the
3941 -- Object directory.
3943 if Data.Library_ALI_Dir = Data.Object_Directory then
3946 "library 'A'L'I directory cannot be the same " &
3947 "as object directory",
3948 Lib_ALI_Dir.Location);
3949 Data.Library_ALI_Dir := No_Path_Information;
3953 OK : Boolean := True;
3954 Dirs_Id : String_List_Id;
3955 Dir_Elem : String_Element;
3958 -- The library ALI directory cannot be the same as
3959 -- a source directory of the current project.
3961 Dirs_Id := Data.Source_Dirs;
3962 while Dirs_Id /= Nil_String loop
3963 Dir_Elem := In_Tree.String_Elements.Table (Dirs_Id);
3964 Dirs_Id := Dir_Elem.Next;
3966 if Data.Library_ALI_Dir.Name =
3967 Path_Name_Type (Dir_Elem.Value)
3969 Err_Vars.Error_Msg_File_1 :=
3970 File_Name_Type (Dir_Elem.Value);
3973 "library 'A'L'I directory cannot be " &
3974 "the same as source directory {",
3975 Lib_ALI_Dir.Location);
3983 -- The library ALI directory cannot be the same as
3984 -- a source directory of another project either.
3988 Pid in 1 .. Project_Table.Last (In_Tree.Projects)
3990 if Pid /= Project then
3992 In_Tree.Projects.Table (Pid).Source_Dirs;
3995 while Dirs_Id /= Nil_String loop
3997 In_Tree.String_Elements.Table (Dirs_Id);
3998 Dirs_Id := Dir_Elem.Next;
4000 if Data.Library_ALI_Dir.Name =
4001 Path_Name_Type (Dir_Elem.Value)
4003 Err_Vars.Error_Msg_File_1 :=
4004 File_Name_Type (Dir_Elem.Value);
4005 Err_Vars.Error_Msg_Name_1 :=
4006 In_Tree.Projects.Table (Pid).Name;
4010 "library 'A'L'I directory cannot " &
4011 "be the same as source directory " &
4013 Lib_ALI_Dir.Location);
4015 exit ALI_Project_Loop;
4017 end loop ALI_Dir_Loop;
4019 end loop ALI_Project_Loop;
4023 Data.Library_ALI_Dir := No_Path_Information;
4025 elsif Current_Verbosity = High then
4027 -- Display the Library ALI directory in high
4030 Write_Str ("Library ALI directory =""");
4033 (Data.Library_ALI_Dir.Display_Name));
4041 pragma Assert (Lib_Version.Kind = Single);
4043 if Lib_Version.Value = Empty_String then
4044 if Current_Verbosity = High then
4045 Write_Line ("No library version specified");
4049 Data.Lib_Internal_Name := Lib_Version.Value;
4052 pragma Assert (The_Lib_Kind.Kind = Single);
4054 if The_Lib_Kind.Value = Empty_String then
4055 if Current_Verbosity = High then
4056 Write_Line ("No library kind specified");
4060 Get_Name_String (The_Lib_Kind.Value);
4063 Kind_Name : constant String :=
4064 To_Lower (Name_Buffer (1 .. Name_Len));
4066 OK : Boolean := True;
4069 if Kind_Name = "static" then
4070 Data.Library_Kind := Static;
4072 elsif Kind_Name = "dynamic" then
4073 Data.Library_Kind := Dynamic;
4075 elsif Kind_Name = "relocatable" then
4076 Data.Library_Kind := Relocatable;
4081 "illegal value for Library_Kind",
4082 The_Lib_Kind.Location);
4086 if Current_Verbosity = High and then OK then
4087 Write_Str ("Library kind = ");
4088 Write_Line (Kind_Name);
4091 if Data.Library_Kind /= Static and then
4092 Support_For_Libraries = Prj.Static_Only
4096 "only static libraries are supported " &
4098 The_Lib_Kind.Location);
4099 Data.Library := False;
4104 if Data.Library then
4105 if Current_Verbosity = High then
4106 Write_Line ("This is a library project file");
4109 if Get_Mode = Multi_Language then
4110 Check_Library (Data.Extends, Extends => True);
4112 Imported_Project_List := Data.Imported_Projects;
4113 while Imported_Project_List /= Empty_Project_List loop
4115 (In_Tree.Project_Lists.Table
4116 (Imported_Project_List).Project,
4118 Imported_Project_List :=
4119 In_Tree.Project_Lists.Table
4120 (Imported_Project_List).Next;
4128 -- Check if Linker'Switches or Linker'Default_Switches are declared.
4129 -- Warn if they are declared, as it is a common error to think that
4130 -- library are "linked" with Linker switches.
4132 if Data.Library then
4134 Linker_Package_Id : constant Package_Id :=
4136 (Name_Linker, Data.Decl.Packages, In_Tree);
4137 Linker_Package : Package_Element;
4138 Switches : Array_Element_Id := No_Array_Element;
4141 if Linker_Package_Id /= No_Package then
4142 Linker_Package := In_Tree.Packages.Table (Linker_Package_Id);
4146 (Name => Name_Switches,
4147 In_Arrays => Linker_Package.Decl.Arrays,
4148 In_Tree => In_Tree);
4150 if Switches = No_Array_Element then
4153 (Name => Name_Default_Switches,
4154 In_Arrays => Linker_Package.Decl.Arrays,
4155 In_Tree => In_Tree);
4158 if Switches /= No_Array_Element then
4161 "?Linker switches not taken into account in library " &
4169 if Data.Extends /= No_Project then
4170 In_Tree.Projects.Table (Data.Extends).Library := False;
4172 end Check_Library_Attributes;
4174 --------------------------
4175 -- Check_Package_Naming --
4176 --------------------------
4178 procedure Check_Package_Naming
4179 (Project : Project_Id;
4180 In_Tree : Project_Tree_Ref;
4181 Data : in out Project_Data)
4183 Naming_Id : constant Package_Id :=
4184 Util.Value_Of (Name_Naming, Data.Decl.Packages, In_Tree);
4186 Naming : Package_Element;
4189 -- If there is a package Naming, we will put in Data.Naming
4190 -- what is in this package Naming.
4192 if Naming_Id /= No_Package then
4193 Naming := In_Tree.Packages.Table (Naming_Id);
4195 if Current_Verbosity = High then
4196 Write_Line ("Checking ""Naming"".");
4199 -- Check Spec_Suffix
4202 Spec_Suffixs : Array_Element_Id :=
4208 Suffix : Array_Element_Id;
4209 Element : Array_Element;
4210 Suffix2 : Array_Element_Id;
4213 -- If some suffixes have been specified, we make sure that
4214 -- for each language for which a default suffix has been
4215 -- specified, there is a suffix specified, either the one
4216 -- in the project file or if there were none, the default.
4218 if Spec_Suffixs /= No_Array_Element then
4219 Suffix := Data.Naming.Spec_Suffix;
4221 while Suffix /= No_Array_Element loop
4223 In_Tree.Array_Elements.Table (Suffix);
4224 Suffix2 := Spec_Suffixs;
4226 while Suffix2 /= No_Array_Element loop
4227 exit when In_Tree.Array_Elements.Table
4228 (Suffix2).Index = Element.Index;
4229 Suffix2 := In_Tree.Array_Elements.Table
4233 -- There is a registered default suffix, but no
4234 -- suffix specified in the project file.
4235 -- Add the default to the array.
4237 if Suffix2 = No_Array_Element then
4238 Array_Element_Table.Increment_Last
4239 (In_Tree.Array_Elements);
4240 In_Tree.Array_Elements.Table
4241 (Array_Element_Table.Last
4242 (In_Tree.Array_Elements)) :=
4243 (Index => Element.Index,
4244 Src_Index => Element.Src_Index,
4245 Index_Case_Sensitive => False,
4246 Value => Element.Value,
4247 Next => Spec_Suffixs);
4248 Spec_Suffixs := Array_Element_Table.Last
4249 (In_Tree.Array_Elements);
4252 Suffix := Element.Next;
4255 -- Put the resulting array as the specification suffixes
4257 Data.Naming.Spec_Suffix := Spec_Suffixs;
4262 Current : Array_Element_Id;
4263 Element : Array_Element;
4266 Current := Data.Naming.Spec_Suffix;
4267 while Current /= No_Array_Element loop
4268 Element := In_Tree.Array_Elements.Table (Current);
4269 Get_Name_String (Element.Value.Value);
4271 if Name_Len = 0 then
4274 "Spec_Suffix cannot be empty",
4275 Element.Value.Location);
4278 In_Tree.Array_Elements.Table (Current) := Element;
4279 Current := Element.Next;
4283 -- Check Body_Suffix
4286 Impl_Suffixs : Array_Element_Id :=
4292 Suffix : Array_Element_Id;
4293 Element : Array_Element;
4294 Suffix2 : Array_Element_Id;
4297 -- If some suffixes have been specified, we make sure that
4298 -- for each language for which a default suffix has been
4299 -- specified, there is a suffix specified, either the one
4300 -- in the project file or if there were none, the default.
4302 if Impl_Suffixs /= No_Array_Element then
4303 Suffix := Data.Naming.Body_Suffix;
4304 while Suffix /= No_Array_Element loop
4306 In_Tree.Array_Elements.Table (Suffix);
4308 Suffix2 := Impl_Suffixs;
4309 while Suffix2 /= No_Array_Element loop
4310 exit when In_Tree.Array_Elements.Table
4311 (Suffix2).Index = Element.Index;
4312 Suffix2 := In_Tree.Array_Elements.Table
4316 -- There is a registered default suffix, but no suffix was
4317 -- specified in the project file. Add default to the array.
4319 if Suffix2 = No_Array_Element then
4320 Array_Element_Table.Increment_Last
4321 (In_Tree.Array_Elements);
4322 In_Tree.Array_Elements.Table
4323 (Array_Element_Table.Last
4324 (In_Tree.Array_Elements)) :=
4325 (Index => Element.Index,
4326 Src_Index => Element.Src_Index,
4327 Index_Case_Sensitive => False,
4328 Value => Element.Value,
4329 Next => Impl_Suffixs);
4330 Impl_Suffixs := Array_Element_Table.Last
4331 (In_Tree.Array_Elements);
4334 Suffix := Element.Next;
4337 -- Put the resulting array as the implementation suffixes
4339 Data.Naming.Body_Suffix := Impl_Suffixs;
4344 Current : Array_Element_Id;
4345 Element : Array_Element;
4348 Current := Data.Naming.Body_Suffix;
4349 while Current /= No_Array_Element loop
4350 Element := In_Tree.Array_Elements.Table (Current);
4351 Get_Name_String (Element.Value.Value);
4353 if Name_Len = 0 then
4356 "Body_Suffix cannot be empty",
4357 Element.Value.Location);
4360 In_Tree.Array_Elements.Table (Current) := Element;
4361 Current := Element.Next;
4365 -- Get the exceptions, if any
4367 Data.Naming.Specification_Exceptions :=
4369 (Name_Specification_Exceptions,
4370 In_Arrays => Naming.Decl.Arrays,
4371 In_Tree => In_Tree);
4373 Data.Naming.Implementation_Exceptions :=
4375 (Name_Implementation_Exceptions,
4376 In_Arrays => Naming.Decl.Arrays,
4377 In_Tree => In_Tree);
4379 end Check_Package_Naming;
4381 ---------------------------------
4382 -- Check_Programming_Languages --
4383 ---------------------------------
4385 procedure Check_Programming_Languages
4386 (In_Tree : Project_Tree_Ref;
4387 Project : Project_Id;
4388 Data : in out Project_Data)
4390 Languages : Variable_Value := Nil_Variable_Value;
4391 Def_Lang : Variable_Value := Nil_Variable_Value;
4392 Def_Lang_Id : Name_Id;
4395 Data.First_Language_Processing := No_Language_Index;
4397 Prj.Util.Value_Of (Name_Languages, Data.Decl.Attributes, In_Tree);
4400 (Name_Default_Language, Data.Decl.Attributes, In_Tree);
4401 Data.Ada_Sources_Present := Data.Source_Dirs /= Nil_String;
4402 Data.Other_Sources_Present := Data.Source_Dirs /= Nil_String;
4404 if Data.Source_Dirs /= Nil_String then
4406 -- Check if languages are specified in this project
4408 if Languages.Default then
4410 -- Attribute Languages is not specified. So, it defaults to
4411 -- a project of the default language only.
4413 Name_List_Table.Increment_Last (In_Tree.Name_Lists);
4414 Data.Languages := Name_List_Table.Last (In_Tree.Name_Lists);
4416 -- In Ada_Only mode, the default language is Ada
4418 if Get_Mode = Ada_Only then
4419 In_Tree.Name_Lists.Table (Data.Languages) :=
4420 (Name => Name_Ada, Next => No_Name_List);
4422 -- Attribute Languages is not specified. So, it defaults to
4423 -- a project of language Ada only. No sources of languages
4426 Data.Other_Sources_Present := False;
4429 -- Fail if there is no default language defined
4431 if Def_Lang.Default then
4432 if not Default_Language_Is_Ada then
4436 "no languages defined for this project",
4438 Def_Lang_Id := No_Name;
4440 Def_Lang_Id := Name_Ada;
4444 Get_Name_String (Def_Lang.Value);
4445 To_Lower (Name_Buffer (1 .. Name_Len));
4446 Def_Lang_Id := Name_Find;
4449 if Def_Lang_Id /= No_Name then
4450 In_Tree.Name_Lists.Table (Data.Languages) :=
4451 (Name => Def_Lang_Id, Next => No_Name_List);
4453 Language_Data_Table.Increment_Last (In_Tree.Languages_Data);
4455 Data.First_Language_Processing :=
4456 Language_Data_Table.Last (In_Tree.Languages_Data);
4457 In_Tree.Languages_Data.Table
4458 (Data.First_Language_Processing) := No_Language_Data;
4459 In_Tree.Languages_Data.Table
4460 (Data.First_Language_Processing).Name := Def_Lang_Id;
4461 Get_Name_String (Def_Lang_Id);
4462 Name_Buffer (1) := GNAT.Case_Util.To_Upper (Name_Buffer (1));
4463 In_Tree.Languages_Data.Table
4464 (Data.First_Language_Processing).Display_Name := Name_Find;
4466 if Def_Lang_Id = Name_Ada then
4467 In_Tree.Languages_Data.Table
4468 (Data.First_Language_Processing).Config.Kind
4470 In_Tree.Languages_Data.Table
4471 (Data.First_Language_Processing).Config.Dependency_Kind
4473 Data.Unit_Based_Language_Name := Name_Ada;
4474 Data.Unit_Based_Language_Index :=
4475 Data.First_Language_Processing;
4477 In_Tree.Languages_Data.Table
4478 (Data.First_Language_Processing).Config.Kind
4486 Current : String_List_Id := Languages.Values;
4487 Element : String_Element;
4488 Lang_Name : Name_Id;
4489 Index : Language_Index;
4490 Lang_Data : Language_Data;
4491 NL_Id : Name_List_Index := No_Name_List;
4494 -- Assume there are no language declared
4496 Data.Ada_Sources_Present := False;
4497 Data.Other_Sources_Present := False;
4499 -- If there are no languages declared, there are no sources
4501 if Current = Nil_String then
4502 Data.Source_Dirs := Nil_String;
4504 if Data.Qualifier = Standard then
4508 "a standard project cannot have no language declared",
4509 Languages.Location);
4513 -- Look through all the languages specified in attribute
4516 while Current /= Nil_String loop
4518 In_Tree.String_Elements.Table (Current);
4519 Get_Name_String (Element.Value);
4520 To_Lower (Name_Buffer (1 .. Name_Len));
4521 Lang_Name := Name_Find;
4523 NL_Id := Data.Languages;
4524 while NL_Id /= No_Name_List loop
4526 Lang_Name = In_Tree.Name_Lists.Table (NL_Id).Name;
4527 NL_Id := In_Tree.Name_Lists.Table (NL_Id).Next;
4530 if NL_Id = No_Name_List then
4531 Name_List_Table.Increment_Last (In_Tree.Name_Lists);
4533 if Data.Languages = No_Name_List then
4535 Name_List_Table.Last (In_Tree.Name_Lists);
4538 NL_Id := Data.Languages;
4539 while In_Tree.Name_Lists.Table (NL_Id).Next /=
4542 NL_Id := In_Tree.Name_Lists.Table (NL_Id).Next;
4545 In_Tree.Name_Lists.Table (NL_Id).Next :=
4546 Name_List_Table.Last (In_Tree.Name_Lists);
4549 NL_Id := Name_List_Table.Last (In_Tree.Name_Lists);
4550 In_Tree.Name_Lists.Table (NL_Id) :=
4551 (Lang_Name, No_Name_List);
4553 if Get_Mode = Ada_Only then
4554 -- Check for language Ada
4556 if Lang_Name = Name_Ada then
4557 Data.Ada_Sources_Present := True;
4560 Data.Other_Sources_Present := True;
4564 Language_Data_Table.Increment_Last
4565 (In_Tree.Languages_Data);
4567 Language_Data_Table.Last (In_Tree.Languages_Data);
4568 Lang_Data.Name := Lang_Name;
4569 Lang_Data.Display_Name := Element.Value;
4570 Lang_Data.Next := Data.First_Language_Processing;
4572 if Lang_Name = Name_Ada then
4573 Lang_Data.Config.Kind := Unit_Based;
4574 Lang_Data.Config.Dependency_Kind := ALI_File;
4575 Data.Unit_Based_Language_Name := Name_Ada;
4576 Data.Unit_Based_Language_Index := Index;
4579 Lang_Data.Config.Kind := File_Based;
4580 Lang_Data.Config.Dependency_Kind := None;
4583 In_Tree.Languages_Data.Table (Index) := Lang_Data;
4584 Data.First_Language_Processing := Index;
4588 Current := Element.Next;
4594 end Check_Programming_Languages;
4600 function Check_Project
4602 Root_Project : Project_Id;
4603 In_Tree : Project_Tree_Ref;
4604 Extending : Boolean) return Boolean
4607 if P = Root_Project then
4610 elsif Extending then
4612 Data : Project_Data := In_Tree.Projects.Table (Root_Project);
4615 while Data.Extends /= No_Project loop
4616 if P = Data.Extends then
4620 Data := In_Tree.Projects.Table (Data.Extends);
4628 -------------------------------
4629 -- Check_Stand_Alone_Library --
4630 -------------------------------
4632 procedure Check_Stand_Alone_Library
4633 (Project : Project_Id;
4634 In_Tree : Project_Tree_Ref;
4635 Data : in out Project_Data;
4636 Current_Dir : String;
4637 Extending : Boolean)
4639 Lib_Interfaces : constant Prj.Variable_Value :=
4641 (Snames.Name_Library_Interface,
4642 Data.Decl.Attributes,
4645 Lib_Auto_Init : constant Prj.Variable_Value :=
4647 (Snames.Name_Library_Auto_Init,
4648 Data.Decl.Attributes,
4651 Lib_Src_Dir : constant Prj.Variable_Value :=
4653 (Snames.Name_Library_Src_Dir,
4654 Data.Decl.Attributes,
4657 Lib_Symbol_File : constant Prj.Variable_Value :=
4659 (Snames.Name_Library_Symbol_File,
4660 Data.Decl.Attributes,
4663 Lib_Symbol_Policy : constant Prj.Variable_Value :=
4665 (Snames.Name_Library_Symbol_Policy,
4666 Data.Decl.Attributes,
4669 Lib_Ref_Symbol_File : constant Prj.Variable_Value :=
4671 (Snames.Name_Library_Reference_Symbol_File,
4672 Data.Decl.Attributes,
4675 Auto_Init_Supported : Boolean;
4676 OK : Boolean := True;
4678 Next_Proj : Project_Id;
4681 if Get_Mode = Multi_Language then
4682 Auto_Init_Supported := Data.Config.Auto_Init_Supported;
4684 Auto_Init_Supported :=
4685 MLib.Tgt.Standalone_Library_Auto_Init_Is_Supported;
4688 pragma Assert (Lib_Interfaces.Kind = List);
4690 -- It is a stand-alone library project file if attribute
4691 -- Library_Interface is defined.
4693 if not Lib_Interfaces.Default then
4694 SAL_Library : declare
4695 Interfaces : String_List_Id := Lib_Interfaces.Values;
4696 Interface_ALIs : String_List_Id := Nil_String;
4698 The_Unit_Id : Unit_Index;
4699 The_Unit_Data : Unit_Data;
4701 procedure Add_ALI_For (Source : File_Name_Type);
4702 -- Add an ALI file name to the list of Interface ALIs
4708 procedure Add_ALI_For (Source : File_Name_Type) is
4710 Get_Name_String (Source);
4713 ALI : constant String :=
4714 ALI_File_Name (Name_Buffer (1 .. Name_Len));
4715 ALI_Name_Id : Name_Id;
4718 Name_Len := ALI'Length;
4719 Name_Buffer (1 .. Name_Len) := ALI;
4720 ALI_Name_Id := Name_Find;
4722 String_Element_Table.Increment_Last
4723 (In_Tree.String_Elements);
4724 In_Tree.String_Elements.Table
4725 (String_Element_Table.Last
4726 (In_Tree.String_Elements)) :=
4727 (Value => ALI_Name_Id,
4729 Display_Value => ALI_Name_Id,
4731 In_Tree.String_Elements.Table
4732 (Interfaces).Location,
4734 Next => Interface_ALIs);
4735 Interface_ALIs := String_Element_Table.Last
4736 (In_Tree.String_Elements);
4740 -- Start of processing for SAL_Library
4743 Data.Standalone_Library := True;
4745 -- Library_Interface cannot be an empty list
4747 if Interfaces = Nil_String then
4750 "Library_Interface cannot be an empty list",
4751 Lib_Interfaces.Location);
4754 -- Process each unit name specified in the attribute
4755 -- Library_Interface.
4757 while Interfaces /= Nil_String loop
4759 (In_Tree.String_Elements.Table (Interfaces).Value);
4760 To_Lower (Name_Buffer (1 .. Name_Len));
4762 if Name_Len = 0 then
4765 "an interface cannot be an empty string",
4766 In_Tree.String_Elements.Table (Interfaces).Location);
4770 Error_Msg_Name_1 := Unit;
4772 if Get_Mode = Ada_Only then
4774 Units_Htable.Get (In_Tree.Units_HT, Unit);
4776 if The_Unit_Id = No_Unit_Index then
4780 In_Tree.String_Elements.Table
4781 (Interfaces).Location);
4784 -- Check that the unit is part of the project
4787 In_Tree.Units.Table (The_Unit_Id);
4789 if The_Unit_Data.File_Names (Body_Part).Name /= No_File
4790 and then The_Unit_Data.File_Names
4791 (Body_Part).Path.Name /= Slash
4794 (The_Unit_Data.File_Names (Body_Part).Project,
4795 Project, In_Tree, Extending)
4797 -- There is a body for this unit.
4798 -- If there is no spec, we need to check
4799 -- that it is not a subunit.
4801 if The_Unit_Data.File_Names
4802 (Specification).Name = No_File
4805 Src_Ind : Source_File_Index;
4808 Src_Ind := Sinput.P.Load_Project_File
4810 (The_Unit_Data.File_Names
4811 (Body_Part).Path.Name));
4813 if Sinput.P.Source_File_Is_Subunit
4818 "%% is a subunit; " &
4819 "it cannot be an interface",
4821 String_Elements.Table
4822 (Interfaces).Location);
4827 -- The unit is not a subunit, so we add
4828 -- to the Interface ALIs the ALI file
4829 -- corresponding to the body.
4832 (The_Unit_Data.File_Names (Body_Part).Name);
4837 "%% is not an unit of this project",
4838 In_Tree.String_Elements.Table
4839 (Interfaces).Location);
4842 elsif The_Unit_Data.File_Names
4843 (Specification).Name /= No_File
4844 and then The_Unit_Data.File_Names
4845 (Specification).Path.Name /= Slash
4846 and then Check_Project
4847 (The_Unit_Data.File_Names
4848 (Specification).Project,
4849 Project, In_Tree, Extending)
4852 -- The unit is part of the project, it has
4853 -- a spec, but no body. We add to the Interface
4854 -- ALIs the ALI file corresponding to the spec.
4857 (The_Unit_Data.File_Names (Specification).Name);
4862 "%% is not an unit of this project",
4863 In_Tree.String_Elements.Table
4864 (Interfaces).Location);
4869 -- Multi_Language mode
4871 Next_Proj := Data.Extends;
4872 Source := Data.First_Source;
4875 while Source /= No_Source and then
4876 In_Tree.Sources.Table (Source).Unit /= Unit
4879 In_Tree.Sources.Table (Source).Next_In_Project;
4882 exit when Source /= No_Source or else
4883 Next_Proj = No_Project;
4886 In_Tree.Projects.Table (Next_Proj).First_Source;
4888 In_Tree.Projects.Table (Next_Proj).Extends;
4891 if Source /= No_Source then
4892 if In_Tree.Sources.Table (Source).Kind = Sep then
4893 Source := No_Source;
4895 elsif In_Tree.Sources.Table (Source).Kind = Spec
4897 In_Tree.Sources.Table (Source).Other_Part /=
4900 Source := In_Tree.Sources.Table (Source).Other_Part;
4904 if Source /= No_Source then
4905 if In_Tree.Sources.Table (Source).Project /= Project
4909 In_Tree.Sources.Table (Source).Project,
4912 Source := No_Source;
4916 if Source = No_Source then
4919 "%% is not an unit of this project",
4920 In_Tree.String_Elements.Table
4921 (Interfaces).Location);
4924 if In_Tree.Sources.Table (Source).Kind = Spec and then
4925 In_Tree.Sources.Table (Source).Other_Part /=
4928 Source := In_Tree.Sources.Table (Source).Other_Part;
4931 String_Element_Table.Increment_Last
4932 (In_Tree.String_Elements);
4933 In_Tree.String_Elements.Table
4934 (String_Element_Table.Last
4935 (In_Tree.String_Elements)) :=
4937 Name_Id (In_Tree.Sources.Table (Source).Dep_Name),
4940 Name_Id (In_Tree.Sources.Table (Source).Dep_Name),
4942 In_Tree.String_Elements.Table
4943 (Interfaces).Location,
4945 Next => Interface_ALIs);
4946 Interface_ALIs := String_Element_Table.Last
4947 (In_Tree.String_Elements);
4955 In_Tree.String_Elements.Table (Interfaces).Next;
4958 -- Put the list of Interface ALIs in the project data
4960 Data.Lib_Interface_ALIs := Interface_ALIs;
4962 -- Check value of attribute Library_Auto_Init and set
4963 -- Lib_Auto_Init accordingly.
4965 if Lib_Auto_Init.Default then
4967 -- If no attribute Library_Auto_Init is declared, then set auto
4968 -- init only if it is supported.
4970 Data.Lib_Auto_Init := Auto_Init_Supported;
4973 Get_Name_String (Lib_Auto_Init.Value);
4974 To_Lower (Name_Buffer (1 .. Name_Len));
4976 if Name_Buffer (1 .. Name_Len) = "false" then
4977 Data.Lib_Auto_Init := False;
4979 elsif Name_Buffer (1 .. Name_Len) = "true" then
4980 if Auto_Init_Supported then
4981 Data.Lib_Auto_Init := True;
4984 -- Library_Auto_Init cannot be "true" if auto init is not
4989 "library auto init not supported " &
4991 Lib_Auto_Init.Location);
4997 "invalid value for attribute Library_Auto_Init",
4998 Lib_Auto_Init.Location);
5003 -- If attribute Library_Src_Dir is defined and not the empty string,
5004 -- check if the directory exist and is not the object directory or
5005 -- one of the source directories. This is the directory where copies
5006 -- of the interface sources will be copied. Note that this directory
5007 -- may be the library directory.
5009 if Lib_Src_Dir.Value /= Empty_String then
5011 Dir_Id : constant File_Name_Type :=
5012 File_Name_Type (Lib_Src_Dir.Value);
5019 Data.Directory.Display_Name,
5020 Data.Library_Src_Dir.Name,
5021 Data.Library_Src_Dir.Display_Name,
5022 Create => "library source copy",
5023 Current_Dir => Current_Dir,
5024 Location => Lib_Src_Dir.Location);
5026 -- If directory does not exist, report an error
5028 if Data.Library_Src_Dir = No_Path_Information then
5030 -- Get the absolute name of the library directory that does
5031 -- not exist, to report an error.
5034 Dir_Name : constant String :=
5035 Get_Name_String (Dir_Id);
5038 if Is_Absolute_Path (Dir_Name) then
5039 Err_Vars.Error_Msg_File_1 := Dir_Id;
5042 Get_Name_String (Data.Directory.Name);
5044 if Name_Buffer (Name_Len) /=
5047 Name_Len := Name_Len + 1;
5048 Name_Buffer (Name_Len) :=
5049 Directory_Separator;
5054 Name_Len + Dir_Name'Length) :=
5056 Name_Len := Name_Len + Dir_Name'Length;
5057 Err_Vars.Error_Msg_Name_1 := Name_Find;
5062 Error_Msg_File_1 := Dir_Id;
5065 "Directory { does not exist",
5066 Lib_Src_Dir.Location);
5069 -- Report error if it is the same as the object directory
5071 elsif Data.Library_Src_Dir = Data.Object_Directory then
5074 "directory to copy interfaces cannot be " &
5075 "the object directory",
5076 Lib_Src_Dir.Location);
5077 Data.Library_Src_Dir := No_Path_Information;
5081 Src_Dirs : String_List_Id;
5082 Src_Dir : String_Element;
5085 -- Interface copy directory cannot be one of the source
5086 -- directory of the current project.
5088 Src_Dirs := Data.Source_Dirs;
5089 while Src_Dirs /= Nil_String loop
5090 Src_Dir := In_Tree.String_Elements.Table (Src_Dirs);
5092 -- Report error if it is one of the source directories
5094 if Data.Library_Src_Dir.Name =
5095 Path_Name_Type (Src_Dir.Value)
5099 "directory to copy interfaces cannot " &
5100 "be one of the source directories",
5101 Lib_Src_Dir.Location);
5102 Data.Library_Src_Dir := No_Path_Information;
5106 Src_Dirs := Src_Dir.Next;
5109 if Data.Library_Src_Dir /= No_Path_Information then
5111 -- It cannot be a source directory of any other
5114 Project_Loop : for Pid in 1 ..
5115 Project_Table.Last (In_Tree.Projects)
5118 In_Tree.Projects.Table (Pid).Source_Dirs;
5119 Dir_Loop : while Src_Dirs /= Nil_String loop
5121 In_Tree.String_Elements.Table (Src_Dirs);
5123 -- Report error if it is one of the source
5126 if Data.Library_Src_Dir.Name =
5127 Path_Name_Type (Src_Dir.Value)
5130 File_Name_Type (Src_Dir.Value);
5132 In_Tree.Projects.Table (Pid).Name;
5135 "directory to copy interfaces cannot " &
5136 "be the same as source directory { of " &
5138 Lib_Src_Dir.Location);
5139 Data.Library_Src_Dir := No_Path_Information;
5143 Src_Dirs := Src_Dir.Next;
5145 end loop Project_Loop;
5149 -- In high verbosity, if there is a valid Library_Src_Dir,
5150 -- display its path name.
5152 if Data.Library_Src_Dir /= No_Path_Information
5153 and then Current_Verbosity = High
5155 Write_Str ("Directory to copy interfaces =""");
5156 Write_Str (Get_Name_String (Data.Library_Src_Dir.Name));
5163 -- Check the symbol related attributes
5165 -- First, the symbol policy
5167 if not Lib_Symbol_Policy.Default then
5169 Value : constant String :=
5171 (Get_Name_String (Lib_Symbol_Policy.Value));
5174 -- Symbol policy must hove one of a limited number of values
5176 if Value = "autonomous" or else Value = "default" then
5177 Data.Symbol_Data.Symbol_Policy := Autonomous;
5179 elsif Value = "compliant" then
5180 Data.Symbol_Data.Symbol_Policy := Compliant;
5182 elsif Value = "controlled" then
5183 Data.Symbol_Data.Symbol_Policy := Controlled;
5185 elsif Value = "restricted" then
5186 Data.Symbol_Data.Symbol_Policy := Restricted;
5188 elsif Value = "direct" then
5189 Data.Symbol_Data.Symbol_Policy := Direct;
5194 "illegal value for Library_Symbol_Policy",
5195 Lib_Symbol_Policy.Location);
5200 -- If attribute Library_Symbol_File is not specified, symbol policy
5201 -- cannot be Restricted.
5203 if Lib_Symbol_File.Default then
5204 if Data.Symbol_Data.Symbol_Policy = Restricted then
5207 "Library_Symbol_File needs to be defined when " &
5208 "symbol policy is Restricted",
5209 Lib_Symbol_Policy.Location);
5213 -- Library_Symbol_File is defined
5215 Data.Symbol_Data.Symbol_File :=
5216 Path_Name_Type (Lib_Symbol_File.Value);
5218 Get_Name_String (Lib_Symbol_File.Value);
5220 if Name_Len = 0 then
5223 "symbol file name cannot be an empty string",
5224 Lib_Symbol_File.Location);
5227 OK := not Is_Absolute_Path (Name_Buffer (1 .. Name_Len));
5230 for J in 1 .. Name_Len loop
5231 if Name_Buffer (J) = '/'
5232 or else Name_Buffer (J) = Directory_Separator
5241 Error_Msg_File_1 := File_Name_Type (Lib_Symbol_File.Value);
5244 "symbol file name { is illegal. " &
5245 "Name cannot include directory info.",
5246 Lib_Symbol_File.Location);
5251 -- If attribute Library_Reference_Symbol_File is not defined,
5252 -- symbol policy cannot be Compliant or Controlled.
5254 if Lib_Ref_Symbol_File.Default then
5255 if Data.Symbol_Data.Symbol_Policy = Compliant
5256 or else Data.Symbol_Data.Symbol_Policy = Controlled
5260 "a reference symbol file need to be defined",
5261 Lib_Symbol_Policy.Location);
5265 -- Library_Reference_Symbol_File is defined, check file exists
5267 Data.Symbol_Data.Reference :=
5268 Path_Name_Type (Lib_Ref_Symbol_File.Value);
5270 Get_Name_String (Lib_Ref_Symbol_File.Value);
5272 if Name_Len = 0 then
5275 "reference symbol file name cannot be an empty string",
5276 Lib_Symbol_File.Location);
5279 if not Is_Absolute_Path (Name_Buffer (1 .. Name_Len)) then
5281 Add_Str_To_Name_Buffer
5282 (Get_Name_String (Data.Directory.Name));
5283 Add_Char_To_Name_Buffer (Directory_Separator);
5284 Add_Str_To_Name_Buffer
5285 (Get_Name_String (Lib_Ref_Symbol_File.Value));
5286 Data.Symbol_Data.Reference := Name_Find;
5289 if not Is_Regular_File
5290 (Get_Name_String (Data.Symbol_Data.Reference))
5293 File_Name_Type (Lib_Ref_Symbol_File.Value);
5295 -- For controlled and direct symbol policies, it is an error
5296 -- if the reference symbol file does not exist. For other
5297 -- symbol policies, this is just a warning
5300 Data.Symbol_Data.Symbol_Policy /= Controlled
5301 and then Data.Symbol_Data.Symbol_Policy /= Direct;
5305 "<library reference symbol file { does not exist",
5306 Lib_Ref_Symbol_File.Location);
5308 -- In addition in the non-controlled case, if symbol policy
5309 -- is Compliant, it is changed to Autonomous, because there
5310 -- is no reference to check against, and we don't want to
5311 -- fail in this case.
5313 if Data.Symbol_Data.Symbol_Policy /= Controlled then
5314 if Data.Symbol_Data.Symbol_Policy = Compliant then
5315 Data.Symbol_Data.Symbol_Policy := Autonomous;
5320 -- If both the reference symbol file and the symbol file are
5321 -- defined, then check that they are not the same file.
5323 if Data.Symbol_Data.Symbol_File /= No_Path then
5324 Get_Name_String (Data.Symbol_Data.Symbol_File);
5326 if Name_Len > 0 then
5328 Symb_Path : constant String :=
5331 (Data.Object_Directory.Name) &
5332 Directory_Separator &
5333 Name_Buffer (1 .. Name_Len),
5334 Directory => Current_Dir,
5336 Opt.Follow_Links_For_Files);
5337 Ref_Path : constant String :=
5340 (Data.Symbol_Data.Reference),
5341 Directory => Current_Dir,
5343 Opt.Follow_Links_For_Files);
5345 if Symb_Path = Ref_Path then
5348 "library reference symbol file and library" &
5349 " symbol file cannot be the same file",
5350 Lib_Ref_Symbol_File.Location);
5358 end Check_Stand_Alone_Library;
5360 ----------------------------
5361 -- Compute_Directory_Last --
5362 ----------------------------
5364 function Compute_Directory_Last (Dir : String) return Natural is
5367 and then (Dir (Dir'Last - 1) = Directory_Separator
5368 or else Dir (Dir'Last - 1) = '/')
5370 return Dir'Last - 1;
5374 end Compute_Directory_Last;
5381 (Project : Project_Id;
5382 In_Tree : Project_Tree_Ref;
5384 Flag_Location : Source_Ptr)
5386 Real_Location : Source_Ptr := Flag_Location;
5387 Error_Buffer : String (1 .. 5_000);
5388 Error_Last : Natural := 0;
5389 Name_Number : Natural := 0;
5390 File_Number : Natural := 0;
5391 First : Positive := Msg'First;
5394 procedure Add (C : Character);
5395 -- Add a character to the buffer
5397 procedure Add (S : String);
5398 -- Add a string to the buffer
5401 -- Add a name to the buffer
5404 -- Add a file name to the buffer
5410 procedure Add (C : Character) is
5412 Error_Last := Error_Last + 1;
5413 Error_Buffer (Error_Last) := C;
5416 procedure Add (S : String) is
5418 Error_Buffer (Error_Last + 1 .. Error_Last + S'Length) := S;
5419 Error_Last := Error_Last + S'Length;
5426 procedure Add_File is
5427 File : File_Name_Type;
5431 File_Number := File_Number + 1;
5435 File := Err_Vars.Error_Msg_File_1;
5437 File := Err_Vars.Error_Msg_File_2;
5439 File := Err_Vars.Error_Msg_File_3;
5444 Get_Name_String (File);
5445 Add (Name_Buffer (1 .. Name_Len));
5453 procedure Add_Name is
5458 Name_Number := Name_Number + 1;
5462 Name := Err_Vars.Error_Msg_Name_1;
5464 Name := Err_Vars.Error_Msg_Name_2;
5466 Name := Err_Vars.Error_Msg_Name_3;
5471 Get_Name_String (Name);
5472 Add (Name_Buffer (1 .. Name_Len));
5476 -- Start of processing for Error_Msg
5479 -- If location of error is unknown, use the location of the project
5481 if Real_Location = No_Location then
5482 Real_Location := In_Tree.Projects.Table (Project).Location;
5485 if Error_Report = null then
5486 Prj.Err.Error_Msg (Msg, Real_Location);
5490 -- Ignore continuation character
5492 if Msg (First) = '\' then
5496 -- Warning character is always the first one in this package
5497 -- this is an undocumented kludge???
5499 if Msg (First) = '?' then
5503 elsif Msg (First) = '<' then
5506 if Err_Vars.Error_Msg_Warn then
5512 while Index <= Msg'Last loop
5513 if Msg (Index) = '{' then
5516 elsif Msg (Index) = '%' then
5517 if Index < Msg'Last and then Msg (Index + 1) = '%' then
5529 Error_Report (Error_Buffer (1 .. Error_Last), Project, In_Tree);
5532 ----------------------
5533 -- Find_Ada_Sources --
5534 ----------------------
5536 procedure Find_Ada_Sources
5537 (Project : Project_Id;
5538 In_Tree : Project_Tree_Ref;
5539 Data : in out Project_Data;
5540 Current_Dir : String)
5542 Source_Dir : String_List_Id := Data.Source_Dirs;
5543 Element : String_Element;
5545 Current_Source : String_List_Id := Nil_String;
5546 Source_Recorded : Boolean := False;
5549 if Current_Verbosity = High then
5550 Write_Line ("Looking for sources:");
5553 -- For each subdirectory
5555 while Source_Dir /= Nil_String loop
5557 Source_Recorded := False;
5558 Element := In_Tree.String_Elements.Table (Source_Dir);
5559 if Element.Value /= No_Name then
5560 Get_Name_String (Element.Display_Value);
5563 Source_Directory : constant String :=
5564 Name_Buffer (1 .. Name_Len) & Directory_Separator;
5565 Dir_Last : constant Natural :=
5566 Compute_Directory_Last (Source_Directory);
5569 if Current_Verbosity = High then
5570 Write_Str ("Source_Dir = ");
5571 Write_Line (Source_Directory);
5574 -- We look at every entry in the source directory
5577 Source_Directory (Source_Directory'First .. Dir_Last));
5580 Read (Dir, Name_Buffer, Name_Len);
5582 if Current_Verbosity = High then
5583 Write_Str (" Checking ");
5584 Write_Line (Name_Buffer (1 .. Name_Len));
5587 exit when Name_Len = 0;
5590 File_Name : constant File_Name_Type := Name_Find;
5592 -- ??? We could probably optimize the following call:
5593 -- we need to resolve links only once for the
5594 -- directory itself, and then do a single call to
5595 -- readlink() for each file. Unfortunately that would
5596 -- require a change in Normalize_Pathname so that it
5597 -- has the option of not resolving links for its
5598 -- Directory parameter, only for Name.
5600 Path : constant String :=
5602 (Name => Name_Buffer (1 .. Name_Len),
5605 (Source_Directory'First .. Dir_Last),
5607 Opt.Follow_Links_For_Files,
5608 Case_Sensitive => True);
5610 Path_Name : Path_Name_Type;
5613 Name_Len := Path'Length;
5614 Name_Buffer (1 .. Name_Len) := Path;
5615 Path_Name := Name_Find;
5617 -- We attempt to register it as a source. However,
5618 -- there is no error if the file does not contain a
5619 -- valid source. But there is an error if we have a
5620 -- duplicate unit name.
5623 (File_Name => File_Name,
5624 Path_Name => Path_Name,
5628 Location => No_Location,
5629 Current_Source => Current_Source,
5630 Source_Recorded => Source_Recorded,
5631 Current_Dir => Current_Dir);
5640 when Directory_Error =>
5644 if Source_Recorded then
5645 In_Tree.String_Elements.Table (Source_Dir).Flag :=
5649 Source_Dir := Element.Next;
5652 if Current_Verbosity = High then
5653 Write_Line ("end Looking for sources.");
5656 end Find_Ada_Sources;
5658 --------------------------------
5659 -- Free_Ada_Naming_Exceptions --
5660 --------------------------------
5662 procedure Free_Ada_Naming_Exceptions is
5664 Ada_Naming_Exception_Table.Set_Last (0);
5665 Ada_Naming_Exceptions.Reset;
5666 Reverse_Ada_Naming_Exceptions.Reset;
5667 end Free_Ada_Naming_Exceptions;
5669 ---------------------
5670 -- Get_Directories --
5671 ---------------------
5673 procedure Get_Directories
5674 (Project : Project_Id;
5675 In_Tree : Project_Tree_Ref;
5676 Current_Dir : String;
5677 Data : in out Project_Data)
5679 Object_Dir : constant Variable_Value :=
5681 (Name_Object_Dir, Data.Decl.Attributes, In_Tree);
5683 Exec_Dir : constant Variable_Value :=
5685 (Name_Exec_Dir, Data.Decl.Attributes, In_Tree);
5687 Source_Dirs : constant Variable_Value :=
5689 (Name_Source_Dirs, Data.Decl.Attributes, In_Tree);
5691 Excluded_Source_Dirs : constant Variable_Value :=
5693 (Name_Excluded_Source_Dirs,
5694 Data.Decl.Attributes,
5697 Source_Files : constant Variable_Value :=
5699 (Name_Source_Files, Data.Decl.Attributes, In_Tree);
5701 Last_Source_Dir : String_List_Id := Nil_String;
5703 procedure Find_Source_Dirs
5704 (From : File_Name_Type;
5705 Location : Source_Ptr;
5706 Removed : Boolean := False);
5707 -- Find one or several source directories, and add (or remove, if
5708 -- Removed is True) them to list of source directories of the project.
5710 ----------------------
5711 -- Find_Source_Dirs --
5712 ----------------------
5714 procedure Find_Source_Dirs
5715 (From : File_Name_Type;
5716 Location : Source_Ptr;
5717 Removed : Boolean := False)
5719 Directory : constant String := Get_Name_String (From);
5720 Element : String_Element;
5722 procedure Recursive_Find_Dirs (Path : Name_Id);
5723 -- Find all the subdirectories (recursively) of Path and add them
5724 -- to the list of source directories of the project.
5726 -------------------------
5727 -- Recursive_Find_Dirs --
5728 -------------------------
5730 procedure Recursive_Find_Dirs (Path : Name_Id) is
5732 Name : String (1 .. 250);
5734 List : String_List_Id;
5735 Prev : String_List_Id;
5736 Element : String_Element;
5737 Found : Boolean := False;
5739 Non_Canonical_Path : Name_Id := No_Name;
5740 Canonical_Path : Name_Id := No_Name;
5742 The_Path : constant String :=
5744 (Get_Name_String (Path),
5745 Directory => Current_Dir,
5746 Resolve_Links => Opt.Follow_Links_For_Dirs) &
5747 Directory_Separator;
5749 The_Path_Last : constant Natural :=
5750 Compute_Directory_Last (The_Path);
5753 Name_Len := The_Path_Last - The_Path'First + 1;
5754 Name_Buffer (1 .. Name_Len) :=
5755 The_Path (The_Path'First .. The_Path_Last);
5756 Non_Canonical_Path := Name_Find;
5758 if Osint.File_Names_Case_Sensitive then
5759 Canonical_Path := Non_Canonical_Path;
5761 Get_Name_String (Non_Canonical_Path);
5762 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
5763 Canonical_Path := Name_Find;
5766 -- To avoid processing the same directory several times, check
5767 -- if the directory is already in Recursive_Dirs. If it is, then
5768 -- there is nothing to do, just return. If it is not, put it there
5769 -- and continue recursive processing.
5772 if Recursive_Dirs.Get (Canonical_Path) then
5775 Recursive_Dirs.Set (Canonical_Path, True);
5779 -- Check if directory is already in list
5781 List := Data.Source_Dirs;
5783 while List /= Nil_String loop
5784 Element := In_Tree.String_Elements.Table (List);
5786 if Element.Value /= No_Name then
5787 Found := Element.Value = Canonical_Path;
5792 List := Element.Next;
5795 -- If directory is not already in list, put it there
5797 if (not Removed) and (not Found) then
5798 if Current_Verbosity = High then
5800 Write_Line (The_Path (The_Path'First .. The_Path_Last));
5803 String_Element_Table.Increment_Last
5804 (In_Tree.String_Elements);
5806 (Value => Canonical_Path,
5807 Display_Value => Non_Canonical_Path,
5808 Location => No_Location,
5813 -- Case of first source directory
5815 if Last_Source_Dir = Nil_String then
5816 Data.Source_Dirs := String_Element_Table.Last
5817 (In_Tree.String_Elements);
5819 -- Here we already have source directories
5822 -- Link the previous last to the new one
5824 In_Tree.String_Elements.Table
5825 (Last_Source_Dir).Next :=
5826 String_Element_Table.Last
5827 (In_Tree.String_Elements);
5830 -- And register this source directory as the new last
5832 Last_Source_Dir := String_Element_Table.Last
5833 (In_Tree.String_Elements);
5834 In_Tree.String_Elements.Table (Last_Source_Dir) :=
5837 elsif Removed and Found then
5838 if Prev = Nil_String then
5840 In_Tree.String_Elements.Table (List).Next;
5842 In_Tree.String_Elements.Table (Prev).Next :=
5843 In_Tree.String_Elements.Table (List).Next;
5847 -- Now look for subdirectories. We do that even when this
5848 -- directory is already in the list, because some of its
5849 -- subdirectories may not be in the list yet.
5851 Open (Dir, The_Path (The_Path'First .. The_Path_Last));
5854 Read (Dir, Name, Last);
5857 if Name (1 .. Last) /= "."
5858 and then Name (1 .. Last) /= ".."
5860 -- Avoid . and .. directories
5862 if Current_Verbosity = High then
5863 Write_Str (" Checking ");
5864 Write_Line (Name (1 .. Last));
5868 Path_Name : constant String :=
5870 (Name => Name (1 .. Last),
5872 The_Path (The_Path'First .. The_Path_Last),
5873 Resolve_Links => Opt.Follow_Links_For_Dirs,
5874 Case_Sensitive => True);
5877 if Is_Directory (Path_Name) then
5878 -- We have found a new subdirectory, call self
5880 Name_Len := Path_Name'Length;
5881 Name_Buffer (1 .. Name_Len) := Path_Name;
5882 Recursive_Find_Dirs (Name_Find);
5891 when Directory_Error =>
5893 end Recursive_Find_Dirs;
5895 -- Start of processing for Find_Source_Dirs
5898 if Current_Verbosity = High and then not Removed then
5899 Write_Str ("Find_Source_Dirs (""");
5900 Write_Str (Directory);
5904 -- First, check if we are looking for a directory tree, indicated
5905 -- by "/**" at the end.
5907 if Directory'Length >= 3
5908 and then Directory (Directory'Last - 1 .. Directory'Last) = "**"
5909 and then (Directory (Directory'Last - 2) = '/'
5911 Directory (Directory'Last - 2) = Directory_Separator)
5914 Data.Known_Order_Of_Source_Dirs := False;
5917 Name_Len := Directory'Length - 3;
5919 if Name_Len = 0 then
5921 -- Case of "/**": all directories in file system
5924 Name_Buffer (1) := Directory (Directory'First);
5927 Name_Buffer (1 .. Name_Len) :=
5928 Directory (Directory'First .. Directory'Last - 3);
5931 if Current_Verbosity = High then
5932 Write_Str ("Looking for all subdirectories of """);
5933 Write_Str (Name_Buffer (1 .. Name_Len));
5938 Base_Dir : constant File_Name_Type := Name_Find;
5939 Root_Dir : constant String :=
5941 (Name => Get_Name_String (Base_Dir),
5943 Get_Name_String (Data.Directory.Display_Name),
5944 Resolve_Links => False,
5945 Case_Sensitive => True);
5948 if Root_Dir'Length = 0 then
5949 Err_Vars.Error_Msg_File_1 := Base_Dir;
5951 if Location = No_Location then
5954 "{ is not a valid directory.",
5959 "{ is not a valid directory.",
5964 -- We have an existing directory, we register it and all of
5965 -- its subdirectories.
5967 if Current_Verbosity = High then
5968 Write_Line ("Looking for source directories:");
5971 Name_Len := Root_Dir'Length;
5972 Name_Buffer (1 .. Name_Len) := Root_Dir;
5973 Recursive_Find_Dirs (Name_Find);
5975 if Current_Verbosity = High then
5976 Write_Line ("End of looking for source directories.");
5981 -- We have a single directory
5985 Path_Name : Path_Name_Type;
5986 Display_Path_Name : Path_Name_Type;
5987 List : String_List_Id;
5988 Prev : String_List_Id;
5992 (Project => Project,
5995 Parent => Data.Directory.Display_Name,
5997 Display => Display_Path_Name,
5998 Current_Dir => Current_Dir);
6000 if Path_Name = No_Path then
6001 Err_Vars.Error_Msg_File_1 := From;
6003 if Location = No_Location then
6006 "{ is not a valid directory",
6011 "{ is not a valid directory",
6017 Path : constant String :=
6018 Get_Name_String (Path_Name) &
6019 Directory_Separator;
6020 Last_Path : constant Natural :=
6021 Compute_Directory_Last (Path);
6023 Display_Path : constant String :=
6025 (Display_Path_Name) &
6026 Directory_Separator;
6027 Last_Display_Path : constant Natural :=
6028 Compute_Directory_Last
6030 Display_Path_Id : Name_Id;
6034 Add_Str_To_Name_Buffer (Path (Path'First .. Last_Path));
6035 Path_Id := Name_Find;
6037 Add_Str_To_Name_Buffer
6039 (Display_Path'First .. Last_Display_Path));
6040 Display_Path_Id := Name_Find;
6044 -- As it is an existing directory, we add it to the
6045 -- list of directories.
6047 String_Element_Table.Increment_Last
6048 (In_Tree.String_Elements);
6052 Display_Value => Display_Path_Id,
6053 Location => No_Location,
6055 Next => Nil_String);
6057 if Last_Source_Dir = Nil_String then
6059 -- This is the first source directory
6061 Data.Source_Dirs := String_Element_Table.Last
6062 (In_Tree.String_Elements);
6065 -- We already have source directories, link the
6066 -- previous last to the new one.
6068 In_Tree.String_Elements.Table
6069 (Last_Source_Dir).Next :=
6070 String_Element_Table.Last
6071 (In_Tree.String_Elements);
6074 -- And register this source directory as the new last
6076 Last_Source_Dir := String_Element_Table.Last
6077 (In_Tree.String_Elements);
6078 In_Tree.String_Elements.Table
6079 (Last_Source_Dir) := Element;
6082 -- Remove source dir, if present
6084 List := Data.Source_Dirs;
6087 -- Look for source dir in current list
6089 while List /= Nil_String loop
6090 Element := In_Tree.String_Elements.Table (List);
6091 exit when Element.Value = Path_Id;
6093 List := Element.Next;
6096 if List /= Nil_String then
6097 -- Source dir was found, remove it from the list
6099 if Prev = Nil_String then
6101 In_Tree.String_Elements.Table (List).Next;
6104 In_Tree.String_Elements.Table (Prev).Next :=
6105 In_Tree.String_Elements.Table (List).Next;
6113 end Find_Source_Dirs;
6115 -- Start of processing for Get_Directories
6118 if Current_Verbosity = High then
6119 Write_Line ("Starting to look for directories");
6122 -- Check the object directory
6124 pragma Assert (Object_Dir.Kind = Single,
6125 "Object_Dir is not a single string");
6127 -- We set the object directory to its default
6129 Data.Object_Directory := Data.Directory;
6131 if Object_Dir.Value /= Empty_String then
6132 Get_Name_String (Object_Dir.Value);
6134 if Name_Len = 0 then
6137 "Object_Dir cannot be empty",
6138 Object_Dir.Location);
6141 -- We check that the specified object directory does exist
6146 File_Name_Type (Object_Dir.Value),
6147 Data.Directory.Display_Name,
6148 Data.Object_Directory.Name,
6149 Data.Object_Directory.Display_Name,
6151 Location => Object_Dir.Location,
6152 Current_Dir => Current_Dir);
6154 if Data.Object_Directory = No_Path_Information then
6156 -- The object directory does not exist, report an error if the
6157 -- project is not externally built.
6159 if not Data.Externally_Built then
6160 Err_Vars.Error_Msg_File_1 :=
6161 File_Name_Type (Object_Dir.Value);
6164 "the object directory { cannot be found",
6168 -- Do not keep a nil Object_Directory. Set it to the specified
6169 -- (relative or absolute) path. This is for the benefit of
6170 -- tools that recover from errors; for example, these tools
6171 -- could create the non existent directory.
6173 Data.Object_Directory.Display_Name :=
6174 Path_Name_Type (Object_Dir.Value);
6176 if Osint.File_Names_Case_Sensitive then
6177 Data.Object_Directory.Name :=
6178 Path_Name_Type (Object_Dir.Value);
6180 Get_Name_String (Object_Dir.Value);
6181 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
6182 Data.Object_Directory.Name := Name_Find;
6187 elsif Subdirs /= null then
6189 Name_Buffer (1) := '.';
6194 Data.Directory.Display_Name,
6195 Data.Object_Directory.Name,
6196 Data.Object_Directory.Display_Name,
6198 Location => Object_Dir.Location,
6199 Current_Dir => Current_Dir);
6202 if Current_Verbosity = High then
6203 if Data.Object_Directory = No_Path_Information then
6204 Write_Line ("No object directory");
6206 Write_Str ("Object directory: """);
6207 Write_Str (Get_Name_String (Data.Object_Directory.Display_Name));
6212 -- Check the exec directory
6214 pragma Assert (Exec_Dir.Kind = Single,
6215 "Exec_Dir is not a single string");
6217 -- We set the object directory to its default
6219 Data.Exec_Directory := Data.Object_Directory;
6221 if Exec_Dir.Value /= Empty_String then
6222 Get_Name_String (Exec_Dir.Value);
6224 if Name_Len = 0 then
6227 "Exec_Dir cannot be empty",
6231 -- We check that the specified exec directory does exist
6236 File_Name_Type (Exec_Dir.Value),
6237 Data.Directory.Display_Name,
6238 Data.Exec_Directory.Name,
6239 Data.Exec_Directory.Display_Name,
6241 Location => Exec_Dir.Location,
6242 Current_Dir => Current_Dir);
6244 if Data.Exec_Directory = No_Path_Information then
6245 Err_Vars.Error_Msg_File_1 := File_Name_Type (Exec_Dir.Value);
6248 "the exec directory { cannot be found",
6254 if Current_Verbosity = High then
6255 if Data.Exec_Directory = No_Path_Information then
6256 Write_Line ("No exec directory");
6258 Write_Str ("Exec directory: """);
6259 Write_Str (Get_Name_String (Data.Exec_Directory.Display_Name));
6264 -- Look for the source directories
6266 if Current_Verbosity = High then
6267 Write_Line ("Starting to look for source directories");
6270 pragma Assert (Source_Dirs.Kind = List, "Source_Dirs is not a list");
6272 if (not Source_Files.Default) and then
6273 Source_Files.Values = Nil_String
6275 Data.Source_Dirs := Nil_String;
6277 if Data.Qualifier = Standard then
6281 "a standard project cannot have no sources",
6282 Source_Files.Location);
6285 if Data.Extends = No_Project
6286 and then Data.Object_Directory = Data.Directory
6288 Data.Object_Directory := No_Path_Information;
6291 elsif Source_Dirs.Default then
6293 -- No Source_Dirs specified: the single source directory is the one
6294 -- containing the project file
6296 String_Element_Table.Increment_Last
6297 (In_Tree.String_Elements);
6298 Data.Source_Dirs := String_Element_Table.Last
6299 (In_Tree.String_Elements);
6300 In_Tree.String_Elements.Table (Data.Source_Dirs) :=
6301 (Value => Name_Id (Data.Directory.Name),
6302 Display_Value => Name_Id (Data.Directory.Display_Name),
6303 Location => No_Location,
6308 if Current_Verbosity = High then
6309 Write_Line ("Single source directory:");
6311 Write_Str (Get_Name_String (Data.Directory.Display_Name));
6315 elsif Source_Dirs.Values = Nil_String then
6316 if Data.Qualifier = Standard then
6320 "a standard project cannot have no source directories",
6321 Source_Dirs.Location);
6324 -- If Source_Dirs is an empty string list, this means that this
6325 -- project contains no source. For projects that don't extend other
6326 -- projects, this also means that there is no need for an object
6327 -- directory, if not specified.
6329 if Data.Extends = No_Project
6330 and then Data.Object_Directory = Data.Directory
6332 Data.Object_Directory := No_Path_Information;
6335 Data.Source_Dirs := Nil_String;
6339 Source_Dir : String_List_Id;
6340 Element : String_Element;
6343 -- Process the source directories for each element of the list
6345 Source_Dir := Source_Dirs.Values;
6346 while Source_Dir /= Nil_String loop
6347 Element := In_Tree.String_Elements.Table (Source_Dir);
6349 (File_Name_Type (Element.Value), Element.Location);
6350 Source_Dir := Element.Next;
6355 if not Excluded_Source_Dirs.Default
6356 and then Excluded_Source_Dirs.Values /= Nil_String
6359 Source_Dir : String_List_Id;
6360 Element : String_Element;
6363 -- Process the source directories for each element of the list
6365 Source_Dir := Excluded_Source_Dirs.Values;
6366 while Source_Dir /= Nil_String loop
6367 Element := In_Tree.String_Elements.Table (Source_Dir);
6369 (File_Name_Type (Element.Value),
6372 Source_Dir := Element.Next;
6377 if Current_Verbosity = High then
6378 Write_Line ("Putting source directories in canonical cases");
6382 Current : String_List_Id := Data.Source_Dirs;
6383 Element : String_Element;
6386 while Current /= Nil_String loop
6387 Element := In_Tree.String_Elements.Table (Current);
6388 if Element.Value /= No_Name then
6389 if not Osint.File_Names_Case_Sensitive then
6390 Get_Name_String (Element.Value);
6391 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
6392 Element.Value := Name_Find;
6395 In_Tree.String_Elements.Table (Current) := Element;
6398 Current := Element.Next;
6402 end Get_Directories;
6409 (Project : Project_Id;
6410 In_Tree : Project_Tree_Ref;
6411 Data : in out Project_Data)
6413 Mains : constant Variable_Value :=
6414 Prj.Util.Value_Of (Name_Main, Data.Decl.Attributes, In_Tree);
6417 Data.Mains := Mains.Values;
6419 -- If no Mains were specified, and if we are an extending project,
6420 -- inherit the Mains from the project we are extending.
6422 if Mains.Default then
6423 if not Data.Library and then Data.Extends /= No_Project then
6425 In_Tree.Projects.Table (Data.Extends).Mains;
6428 -- In a library project file, Main cannot be specified
6430 elsif Data.Library then
6433 "a library project file cannot have Main specified",
6438 ---------------------------
6439 -- Get_Sources_From_File --
6440 ---------------------------
6442 procedure Get_Sources_From_File
6444 Location : Source_Ptr;
6445 Project : Project_Id;
6446 In_Tree : Project_Tree_Ref)
6448 File : Prj.Util.Text_File;
6449 Line : String (1 .. 250);
6451 Source_Name : File_Name_Type;
6452 Name_Loc : Name_Location;
6455 if Get_Mode = Ada_Only then
6459 if Current_Verbosity = High then
6460 Write_Str ("Opening """);
6467 Prj.Util.Open (File, Path);
6469 if not Prj.Util.Is_Valid (File) then
6470 Error_Msg (Project, In_Tree, "file does not exist", Location);
6473 -- Read the lines one by one
6475 while not Prj.Util.End_Of_File (File) loop
6476 Prj.Util.Get_Line (File, Line, Last);
6478 -- A non empty, non comment line should contain a file name
6481 and then (Last = 1 or else Line (1 .. 2) /= "--")
6484 Name_Buffer (1 .. Name_Len) := Line (1 .. Last);
6485 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
6486 Source_Name := Name_Find;
6488 -- Check that there is no directory information
6490 for J in 1 .. Last loop
6491 if Line (J) = '/' or else Line (J) = Directory_Separator then
6492 Error_Msg_File_1 := Source_Name;
6496 "file name cannot include directory information ({)",
6502 Name_Loc := Source_Names.Get (Source_Name);
6504 if Name_Loc = No_Name_Location then
6506 (Name => Source_Name,
6507 Location => Location,
6508 Source => No_Source,
6513 Source_Names.Set (Source_Name, Name_Loc);
6517 Prj.Util.Close (File);
6520 end Get_Sources_From_File;
6527 (In_Tree : Project_Tree_Ref;
6528 Canonical_File_Name : File_Name_Type;
6529 Naming : Naming_Data;
6530 Exception_Id : out Ada_Naming_Exception_Id;
6531 Unit_Name : out Name_Id;
6532 Unit_Kind : out Spec_Or_Body;
6533 Needs_Pragma : out Boolean)
6535 Info_Id : Ada_Naming_Exception_Id :=
6536 Ada_Naming_Exceptions.Get (Canonical_File_Name);
6537 VMS_Name : File_Name_Type;
6540 if Info_Id = No_Ada_Naming_Exception then
6541 if Hostparm.OpenVMS then
6542 VMS_Name := Canonical_File_Name;
6543 Get_Name_String (VMS_Name);
6545 if Name_Buffer (Name_Len) = '.' then
6546 Name_Len := Name_Len - 1;
6547 VMS_Name := Name_Find;
6550 Info_Id := Ada_Naming_Exceptions.Get (VMS_Name);
6555 if Info_Id /= No_Ada_Naming_Exception then
6556 Exception_Id := Info_Id;
6557 Unit_Name := No_Name;
6558 Unit_Kind := Specification;
6559 Needs_Pragma := True;
6563 Needs_Pragma := False;
6564 Exception_Id := No_Ada_Naming_Exception;
6566 Get_Name_String (Canonical_File_Name);
6568 -- How about some comments and a name for this declare block ???
6569 -- In fact the whole code below needs more comments ???
6572 File : String := Name_Buffer (1 .. Name_Len);
6573 First : constant Positive := File'First;
6574 Last : Natural := File'Last;
6575 Standard_GNAT : Boolean;
6576 Spec : constant File_Name_Type :=
6577 Spec_Suffix_Id_Of (In_Tree, Name_Ada, Naming);
6578 Body_Suff : constant File_Name_Type :=
6579 Body_Suffix_Id_Of (In_Tree, Name_Ada, Naming);
6582 Standard_GNAT := Spec = Default_Ada_Spec_Suffix
6583 and then Body_Suff = Default_Ada_Body_Suffix;
6586 Spec_Suffix : constant String := Get_Name_String (Spec);
6587 Body_Suffix : constant String := Get_Name_String (Body_Suff);
6588 Sep_Suffix : constant String :=
6589 Get_Name_String (Naming.Separate_Suffix);
6591 May_Be_Spec : Boolean;
6592 May_Be_Body : Boolean;
6593 May_Be_Sep : Boolean;
6597 File'Length > Spec_Suffix'Length
6599 File (Last - Spec_Suffix'Length + 1 .. Last) = Spec_Suffix;
6602 File'Length > Body_Suffix'Length
6604 File (Last - Body_Suffix'Length + 1 .. Last) = Body_Suffix;
6607 File'Length > Sep_Suffix'Length
6609 File (Last - Sep_Suffix'Length + 1 .. Last) = Sep_Suffix;
6611 -- If two May_Be_ booleans are True, always choose the longer one
6614 if May_Be_Body and then
6615 Spec_Suffix'Length < Body_Suffix'Length
6617 Unit_Kind := Body_Part;
6619 if May_Be_Sep and then
6620 Body_Suffix'Length < Sep_Suffix'Length
6622 Last := Last - Sep_Suffix'Length;
6623 May_Be_Body := False;
6626 Last := Last - Body_Suffix'Length;
6627 May_Be_Sep := False;
6630 elsif May_Be_Sep and then
6631 Spec_Suffix'Length < Sep_Suffix'Length
6633 Unit_Kind := Body_Part;
6634 Last := Last - Sep_Suffix'Length;
6637 Unit_Kind := Specification;
6638 Last := Last - Spec_Suffix'Length;
6641 elsif May_Be_Body then
6642 Unit_Kind := Body_Part;
6644 if May_Be_Sep and then
6645 Body_Suffix'Length < Sep_Suffix'Length
6647 Last := Last - Sep_Suffix'Length;
6648 May_Be_Body := False;
6650 Last := Last - Body_Suffix'Length;
6651 May_Be_Sep := False;
6654 elsif May_Be_Sep then
6655 Unit_Kind := Body_Part;
6656 Last := Last - Sep_Suffix'Length;
6664 -- This is not a source file
6666 Unit_Name := No_Name;
6667 Unit_Kind := Specification;
6669 if Current_Verbosity = High then
6670 Write_Line (" Not a valid file name.");
6675 elsif Current_Verbosity = High then
6677 when Specification =>
6678 Write_Str (" Specification: ");
6679 Write_Line (File (First .. Last + Spec_Suffix'Length));
6683 Write_Str (" Body: ");
6684 Write_Line (File (First .. Last + Body_Suffix'Length));
6687 Write_Str (" Separate: ");
6688 Write_Line (File (First .. Last + Sep_Suffix'Length));
6694 Get_Name_String (Naming.Dot_Replacement);
6696 Standard_GNAT and then Name_Buffer (1 .. Name_Len) = "-";
6698 if Name_Buffer (1 .. Name_Len) /= "." then
6700 -- If Dot_Replacement is not a single dot, then there should not
6701 -- be any dot in the name.
6703 for Index in First .. Last loop
6704 if File (Index) = '.' then
6705 if Current_Verbosity = High then
6707 (" Not a valid file name (some dot not replaced).");
6710 Unit_Name := No_Name;
6716 -- Replace the substring Dot_Replacement with dots
6719 Index : Positive := First;
6722 while Index <= Last - Name_Len + 1 loop
6724 if File (Index .. Index + Name_Len - 1) =
6725 Name_Buffer (1 .. Name_Len)
6727 File (Index) := '.';
6729 if Name_Len > 1 and then Index < Last then
6730 File (Index + 1 .. Last - Name_Len + 1) :=
6731 File (Index + Name_Len .. Last);
6734 Last := Last - Name_Len + 1;
6742 -- Check if the casing is right
6745 Src : String := File (First .. Last);
6746 Src_Last : Positive := Last;
6749 case Naming.Casing is
6750 when All_Lower_Case =>
6753 Mapping => Lower_Case_Map);
6755 when All_Upper_Case =>
6758 Mapping => Upper_Case_Map);
6760 when Mixed_Case | Unknown =>
6764 if Src /= File (First .. Last) then
6765 if Current_Verbosity = High then
6766 Write_Line (" Not a valid file name (casing).");
6769 Unit_Name := No_Name;
6773 -- We put the name in lower case
6777 Mapping => Lower_Case_Map);
6779 -- In the standard GNAT naming scheme, check for special cases:
6780 -- children or separates of A, G, I or S, and run time sources.
6782 if Standard_GNAT and then Src'Length >= 3 then
6784 S1 : constant Character := Src (Src'First);
6785 S2 : constant Character := Src (Src'First + 1);
6786 S3 : constant Character := Src (Src'First + 2);
6794 -- Children or separates of packages A, G, I or S. These
6795 -- names are x__ ... or x~... (where x is a, g, i, or s).
6796 -- Both versions (x__... and x~...) are allowed in all
6797 -- platforms, because it is not possible to know the
6798 -- platform before processing of the project files.
6800 if S2 = '_' and then S3 = '_' then
6801 Src (Src'First + 1) := '.';
6802 Src_Last := Src_Last - 1;
6803 Src (Src'First + 2 .. Src_Last) :=
6804 Src (Src'First + 3 .. Src_Last + 1);
6807 Src (Src'First + 1) := '.';
6809 -- If it is potentially a run time source, disable
6810 -- filling of the mapping file to avoid warnings.
6813 Set_Mapping_File_Initial_State_To_Empty;
6819 if Current_Verbosity = High then
6821 Write_Line (Src (Src'First .. Src_Last));
6824 -- Now, we check if this name is a valid unit name
6827 (Name => Src (Src'First .. Src_Last), Unit => Unit_Name);
6837 function Hash (Unit : Unit_Info) return Header_Num is
6839 return Header_Num (Unit.Unit mod 2048);
6842 -----------------------
6843 -- Is_Illegal_Suffix --
6844 -----------------------
6846 function Is_Illegal_Suffix
6848 Dot_Replacement_Is_A_Single_Dot : Boolean) return Boolean
6851 if Suffix'Length = 0 or else Index (Suffix, ".") = 0 then
6855 -- If dot replacement is a single dot, and first character of suffix is
6858 if Dot_Replacement_Is_A_Single_Dot
6859 and then Suffix (Suffix'First) = '.'
6861 for Index in Suffix'First + 1 .. Suffix'Last loop
6863 -- If there is another dot
6865 if Suffix (Index) = '.' then
6867 -- It is illegal to have a letter following the initial dot
6869 return Is_Letter (Suffix (Suffix'First + 1));
6877 end Is_Illegal_Suffix;
6879 ----------------------
6880 -- Locate_Directory --
6881 ----------------------
6883 procedure Locate_Directory
6884 (Project : Project_Id;
6885 In_Tree : Project_Tree_Ref;
6886 Name : File_Name_Type;
6887 Parent : Path_Name_Type;
6888 Dir : out Path_Name_Type;
6889 Display : out Path_Name_Type;
6890 Create : String := "";
6891 Current_Dir : String;
6892 Location : Source_Ptr := No_Location)
6894 The_Parent : constant String :=
6895 Get_Name_String (Parent) & Directory_Separator;
6897 The_Parent_Last : constant Natural :=
6898 Compute_Directory_Last (The_Parent);
6900 Full_Name : File_Name_Type;
6902 The_Name : File_Name_Type;
6905 Get_Name_String (Name);
6907 -- Add Subdirs.all if it is a directory that may be created and
6908 -- Subdirs is not null;
6910 if Create /= "" and then Subdirs /= null then
6911 if Name_Buffer (Name_Len) /= Directory_Separator then
6912 Add_Char_To_Name_Buffer (Directory_Separator);
6915 Add_Str_To_Name_Buffer (Subdirs.all);
6918 -- Convert '/' to directory separator (for Windows)
6920 for J in 1 .. Name_Len loop
6921 if Name_Buffer (J) = '/' then
6922 Name_Buffer (J) := Directory_Separator;
6926 The_Name := Name_Find;
6928 if Current_Verbosity = High then
6929 Write_Str ("Locate_Directory (""");
6930 Write_Str (Get_Name_String (The_Name));
6931 Write_Str (""", """);
6932 Write_Str (The_Parent);
6939 if Is_Absolute_Path (Get_Name_String (The_Name)) then
6940 Full_Name := The_Name;
6944 Add_Str_To_Name_Buffer
6945 (The_Parent (The_Parent'First .. The_Parent_Last));
6946 Add_Str_To_Name_Buffer (Get_Name_String (The_Name));
6947 Full_Name := Name_Find;
6951 Full_Path_Name : constant String := Get_Name_String (Full_Name);
6954 if (Setup_Projects or else Subdirs /= null)
6955 and then Create'Length > 0
6956 and then not Is_Directory (Full_Path_Name)
6959 Create_Path (Full_Path_Name);
6961 if not Quiet_Output then
6963 Write_Str (" directory """);
6964 Write_Str (Full_Path_Name);
6965 Write_Line (""" created");
6972 "could not create " & Create &
6973 " directory " & Full_Path_Name,
6978 if Is_Directory (Full_Path_Name) then
6980 Normed : constant String :=
6983 Directory => Current_Dir,
6984 Resolve_Links => False,
6985 Case_Sensitive => True);
6987 Canonical_Path : constant String :=
6990 Directory => Current_Dir,
6992 Opt.Follow_Links_For_Dirs,
6993 Case_Sensitive => False);
6996 Name_Len := Normed'Length;
6997 Name_Buffer (1 .. Name_Len) := Normed;
6998 Display := Name_Find;
7000 Name_Len := Canonical_Path'Length;
7001 Name_Buffer (1 .. Name_Len) := Canonical_Path;
7006 end Locate_Directory;
7008 ---------------------------
7009 -- Find_Excluded_Sources --
7010 ---------------------------
7012 procedure Find_Excluded_Sources
7013 (Project : Project_Id;
7014 In_Tree : Project_Tree_Ref;
7015 Data : Project_Data)
7017 Excluded_Sources : Variable_Value;
7019 Excluded_Source_List_File : Variable_Value;
7021 Current : String_List_Id;
7023 Element : String_Element;
7025 Location : Source_Ptr;
7027 Name : File_Name_Type;
7029 File : Prj.Util.Text_File;
7030 Line : String (1 .. 300);
7033 Locally_Removed : Boolean := False;
7035 Excluded_Source_List_File :=
7037 (Name_Excluded_Source_List_File, Data.Decl.Attributes, In_Tree);
7041 (Name_Excluded_Source_Files, Data.Decl.Attributes, In_Tree);
7043 -- If Excluded_Source_Files is not declared, check
7044 -- Locally_Removed_Files.
7046 if Excluded_Sources.Default then
7047 Locally_Removed := True;
7050 (Name_Locally_Removed_Files, Data.Decl.Attributes, In_Tree);
7053 Excluded_Sources_Htable.Reset;
7055 -- If there are excluded sources, put them in the table
7057 if not Excluded_Sources.Default then
7058 if not Excluded_Source_List_File.Default then
7059 if Locally_Removed then
7062 "?both attributes Locally_Removed_Files and " &
7063 "Excluded_Source_List_File are present",
7064 Excluded_Source_List_File.Location);
7068 "?both attributes Excluded_Source_Files and " &
7069 "Excluded_Source_List_File are present",
7070 Excluded_Source_List_File.Location);
7074 Current := Excluded_Sources.Values;
7075 while Current /= Nil_String loop
7076 Element := In_Tree.String_Elements.Table (Current);
7078 if Osint.File_Names_Case_Sensitive then
7079 Name := File_Name_Type (Element.Value);
7081 Get_Name_String (Element.Value);
7082 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
7086 -- If the element has no location, then use the location
7087 -- of Excluded_Sources to report possible errors.
7089 if Element.Location = No_Location then
7090 Location := Excluded_Sources.Location;
7092 Location := Element.Location;
7095 Excluded_Sources_Htable.Set (Name, (Name, False, Location));
7096 Current := Element.Next;
7099 elsif not Excluded_Source_List_File.Default then
7100 Location := Excluded_Source_List_File.Location;
7103 Source_File_Path_Name : constant String :=
7106 (Excluded_Source_List_File.Value),
7107 Data.Directory.Name);
7110 if Source_File_Path_Name'Length = 0 then
7111 Err_Vars.Error_Msg_File_1 :=
7112 File_Name_Type (Excluded_Source_List_File.Value);
7115 "file with excluded sources { does not exist",
7116 Excluded_Source_List_File.Location);
7121 Prj.Util.Open (File, Source_File_Path_Name);
7123 if not Prj.Util.Is_Valid (File) then
7125 (Project, In_Tree, "file does not exist", Location);
7127 -- Read the lines one by one
7129 while not Prj.Util.End_Of_File (File) loop
7130 Prj.Util.Get_Line (File, Line, Last);
7132 -- A non empty, non comment line should contain a file
7136 and then (Last = 1 or else Line (1 .. 2) /= "--")
7139 Name_Buffer (1 .. Name_Len) := Line (1 .. Last);
7140 Canonical_Case_File_Name
7141 (Name_Buffer (1 .. Name_Len));
7144 -- Check that there is no directory information
7146 for J in 1 .. Last loop
7148 or else Line (J) = Directory_Separator
7150 Error_Msg_File_1 := Name;
7154 "file name cannot include " &
7155 "directory information ({)",
7161 Excluded_Sources_Htable.Set
7162 (Name, (Name, False, Location));
7166 Prj.Util.Close (File);
7171 end Find_Excluded_Sources;
7173 ---------------------------
7174 -- Find_Explicit_Sources --
7175 ---------------------------
7177 procedure Find_Explicit_Sources
7178 (Current_Dir : String;
7179 Project : Project_Id;
7180 In_Tree : Project_Tree_Ref;
7181 Data : in out Project_Data)
7183 Sources : constant Variable_Value :=
7186 Data.Decl.Attributes,
7188 Source_List_File : constant Variable_Value :=
7190 (Name_Source_List_File,
7191 Data.Decl.Attributes,
7193 Name_Loc : Name_Location;
7196 pragma Assert (Sources.Kind = List, "Source_Files is not a list");
7198 (Source_List_File.Kind = Single,
7199 "Source_List_File is not a single string");
7201 -- If the user has specified a Sources attribute
7203 if not Sources.Default then
7204 if not Source_List_File.Default then
7207 "?both attributes source_files and " &
7208 "source_list_file are present",
7209 Source_List_File.Location);
7212 -- Sources is a list of file names
7215 Current : String_List_Id := Sources.Values;
7216 Element : String_Element;
7217 Location : Source_Ptr;
7218 Name : File_Name_Type;
7221 if Get_Mode = Ada_Only then
7222 Data.Ada_Sources_Present := Current /= Nil_String;
7225 if Get_Mode = Multi_Language then
7226 if Current = Nil_String then
7227 Data.First_Language_Processing := No_Language_Index;
7229 -- This project contains no source. For projects that
7230 -- don't extend other projects, this also means that
7231 -- there is no need for an object directory, if not
7234 if Data.Extends = No_Project
7235 and then Data.Object_Directory = Data.Directory
7237 Data.Object_Directory := No_Path_Information;
7242 while Current /= Nil_String loop
7243 Element := In_Tree.String_Elements.Table (Current);
7244 Get_Name_String (Element.Value);
7246 if Osint.File_Names_Case_Sensitive then
7247 Name := File_Name_Type (Element.Value);
7249 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
7253 -- If the element has no location, then use the
7254 -- location of Sources to report possible errors.
7256 if Element.Location = No_Location then
7257 Location := Sources.Location;
7259 Location := Element.Location;
7262 -- Check that there is no directory information
7264 for J in 1 .. Name_Len loop
7265 if Name_Buffer (J) = '/'
7266 or else Name_Buffer (J) = Directory_Separator
7268 Error_Msg_File_1 := Name;
7272 "file name cannot include directory " &
7279 -- In Multi_Language mode, check whether the file is
7280 -- already there: the same file name may be in the list; if
7281 -- the source is missing, the error will be on the first
7282 -- mention of the source file name.
7286 Name_Loc := No_Name_Location;
7287 when Multi_Language =>
7288 Name_Loc := Source_Names.Get (Name);
7291 if Name_Loc = No_Name_Location then
7294 Location => Location,
7295 Source => No_Source,
7298 Source_Names.Set (Name, Name_Loc);
7301 Current := Element.Next;
7304 if Get_Mode = Ada_Only then
7305 Get_Path_Names_And_Record_Ada_Sources
7306 (Project, In_Tree, Data, Current_Dir);
7310 -- If we have no Source_Files attribute, check the Source_List_File
7313 elsif not Source_List_File.Default then
7315 -- Source_List_File is the name of the file
7316 -- that contains the source file names
7319 Source_File_Path_Name : constant String :=
7321 (File_Name_Type (Source_List_File.Value), Data.Directory.Name);
7324 if Source_File_Path_Name'Length = 0 then
7325 Err_Vars.Error_Msg_File_1 :=
7326 File_Name_Type (Source_List_File.Value);
7329 "file with sources { does not exist",
7330 Source_List_File.Location);
7333 Get_Sources_From_File
7334 (Source_File_Path_Name, Source_List_File.Location,
7337 if Get_Mode = Ada_Only then
7338 -- Look in the source directories to find those sources
7340 Get_Path_Names_And_Record_Ada_Sources
7341 (Project, In_Tree, Data, Current_Dir);
7347 -- Neither Source_Files nor Source_List_File has been
7348 -- specified. Find all the files that satisfy the naming
7349 -- scheme in all the source directories.
7351 if Get_Mode = Ada_Only then
7352 Find_Ada_Sources (Project, In_Tree, Data, Current_Dir);
7356 if Get_Mode = Multi_Language then
7358 (Project, In_Tree, Data,
7360 Sources.Default and then Source_List_File.Default);
7362 -- Check if all exceptions have been found.
7363 -- For Ada, it is an error if an exception is not found.
7364 -- For other language, the source is simply removed.
7368 Src_Data : Source_Data;
7371 Source := Data.First_Source;
7372 while Source /= No_Source loop
7373 Src_Data := In_Tree.Sources.Table (Source);
7375 if Src_Data.Naming_Exception
7376 and then Src_Data.Path = No_Path_Information
7378 if Src_Data.Unit /= No_Name then
7379 Error_Msg_Name_1 := Name_Id (Src_Data.Display_File);
7380 Error_Msg_Name_2 := Name_Id (Src_Data.Unit);
7383 "source file %% for unit %% not found",
7387 Remove_Source (Source, No_Source, Project, Data, In_Tree);
7390 Source := Src_Data.Next_In_Project;
7394 -- Check that all sources in Source_Files or the file
7395 -- Source_List_File has been found.
7398 Name_Loc : Name_Location;
7401 Name_Loc := Source_Names.Get_First;
7402 while Name_Loc /= No_Name_Location loop
7403 if (not Name_Loc.Except) and then (not Name_Loc.Found) then
7404 Error_Msg_Name_1 := Name_Id (Name_Loc.Name);
7408 "file %% not found",
7412 Name_Loc := Source_Names.Get_Next;
7417 if Get_Mode = Ada_Only
7418 and then Data.Extends = No_Project
7420 -- We should have found at least one source, if not report an error
7422 if Data.Ada_Sources = Nil_String then
7424 (Project, "Ada", In_Tree, Source_List_File.Location);
7428 end Find_Explicit_Sources;
7430 -------------------------------------------
7431 -- Get_Path_Names_And_Record_Ada_Sources --
7432 -------------------------------------------
7434 procedure Get_Path_Names_And_Record_Ada_Sources
7435 (Project : Project_Id;
7436 In_Tree : Project_Tree_Ref;
7437 Data : in out Project_Data;
7438 Current_Dir : String)
7440 Source_Dir : String_List_Id;
7441 Element : String_Element;
7442 Path : Path_Name_Type;
7444 Name : File_Name_Type;
7445 Canonical_Name : File_Name_Type;
7446 Name_Str : String (1 .. 1_024);
7447 Last : Natural := 0;
7449 Current_Source : String_List_Id := Nil_String;
7450 First_Error : Boolean := True;
7451 Source_Recorded : Boolean := False;
7454 -- We look in all source directories for the file names in the hash
7455 -- table Source_Names.
7457 Source_Dir := Data.Source_Dirs;
7458 while Source_Dir /= Nil_String loop
7459 Source_Recorded := False;
7460 Element := In_Tree.String_Elements.Table (Source_Dir);
7463 Dir_Path : constant String :=
7464 Get_Name_String (Element.Display_Value);
7466 if Current_Verbosity = High then
7467 Write_Str ("checking directory """);
7468 Write_Str (Dir_Path);
7472 Open (Dir, Dir_Path);
7475 Read (Dir, Name_Str, Last);
7479 Name_Buffer (1 .. Name_Len) := Name_Str (1 .. Last);
7482 if Osint.File_Names_Case_Sensitive then
7483 Canonical_Name := Name;
7485 Canonical_Case_File_Name (Name_Str (1 .. Last));
7486 Name_Buffer (1 .. Name_Len) := Name_Str (1 .. Last);
7487 Canonical_Name := Name_Find;
7490 NL := Source_Names.Get (Canonical_Name);
7492 if NL /= No_Name_Location and then not NL.Found then
7494 Source_Names.Set (Canonical_Name, NL);
7495 Name_Len := Dir_Path'Length;
7496 Name_Buffer (1 .. Name_Len) := Dir_Path;
7498 if Name_Buffer (Name_Len) /= Directory_Separator then
7499 Add_Char_To_Name_Buffer (Directory_Separator);
7502 Add_Str_To_Name_Buffer (Name_Str (1 .. Last));
7505 if Current_Verbosity = High then
7506 Write_Str (" found ");
7507 Write_Line (Get_Name_String (Name));
7510 -- Register the source if it is an Ada compilation unit
7518 Location => NL.Location,
7519 Current_Source => Current_Source,
7520 Source_Recorded => Source_Recorded,
7521 Current_Dir => Current_Dir);
7528 if Source_Recorded then
7529 In_Tree.String_Elements.Table (Source_Dir).Flag :=
7533 Source_Dir := Element.Next;
7536 -- It is an error if a source file name in a source list or
7537 -- in a source list file is not found.
7539 NL := Source_Names.Get_First;
7540 while NL /= No_Name_Location loop
7541 if not NL.Found then
7542 Err_Vars.Error_Msg_File_1 := NL.Name;
7547 "source file { cannot be found",
7549 First_Error := False;
7554 "\source file { cannot be found",
7559 NL := Source_Names.Get_Next;
7561 end Get_Path_Names_And_Record_Ada_Sources;
7563 --------------------------
7564 -- Check_Naming_Schemes --
7565 --------------------------
7567 procedure Check_Naming_Schemes
7568 (In_Tree : Project_Tree_Ref;
7569 Data : in out Project_Data;
7571 File_Name : File_Name_Type;
7572 Alternate_Languages : out Alternate_Language_Id;
7573 Language : out Language_Index;
7574 Language_Name : out Name_Id;
7575 Display_Language_Name : out Name_Id;
7577 Lang_Kind : out Language_Kind;
7578 Kind : out Source_Kind)
7580 Last : Positive := Filename'Last;
7581 Config : Language_Config;
7582 Lang : Name_List_Index := Data.Languages;
7583 Header_File : Boolean := False;
7584 First_Language : Language_Index;
7587 Last_Spec : Natural;
7588 Last_Body : Natural;
7593 Alternate_Languages := No_Alternate_Language;
7595 while Lang /= No_Name_List loop
7596 Language_Name := In_Tree.Name_Lists.Table (Lang).Name;
7597 Language := Data.First_Language_Processing;
7599 if Current_Verbosity = High then
7601 (" Testing language "
7602 & Get_Name_String (Language_Name)
7603 & " Header_File=" & Header_File'Img);
7606 while Language /= No_Language_Index loop
7607 if In_Tree.Languages_Data.Table (Language).Name =
7610 Display_Language_Name :=
7611 In_Tree.Languages_Data.Table (Language).Display_Name;
7612 Config := In_Tree.Languages_Data.Table (Language).Config;
7613 Lang_Kind := Config.Kind;
7615 if Config.Kind = File_Based then
7617 -- For file based languages, there is no Unit. Just
7618 -- check if the file name has the implementation or,
7619 -- if it is specified, the template suffix of the
7625 and then Config.Naming_Data.Body_Suffix /= No_File
7628 Impl_Suffix : constant String :=
7629 Get_Name_String (Config.Naming_Data.Body_Suffix);
7632 if Filename'Length > Impl_Suffix'Length
7635 (Last - Impl_Suffix'Length + 1 .. Last) =
7640 if Current_Verbosity = High then
7641 Write_Str (" source of language ");
7643 (Get_Name_String (Display_Language_Name));
7651 if Config.Naming_Data.Spec_Suffix /= No_File then
7653 Spec_Suffix : constant String :=
7655 (Config.Naming_Data.Spec_Suffix);
7658 if Filename'Length > Spec_Suffix'Length
7661 (Last - Spec_Suffix'Length + 1 .. Last) =
7666 if Current_Verbosity = High then
7667 Write_Str (" header file of language ");
7669 (Get_Name_String (Display_Language_Name));
7673 Alternate_Language_Table.Increment_Last
7674 (In_Tree.Alt_Langs);
7675 In_Tree.Alt_Langs.Table
7676 (Alternate_Language_Table.Last
7677 (In_Tree.Alt_Langs)) :=
7678 (Language => Language,
7679 Next => Alternate_Languages);
7680 Alternate_Languages :=
7681 Alternate_Language_Table.Last
7682 (In_Tree.Alt_Langs);
7684 Header_File := True;
7685 First_Language := Language;
7691 elsif not Header_File then
7692 -- Unit based language
7694 OK := Config.Naming_Data.Dot_Replacement /= No_File;
7699 -- ??? Are we doing this once per file in the project ?
7700 -- It should be done only once per project.
7702 case Config.Naming_Data.Casing is
7703 when All_Lower_Case =>
7704 for J in Filename'Range loop
7705 if Is_Letter (Filename (J)) then
7706 if not Is_Lower (Filename (J)) then
7713 when All_Upper_Case =>
7714 for J in Filename'Range loop
7715 if Is_Letter (Filename (J)) then
7716 if not Is_Upper (Filename (J)) then
7732 Last_Spec := Natural'Last;
7733 Last_Body := Natural'Last;
7734 Last_Sep := Natural'Last;
7736 if Config.Naming_Data.Separate_Suffix /= No_File
7738 Config.Naming_Data.Separate_Suffix /=
7739 Config.Naming_Data.Body_Suffix
7742 Suffix : constant String :=
7744 (Config.Naming_Data.Separate_Suffix);
7746 if Filename'Length > Suffix'Length
7749 (Last - Suffix'Length + 1 .. Last) =
7752 Last_Sep := Last - Suffix'Length;
7757 if Config.Naming_Data.Body_Suffix /= No_File then
7759 Suffix : constant String :=
7761 (Config.Naming_Data.Body_Suffix);
7763 if Filename'Length > Suffix'Length
7766 (Last - Suffix'Length + 1 .. Last) =
7769 Last_Body := Last - Suffix'Length;
7774 if Config.Naming_Data.Spec_Suffix /= No_File then
7776 Suffix : constant String :=
7778 (Config.Naming_Data.Spec_Suffix);
7780 if Filename'Length > Suffix'Length
7783 (Last - Suffix'Length + 1 .. Last) =
7786 Last_Spec := Last - Suffix'Length;
7792 Last_Min : constant Natural :=
7793 Natural'Min (Natural'Min (Last_Spec,
7798 OK := Last_Min < Last;
7803 if Last_Min = Last_Spec then
7806 elsif Last_Min = Last_Body then
7818 -- Replace dot replacements with dots
7823 J : Positive := Filename'First;
7825 Dot_Replacement : constant String :=
7827 (Config.Naming_Data.
7830 Max : constant Positive :=
7831 Last - Dot_Replacement'Length + 1;
7835 Name_Len := Name_Len + 1;
7837 if J <= Max and then
7839 (J .. J + Dot_Replacement'Length - 1) =
7842 Name_Buffer (Name_Len) := '.';
7843 J := J + Dot_Replacement'Length;
7846 if Filename (J) = '.' then
7851 Name_Buffer (Name_Len) :=
7852 GNAT.Case_Util.To_Lower (Filename (J));
7863 -- The name buffer should contain the name of the
7864 -- the unit, if it is one.
7866 -- Check that this is a valid unit name
7868 Check_Ada_Name (Name_Buffer (1 .. Name_Len), Unit);
7870 if Unit /= No_Name then
7872 if Current_Verbosity = High then
7874 Write_Str (" spec of ");
7876 Write_Str (" body of ");
7879 Write_Str (Get_Name_String (Unit));
7880 Write_Str (" (language ");
7882 (Get_Name_String (Display_Language_Name));
7886 -- Comments required, declare block should
7890 Unit_Except : constant Unit_Exception :=
7891 Unit_Exceptions.Get (Unit);
7893 procedure Masked_Unit (Spec : Boolean);
7894 -- Indicate that there is an exception for
7895 -- the same unit, so the file is not a
7896 -- source for the unit.
7902 procedure Masked_Unit (Spec : Boolean) is
7904 if Current_Verbosity = High then
7906 Write_Str (Filename);
7907 Write_Str (""" contains the ");
7916 (" of a unit that is found in """);
7921 (Unit_Except.Spec));
7925 (Unit_Except.Impl));
7928 Write_Line (""" (ignored)");
7931 Language := No_Language_Index;
7936 if Unit_Except.Spec /= No_File
7937 and then Unit_Except.Spec /= File_Name
7939 Masked_Unit (Spec => True);
7943 if Unit_Except.Impl /= No_File
7944 and then Unit_Except.Impl /= File_Name
7946 Masked_Unit (Spec => False);
7957 Language := In_Tree.Languages_Data.Table (Language).Next;
7960 Lang := In_Tree.Name_Lists.Table (Lang).Next;
7963 -- Comment needed here ???
7966 Language := First_Language;
7969 Language := No_Language_Index;
7971 if Current_Verbosity = High then
7972 Write_Line (" not a source of any language");
7975 end Check_Naming_Schemes;
7981 procedure Check_File
7982 (Project : Project_Id;
7983 In_Tree : Project_Tree_Ref;
7984 Data : in out Project_Data;
7986 File_Name : File_Name_Type;
7987 Display_File_Name : File_Name_Type;
7988 Source_Directory : String;
7989 For_All_Sources : Boolean)
7991 Display_Path : constant String :=
7994 Directory => Source_Directory,
7995 Resolve_Links => Opt.Follow_Links_For_Files,
7996 Case_Sensitive => True);
7998 Name_Loc : Name_Location := Source_Names.Get (File_Name);
7999 Path_Id : Path_Name_Type;
8000 Display_Path_Id : Path_Name_Type;
8001 Check_Name : Boolean := False;
8002 Alternate_Languages : Alternate_Language_Id := No_Alternate_Language;
8003 Language : Language_Index;
8005 Other_Part : Source_Id;
8007 Src_Ind : Source_File_Index;
8008 Src_Data : Source_Data;
8010 Source_To_Replace : Source_Id := No_Source;
8011 Language_Name : Name_Id;
8012 Display_Language_Name : Name_Id;
8013 Lang_Kind : Language_Kind;
8014 Kind : Source_Kind := Spec;
8017 Name_Len := Display_Path'Length;
8018 Name_Buffer (1 .. Name_Len) := Display_Path;
8019 Display_Path_Id := Name_Find;
8021 if Osint.File_Names_Case_Sensitive then
8022 Path_Id := Display_Path_Id;
8024 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
8025 Path_Id := Name_Find;
8028 if Name_Loc = No_Name_Location then
8029 Check_Name := For_All_Sources;
8032 if Name_Loc.Found then
8034 -- Check if it is OK to have the same file name in several
8035 -- source directories.
8037 if not Data.Known_Order_Of_Source_Dirs then
8038 Error_Msg_File_1 := File_Name;
8041 "{ is found in several source directories",
8046 Name_Loc.Found := True;
8048 Source_Names.Set (File_Name, Name_Loc);
8050 if Name_Loc.Source = No_Source then
8054 In_Tree.Sources.Table (Name_Loc.Source).Path :=
8055 (Path_Id, Display_Path_Id);
8057 Source_Paths_Htable.Set
8058 (In_Tree.Source_Paths_HT,
8062 -- Check if this is a subunit
8064 if In_Tree.Sources.Table (Name_Loc.Source).Unit /= No_Name
8066 In_Tree.Sources.Table (Name_Loc.Source).Kind = Impl
8068 Src_Ind := Sinput.P.Load_Project_File
8069 (Get_Name_String (Path_Id));
8071 if Sinput.P.Source_File_Is_Subunit (Src_Ind) then
8072 In_Tree.Sources.Table (Name_Loc.Source).Kind := Sep;
8080 Other_Part := No_Source;
8082 Check_Naming_Schemes
8083 (In_Tree => In_Tree,
8085 Filename => Get_Name_String (File_Name),
8086 File_Name => File_Name,
8087 Alternate_Languages => Alternate_Languages,
8088 Language => Language,
8089 Language_Name => Language_Name,
8090 Display_Language_Name => Display_Language_Name,
8092 Lang_Kind => Lang_Kind,
8095 if Language = No_Language_Index then
8097 -- A file name in a list must be a source of a language
8099 if Name_Loc.Found then
8100 Error_Msg_File_1 := File_Name;
8104 "language unknown for {",
8109 -- Check if the same file name or unit is used in the prj tree
8111 Source := In_Tree.First_Source;
8113 while Source /= No_Source loop
8114 Src_Data := In_Tree.Sources.Table (Source);
8117 and then Src_Data.Unit = Unit
8119 ((Src_Data.Kind = Spec and then Kind = Impl)
8121 (Src_Data.Kind = Impl and then Kind = Spec))
8123 Other_Part := Source;
8125 elsif (Unit /= No_Name
8126 and then Src_Data.Unit = Unit
8128 (Src_Data.Kind = Kind
8130 (Src_Data.Kind = Sep and then Kind = Impl)
8132 (Src_Data.Kind = Impl and then Kind = Sep)))
8133 or else (Unit = No_Name and then Src_Data.File = File_Name)
8135 -- Duplication of file/unit in same project is only
8136 -- allowed if order of source directories is known.
8138 if Project = Src_Data.Project then
8139 if Data.Known_Order_Of_Source_Dirs then
8142 elsif Unit /= No_Name then
8143 Error_Msg_Name_1 := Unit;
8145 (Project, In_Tree, "duplicate unit %%", No_Location);
8149 Error_Msg_File_1 := File_Name;
8151 (Project, In_Tree, "duplicate source file name {",
8156 -- Do not allow the same unit name in different
8157 -- projects, except if one is extending the other.
8159 -- For a file based language, the same file name
8160 -- replaces a file in a project being extended, but
8161 -- it is allowed to have the same file name in
8162 -- unrelated projects.
8165 (Project, Src_Data.Project, In_Tree)
8167 Source_To_Replace := Source;
8169 elsif Unit /= No_Name
8170 and then not Src_Data.Locally_Removed
8172 Error_Msg_Name_1 := Unit;
8175 "unit %% cannot belong to several projects",
8178 Error_Msg_Name_1 := In_Tree.Projects.Table (Project).Name;
8179 Error_Msg_Name_2 := Name_Id (Display_Path_Id);
8181 (Project, In_Tree, "\ project %%, %%", No_Location);
8184 In_Tree.Projects.Table (Src_Data.Project).Name;
8185 Error_Msg_Name_2 := Name_Id (Src_Data.Path.Display_Name);
8187 (Project, In_Tree, "\ project %%, %%", No_Location);
8193 Source := Src_Data.Next_In_Sources;
8202 Lang => Language_Name,
8203 Lang_Id => Language,
8204 Lang_Kind => Lang_Kind,
8206 Alternate_Languages => Alternate_Languages,
8207 File_Name => File_Name,
8208 Display_File => Display_File_Name,
8209 Other_Part => Other_Part,
8212 Display_Path => Display_Path_Id,
8213 Source_To_Replace => Source_To_Replace);
8219 ------------------------
8220 -- Search_Directories --
8221 ------------------------
8223 procedure Search_Directories
8224 (Project : Project_Id;
8225 In_Tree : Project_Tree_Ref;
8226 Data : in out Project_Data;
8227 For_All_Sources : Boolean)
8229 Source_Dir : String_List_Id;
8230 Element : String_Element;
8232 Name : String (1 .. 1_000);
8234 File_Name : File_Name_Type;
8235 Display_File_Name : File_Name_Type;
8238 if Current_Verbosity = High then
8239 Write_Line ("Looking for sources:");
8242 -- Loop through subdirectories
8244 Source_Dir := Data.Source_Dirs;
8245 while Source_Dir /= Nil_String loop
8247 Element := In_Tree.String_Elements.Table (Source_Dir);
8248 if Element.Value /= No_Name then
8249 Get_Name_String (Element.Display_Value);
8252 Source_Directory : constant String :=
8253 Name_Buffer (1 .. Name_Len) &
8254 Directory_Separator;
8256 Dir_Last : constant Natural :=
8257 Compute_Directory_Last
8261 if Current_Verbosity = High then
8262 Write_Str ("Source_Dir = ");
8263 Write_Line (Source_Directory);
8266 -- We look to every entry in the source directory
8268 Open (Dir, Source_Directory);
8271 Read (Dir, Name, Last);
8275 -- ??? Duplicate system call here, we just did a
8276 -- a similar one. Maybe Ada.Directories would be more
8280 (Source_Directory & Name (1 .. Last))
8282 if Current_Verbosity = High then
8283 Write_Str (" Checking ");
8284 Write_Line (Name (1 .. Last));
8288 Name_Buffer (1 .. Name_Len) := Name (1 .. Last);
8289 Display_File_Name := Name_Find;
8291 if Osint.File_Names_Case_Sensitive then
8292 File_Name := Display_File_Name;
8294 Canonical_Case_File_Name
8295 (Name_Buffer (1 .. Name_Len));
8296 File_Name := Name_Find;
8301 Excluded_Sources_Htable.Get (File_Name);
8304 if FF /= No_File_Found then
8305 if not FF.Found then
8307 Excluded_Sources_Htable.Set
8310 if Current_Verbosity = High then
8311 Write_Str (" excluded source """);
8312 Write_Str (Get_Name_String (File_Name));
8319 (Project => Project,
8322 Name => Name (1 .. Last),
8323 File_Name => File_Name,
8324 Display_File_Name => Display_File_Name,
8325 Source_Directory => Source_Directory
8326 (Source_Directory'First .. Dir_Last),
8327 For_All_Sources => For_All_Sources);
8338 when Directory_Error =>
8342 Source_Dir := Element.Next;
8345 if Current_Verbosity = High then
8346 Write_Line ("end Looking for sources.");
8348 end Search_Directories;
8350 ----------------------
8351 -- Look_For_Sources --
8352 ----------------------
8354 procedure Look_For_Sources
8355 (Project : Project_Id;
8356 In_Tree : Project_Tree_Ref;
8357 Data : in out Project_Data;
8358 Current_Dir : String)
8360 procedure Remove_Locally_Removed_Files_From_Units;
8361 -- Mark all locally removed sources as such in the Units table
8363 procedure Process_Sources_In_Multi_Language_Mode;
8364 -- Find all source files when in multi language mode
8366 ---------------------------------------------
8367 -- Remove_Locally_Removed_Files_From_Units --
8368 ---------------------------------------------
8370 procedure Remove_Locally_Removed_Files_From_Units is
8371 Excluded : File_Found;
8374 Extended : Project_Id;
8377 Excluded := Excluded_Sources_Htable.Get_First;
8378 while Excluded /= No_File_Found loop
8382 for Index in Unit_Table.First ..
8383 Unit_Table.Last (In_Tree.Units)
8385 Unit := In_Tree.Units.Table (Index);
8387 for Kind in Spec_Or_Body'Range loop
8388 if Unit.File_Names (Kind).Name = Excluded.File then
8391 -- Check that this is from the current project or
8392 -- that the current project extends.
8394 Extended := Unit.File_Names (Kind).Project;
8396 if Extended = Project
8397 or else Project_Extends (Project, Extended, In_Tree)
8399 Unit.File_Names (Kind).Path.Name := Slash;
8400 Unit.File_Names (Kind).Needs_Pragma := False;
8401 In_Tree.Units.Table (Index) := Unit;
8402 Add_Forbidden_File_Name
8403 (Unit.File_Names (Kind).Name);
8407 "cannot remove a source from " &
8414 end loop For_Each_Unit;
8417 Err_Vars.Error_Msg_File_1 := Excluded.File;
8419 (Project, In_Tree, "unknown file {", Excluded.Location);
8422 Excluded := Excluded_Sources_Htable.Get_Next;
8424 end Remove_Locally_Removed_Files_From_Units;
8426 --------------------------------------------
8427 -- Process_Sources_In_Multi_Language_Mode --
8428 --------------------------------------------
8430 procedure Process_Sources_In_Multi_Language_Mode is
8432 Src_Data : Source_Data;
8433 Name_Loc : Name_Location;
8438 -- First, put all naming exceptions if any, in the Source_Names table
8440 Unit_Exceptions.Reset;
8442 Source := Data.First_Source;
8443 while Source /= No_Source loop
8444 Src_Data := In_Tree.Sources.Table (Source);
8446 -- A file that is excluded cannot also be an exception file name
8448 if Excluded_Sources_Htable.Get (Src_Data.File) /=
8451 Error_Msg_File_1 := Src_Data.File;
8454 "{ cannot be both excluded and an exception file name",
8458 Name_Loc := (Name => Src_Data.File,
8459 Location => No_Location,
8461 Except => Src_Data.Unit /= No_Name,
8464 if Current_Verbosity = High then
8465 Write_Str ("Putting source #");
8466 Write_Str (Source'Img);
8467 Write_Str (", file ");
8468 Write_Str (Get_Name_String (Src_Data.File));
8469 Write_Line (" in Source_Names");
8472 Source_Names.Set (K => Src_Data.File, E => Name_Loc);
8474 -- If this is an Ada exception, record it in table Unit_Exceptions
8476 if Src_Data.Unit /= No_Name then
8478 Unit_Except : Unit_Exception :=
8479 Unit_Exceptions.Get (Src_Data.Unit);
8482 Unit_Except.Name := Src_Data.Unit;
8484 if Src_Data.Kind = Spec then
8485 Unit_Except.Spec := Src_Data.File;
8487 Unit_Except.Impl := Src_Data.File;
8490 Unit_Exceptions.Set (Src_Data.Unit, Unit_Except);
8494 Source := Src_Data.Next_In_Project;
8497 Find_Explicit_Sources
8498 (Current_Dir, Project, In_Tree, Data);
8500 -- Mark as such the sources that are declared as excluded
8502 FF := Excluded_Sources_Htable.Get_First;
8503 while FF /= No_File_Found loop
8505 Source := In_Tree.First_Source;
8507 while Source /= No_Source loop
8508 Src_Data := In_Tree.Sources.Table (Source);
8510 if Src_Data.File = FF.File then
8512 -- Check that this is from this project or a project that
8513 -- the current project extends.
8515 if Src_Data.Project = Project or else
8516 Is_Extending (Project, Src_Data.Project, In_Tree)
8518 Src_Data.Locally_Removed := True;
8519 Src_Data.In_Interfaces := False;
8520 In_Tree.Sources.Table (Source) := Src_Data;
8521 Add_Forbidden_File_Name (FF.File);
8527 Source := Src_Data.Next_In_Sources;
8530 if not FF.Found and not OK then
8531 Err_Vars.Error_Msg_File_1 := FF.File;
8532 Error_Msg (Project, In_Tree, "unknown file {", FF.Location);
8535 FF := Excluded_Sources_Htable.Get_Next;
8538 -- Check that two sources of this project do not have the same object
8541 Check_Object_File_Names : declare
8543 Src_Data : Source_Data;
8544 Source_Name : File_Name_Type;
8546 procedure Check_Object;
8547 -- Check if object file name of the current source is already in
8548 -- hash table Object_File_Names. If it is, report an error. If it
8549 -- is not, put it there with the file name of the current source.
8555 procedure Check_Object is
8557 Source_Name := Object_File_Names.Get (Src_Data.Object);
8559 if Source_Name /= No_File then
8560 Error_Msg_File_1 := Src_Data.File;
8561 Error_Msg_File_2 := Source_Name;
8565 "{ and { have the same object file name",
8569 Object_File_Names.Set (Src_Data.Object, Src_Data.File);
8573 -- Start of processing for Check_Object_File_Names
8576 Object_File_Names.Reset;
8577 Src_Id := In_Tree.First_Source;
8578 while Src_Id /= No_Source loop
8579 Src_Data := In_Tree.Sources.Table (Src_Id);
8581 if Src_Data.Compiled and then Src_Data.Object_Exists
8582 and then Project_Extends (Project, Src_Data.Project, In_Tree)
8584 if Src_Data.Unit = No_Name then
8585 if Src_Data.Kind = Impl then
8590 case Src_Data.Kind is
8592 if Src_Data.Other_Part = No_Source then
8600 if Src_Data.Other_Part /= No_Source then
8604 -- Check if it is a subunit
8607 Src_Ind : constant Source_File_Index :=
8608 Sinput.P.Load_Project_File
8610 (Src_Data.Path.Name));
8613 if Sinput.P.Source_File_Is_Subunit
8616 In_Tree.Sources.Table (Src_Id).Kind := Sep;
8626 Src_Id := Src_Data.Next_In_Sources;
8628 end Check_Object_File_Names;
8629 end Process_Sources_In_Multi_Language_Mode;
8631 -- Start of processing for Look_For_Sources
8635 Find_Excluded_Sources (Project, In_Tree, Data);
8639 if Is_A_Language (In_Tree, Data, Name_Ada) then
8640 Find_Explicit_Sources (Current_Dir, Project, In_Tree, Data);
8641 Remove_Locally_Removed_Files_From_Units;
8644 when Multi_Language =>
8645 if Data.First_Language_Processing /= No_Language_Index then
8646 Process_Sources_In_Multi_Language_Mode;
8649 end Look_For_Sources;
8655 function Path_Name_Of
8656 (File_Name : File_Name_Type;
8657 Directory : Path_Name_Type) return String
8659 Result : String_Access;
8660 The_Directory : constant String := Get_Name_String (Directory);
8663 Get_Name_String (File_Name);
8666 (File_Name => Name_Buffer (1 .. Name_Len),
8667 Path => The_Directory);
8669 if Result = null then
8672 Canonical_Case_File_Name (Result.all);
8677 -------------------------------
8678 -- Prepare_Ada_Naming_Exceptions --
8679 -------------------------------
8681 procedure Prepare_Ada_Naming_Exceptions
8682 (List : Array_Element_Id;
8683 In_Tree : Project_Tree_Ref;
8684 Kind : Spec_Or_Body)
8686 Current : Array_Element_Id;
8687 Element : Array_Element;
8691 -- Traverse the list
8694 while Current /= No_Array_Element loop
8695 Element := In_Tree.Array_Elements.Table (Current);
8697 if Element.Index /= No_Name then
8700 Unit => Element.Index,
8701 Next => No_Ada_Naming_Exception);
8702 Reverse_Ada_Naming_Exceptions.Set
8703 (Unit, (Element.Value.Value, Element.Value.Index));
8705 Ada_Naming_Exceptions.Get (File_Name_Type (Element.Value.Value));
8706 Ada_Naming_Exception_Table.Increment_Last;
8707 Ada_Naming_Exception_Table.Table
8708 (Ada_Naming_Exception_Table.Last) := Unit;
8709 Ada_Naming_Exceptions.Set
8710 (File_Name_Type (Element.Value.Value),
8711 Ada_Naming_Exception_Table.Last);
8714 Current := Element.Next;
8716 end Prepare_Ada_Naming_Exceptions;
8718 ---------------------
8719 -- Project_Extends --
8720 ---------------------
8722 function Project_Extends
8723 (Extending : Project_Id;
8724 Extended : Project_Id;
8725 In_Tree : Project_Tree_Ref) return Boolean
8727 Current : Project_Id := Extending;
8731 if Current = No_Project then
8734 elsif Current = Extended then
8738 Current := In_Tree.Projects.Table (Current).Extends;
8740 end Project_Extends;
8742 -----------------------
8743 -- Record_Ada_Source --
8744 -----------------------
8746 procedure Record_Ada_Source
8747 (File_Name : File_Name_Type;
8748 Path_Name : Path_Name_Type;
8749 Project : Project_Id;
8750 In_Tree : Project_Tree_Ref;
8751 Data : in out Project_Data;
8752 Location : Source_Ptr;
8753 Current_Source : in out String_List_Id;
8754 Source_Recorded : in out Boolean;
8755 Current_Dir : String)
8757 Canonical_File_Name : File_Name_Type;
8758 Canonical_Path_Name : Path_Name_Type;
8760 Exception_Id : Ada_Naming_Exception_Id;
8761 Unit_Name : Name_Id;
8762 Unit_Kind : Spec_Or_Body;
8763 Unit_Ind : Int := 0;
8765 Name_Index : Name_And_Index;
8766 Needs_Pragma : Boolean;
8768 The_Location : Source_Ptr := Location;
8769 Previous_Source : constant String_List_Id := Current_Source;
8770 Except_Name : Name_And_Index := No_Name_And_Index;
8772 Unit_Prj : Unit_Project;
8774 File_Name_Recorded : Boolean := False;
8777 if Osint.File_Names_Case_Sensitive then
8778 Canonical_File_Name := File_Name;
8779 Canonical_Path_Name := Path_Name;
8781 Get_Name_String (File_Name);
8782 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
8783 Canonical_File_Name := Name_Find;
8786 Canonical_Path : constant String :=
8788 (Get_Name_String (Path_Name),
8789 Directory => Current_Dir,
8790 Resolve_Links => Opt.Follow_Links_For_Files,
8791 Case_Sensitive => False);
8794 Add_Str_To_Name_Buffer (Canonical_Path);
8795 Canonical_Path_Name := Name_Find;
8799 -- Find out the unit name, the unit kind and if it needs
8800 -- a specific SFN pragma.
8803 (In_Tree => In_Tree,
8804 Canonical_File_Name => Canonical_File_Name,
8805 Naming => Data.Naming,
8806 Exception_Id => Exception_Id,
8807 Unit_Name => Unit_Name,
8808 Unit_Kind => Unit_Kind,
8809 Needs_Pragma => Needs_Pragma);
8811 if Exception_Id = No_Ada_Naming_Exception
8812 and then Unit_Name = No_Name
8814 if Current_Verbosity = High then
8816 Write_Str (Get_Name_String (Canonical_File_Name));
8817 Write_Line (""" is not a valid source file name (ignored).");
8821 -- Check to see if the source has been hidden by an exception,
8822 -- but only if it is not an exception.
8824 if not Needs_Pragma then
8826 Reverse_Ada_Naming_Exceptions.Get
8827 ((Unit_Kind, Unit_Name, No_Ada_Naming_Exception));
8829 if Except_Name /= No_Name_And_Index then
8830 if Current_Verbosity = High then
8832 Write_Str (Get_Name_String (Canonical_File_Name));
8833 Write_Str (""" contains a unit that is found in """);
8834 Write_Str (Get_Name_String (Except_Name.Name));
8835 Write_Line (""" (ignored).");
8838 -- The file is not included in the source of the project since
8839 -- it is hidden by the exception. So, nothing else to do.
8846 if Exception_Id /= No_Ada_Naming_Exception then
8847 Info := Ada_Naming_Exception_Table.Table (Exception_Id);
8848 Exception_Id := Info.Next;
8849 Info.Next := No_Ada_Naming_Exception;
8850 Name_Index := Reverse_Ada_Naming_Exceptions.Get (Info);
8852 Unit_Name := Info.Unit;
8853 Unit_Ind := Name_Index.Index;
8854 Unit_Kind := Info.Kind;
8857 -- Put the file name in the list of sources of the project
8859 String_Element_Table.Increment_Last (In_Tree.String_Elements);
8860 In_Tree.String_Elements.Table
8861 (String_Element_Table.Last (In_Tree.String_Elements)) :=
8862 (Value => Name_Id (Canonical_File_Name),
8863 Display_Value => Name_Id (File_Name),
8864 Location => No_Location,
8869 if Current_Source = Nil_String then
8871 String_Element_Table.Last (In_Tree.String_Elements);
8873 In_Tree.String_Elements.Table (Current_Source).Next :=
8874 String_Element_Table.Last (In_Tree.String_Elements);
8878 String_Element_Table.Last (In_Tree.String_Elements);
8880 -- Put the unit in unit list
8883 The_Unit : Unit_Index :=
8884 Units_Htable.Get (In_Tree.Units_HT, Unit_Name);
8886 The_Unit_Data : Unit_Data;
8889 if Current_Verbosity = High then
8890 Write_Str ("Putting ");
8891 Write_Str (Get_Name_String (Unit_Name));
8892 Write_Line (" in the unit list.");
8895 -- The unit is already in the list, but may be it is
8896 -- only the other unit kind (spec or body), or what is
8897 -- in the unit list is a unit of a project we are extending.
8899 if The_Unit /= No_Unit_Index then
8900 The_Unit_Data := In_Tree.Units.Table (The_Unit);
8902 if (The_Unit_Data.File_Names (Unit_Kind).Name =
8905 The_Unit_Data.File_Names
8906 (Unit_Kind).Path.Name = Slash)
8907 or else The_Unit_Data.File_Names (Unit_Kind).Name = No_File
8908 or else Project_Extends
8910 The_Unit_Data.File_Names (Unit_Kind).Project,
8914 The_Unit_Data.File_Names (Unit_Kind).Path.Name = Slash
8916 Remove_Forbidden_File_Name
8917 (The_Unit_Data.File_Names (Unit_Kind).Name);
8920 -- Record the file name in the hash table Files_Htable
8922 Unit_Prj := (Unit => The_Unit, Project => Project);
8925 Canonical_File_Name,
8928 The_Unit_Data.File_Names (Unit_Kind) :=
8929 (Name => Canonical_File_Name,
8931 Display_Name => File_Name,
8932 Path => (Canonical_Path_Name, Path_Name),
8934 Needs_Pragma => Needs_Pragma);
8935 In_Tree.Units.Table (The_Unit) := The_Unit_Data;
8936 Source_Recorded := True;
8938 elsif The_Unit_Data.File_Names (Unit_Kind).Project = Project
8939 and then (Data.Known_Order_Of_Source_Dirs
8941 The_Unit_Data.File_Names
8942 (Unit_Kind).Path.Name = Canonical_Path_Name)
8944 if Previous_Source = Nil_String then
8945 Data.Ada_Sources := Nil_String;
8947 In_Tree.String_Elements.Table (Previous_Source).Next :=
8949 String_Element_Table.Decrement_Last
8950 (In_Tree.String_Elements);
8953 Current_Source := Previous_Source;
8956 -- It is an error to have two units with the same name
8957 -- and the same kind (spec or body).
8959 if The_Location = No_Location then
8961 In_Tree.Projects.Table (Project).Location;
8964 Err_Vars.Error_Msg_Name_1 := Unit_Name;
8966 (Project, In_Tree, "duplicate unit %%", The_Location);
8968 Err_Vars.Error_Msg_Name_1 :=
8969 In_Tree.Projects.Table
8970 (The_Unit_Data.File_Names (Unit_Kind).Project).Name;
8971 Err_Vars.Error_Msg_File_1 :=
8973 (The_Unit_Data.File_Names (Unit_Kind).Path.Name);
8976 "\ project file %%, {", The_Location);
8978 Err_Vars.Error_Msg_Name_1 :=
8979 In_Tree.Projects.Table (Project).Name;
8980 Err_Vars.Error_Msg_File_1 :=
8981 File_Name_Type (Canonical_Path_Name);
8984 "\ project file %%, {", The_Location);
8987 -- It is a new unit, create a new record
8990 -- First, check if there is no other unit with this file
8991 -- name in another project. If it is, report error but note
8992 -- we do that only for the first unit in the source file.
8995 Files_Htable.Get (In_Tree.Files_HT, Canonical_File_Name);
8997 if not File_Name_Recorded and then
8998 Unit_Prj /= No_Unit_Project
9000 Error_Msg_File_1 := File_Name;
9002 In_Tree.Projects.Table (Unit_Prj.Project).Name;
9005 "{ is already a source of project %%",
9009 Unit_Table.Increment_Last (In_Tree.Units);
9010 The_Unit := Unit_Table.Last (In_Tree.Units);
9012 (In_Tree.Units_HT, Unit_Name, The_Unit);
9013 Unit_Prj := (Unit => The_Unit, Project => Project);
9016 Canonical_File_Name,
9018 The_Unit_Data.Name := Unit_Name;
9019 The_Unit_Data.File_Names (Unit_Kind) :=
9020 (Name => Canonical_File_Name,
9022 Display_Name => File_Name,
9023 Path => (Canonical_Path_Name, Path_Name),
9025 Needs_Pragma => Needs_Pragma);
9026 In_Tree.Units.Table (The_Unit) := The_Unit_Data;
9027 Source_Recorded := True;
9032 exit when Exception_Id = No_Ada_Naming_Exception;
9033 File_Name_Recorded := True;
9036 end Record_Ada_Source;
9042 procedure Remove_Source
9044 Replaced_By : Source_Id;
9045 Project : Project_Id;
9046 Data : in out Project_Data;
9047 In_Tree : Project_Tree_Ref)
9049 Src_Data : constant Source_Data := In_Tree.Sources.Table (Id);
9053 if Current_Verbosity = High then
9054 Write_Str ("Removing source #");
9055 Write_Line (Id'Img);
9058 if Replaced_By /= No_Source then
9059 In_Tree.Sources.Table (Id).Replaced_By := Replaced_By;
9060 In_Tree.Sources.Table (Replaced_By).Declared_In_Interfaces :=
9061 In_Tree.Sources.Table (Id).Declared_In_Interfaces;
9064 -- Remove the source from the global source list
9066 Source := In_Tree.First_Source;
9069 In_Tree.First_Source := Src_Data.Next_In_Sources;
9072 while In_Tree.Sources.Table (Source).Next_In_Sources /= Id loop
9073 Source := In_Tree.Sources.Table (Source).Next_In_Sources;
9076 In_Tree.Sources.Table (Source).Next_In_Sources :=
9077 Src_Data.Next_In_Sources;
9080 -- Remove the source from the project list
9082 if Src_Data.Project = Project then
9083 Source := Data.First_Source;
9086 Data.First_Source := Src_Data.Next_In_Project;
9088 if Src_Data.Next_In_Project = No_Source then
9089 Data.Last_Source := No_Source;
9093 while In_Tree.Sources.Table (Source).Next_In_Project /= Id loop
9094 Source := In_Tree.Sources.Table (Source).Next_In_Project;
9097 In_Tree.Sources.Table (Source).Next_In_Project :=
9098 Src_Data.Next_In_Project;
9100 if Src_Data.Next_In_Project = No_Source then
9101 In_Tree.Projects.Table (Src_Data.Project).Last_Source := Source;
9106 Source := In_Tree.Projects.Table (Src_Data.Project).First_Source;
9109 In_Tree.Projects.Table (Src_Data.Project).First_Source :=
9110 Src_Data.Next_In_Project;
9112 if Src_Data.Next_In_Project = No_Source then
9113 In_Tree.Projects.Table (Src_Data.Project).Last_Source :=
9118 while In_Tree.Sources.Table (Source).Next_In_Project /= Id loop
9119 Source := In_Tree.Sources.Table (Source).Next_In_Project;
9122 In_Tree.Sources.Table (Source).Next_In_Project :=
9123 Src_Data.Next_In_Project;
9125 if Src_Data.Next_In_Project = No_Source then
9126 In_Tree.Projects.Table (Src_Data.Project).Last_Source := Source;
9131 -- Remove source from the language list
9133 Source := In_Tree.Languages_Data.Table (Src_Data.Language).First_Source;
9136 In_Tree.Languages_Data.Table (Src_Data.Language).First_Source :=
9137 Src_Data.Next_In_Lang;
9140 while In_Tree.Sources.Table (Source).Next_In_Lang /= Id loop
9141 Source := In_Tree.Sources.Table (Source).Next_In_Lang;
9144 In_Tree.Sources.Table (Source).Next_In_Lang :=
9145 Src_Data.Next_In_Lang;
9149 -----------------------
9150 -- Report_No_Sources --
9151 -----------------------
9153 procedure Report_No_Sources
9154 (Project : Project_Id;
9156 In_Tree : Project_Tree_Ref;
9157 Location : Source_Ptr;
9158 Continuation : Boolean := False)
9161 case When_No_Sources is
9165 when Warning | Error =>
9167 Msg : constant String :=
9170 " sources in this project";
9173 Error_Msg_Warn := When_No_Sources = Warning;
9175 if Continuation then
9177 (Project, In_Tree, "\" & Msg, Location);
9181 (Project, In_Tree, Msg, Location);
9185 end Report_No_Sources;
9187 ----------------------
9188 -- Show_Source_Dirs --
9189 ----------------------
9191 procedure Show_Source_Dirs
9192 (Data : Project_Data;
9193 In_Tree : Project_Tree_Ref)
9195 Current : String_List_Id;
9196 Element : String_Element;
9199 Write_Line ("Source_Dirs:");
9201 Current := Data.Source_Dirs;
9202 while Current /= Nil_String loop
9203 Element := In_Tree.String_Elements.Table (Current);
9205 Write_Line (Get_Name_String (Element.Value));
9206 Current := Element.Next;
9209 Write_Line ("end Source_Dirs.");
9210 end Show_Source_Dirs;
9212 -------------------------
9213 -- Warn_If_Not_Sources --
9214 -------------------------
9216 -- comments needed in this body ???
9218 procedure Warn_If_Not_Sources
9219 (Project : Project_Id;
9220 In_Tree : Project_Tree_Ref;
9221 Conventions : Array_Element_Id;
9223 Extending : Boolean)
9225 Conv : Array_Element_Id;
9227 The_Unit_Id : Unit_Index;
9228 The_Unit_Data : Unit_Data;
9229 Location : Source_Ptr;
9232 Conv := Conventions;
9233 while Conv /= No_Array_Element loop
9234 Unit := In_Tree.Array_Elements.Table (Conv).Index;
9235 Error_Msg_Name_1 := Unit;
9236 Get_Name_String (Unit);
9237 To_Lower (Name_Buffer (1 .. Name_Len));
9239 The_Unit_Id := Units_Htable.Get (In_Tree.Units_HT, Unit);
9240 Location := In_Tree.Array_Elements.Table (Conv).Value.Location;
9242 if The_Unit_Id = No_Unit_Index then
9243 Error_Msg (Project, In_Tree, "?unknown unit %%", Location);
9246 The_Unit_Data := In_Tree.Units.Table (The_Unit_Id);
9248 In_Tree.Array_Elements.Table (Conv).Value.Value;
9251 if not Check_Project
9252 (The_Unit_Data.File_Names (Specification).Project,
9253 Project, In_Tree, Extending)
9257 "?source of spec of unit %% (%%)" &
9258 " cannot be found in this project",
9263 if not Check_Project
9264 (The_Unit_Data.File_Names (Body_Part).Project,
9265 Project, In_Tree, Extending)
9269 "?source of body of unit %% (%%)" &
9270 " cannot be found in this project",
9276 Conv := In_Tree.Array_Elements.Table (Conv).Next;
9278 end Warn_If_Not_Sources;