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);
6415 List : String_List_Id;
6416 Elem : String_Element;
6419 Data.Mains := Mains.Values;
6421 -- If no Mains were specified, and if we are an extending project,
6422 -- inherit the Mains from the project we are extending.
6424 if Mains.Default then
6425 if not Data.Library and then Data.Extends /= No_Project then
6427 In_Tree.Projects.Table (Data.Extends).Mains;
6430 -- In a library project file, Main cannot be specified
6432 elsif Data.Library then
6435 "a library project file cannot have Main specified",
6438 -- Normal case where Main was specified
6441 List := Mains.Values;
6442 while List /= Nil_String loop
6443 Elem := In_Tree.String_Elements.Table (List);
6445 if Length_Of_Name (Elem.Value) = 0 then
6448 "?a main cannot have an empty name",
6458 ---------------------------
6459 -- Get_Sources_From_File --
6460 ---------------------------
6462 procedure Get_Sources_From_File
6464 Location : Source_Ptr;
6465 Project : Project_Id;
6466 In_Tree : Project_Tree_Ref)
6468 File : Prj.Util.Text_File;
6469 Line : String (1 .. 250);
6471 Source_Name : File_Name_Type;
6472 Name_Loc : Name_Location;
6475 if Get_Mode = Ada_Only then
6479 if Current_Verbosity = High then
6480 Write_Str ("Opening """);
6487 Prj.Util.Open (File, Path);
6489 if not Prj.Util.Is_Valid (File) then
6490 Error_Msg (Project, In_Tree, "file does not exist", Location);
6493 -- Read the lines one by one
6495 while not Prj.Util.End_Of_File (File) loop
6496 Prj.Util.Get_Line (File, Line, Last);
6498 -- A non empty, non comment line should contain a file name
6501 and then (Last = 1 or else Line (1 .. 2) /= "--")
6504 Name_Buffer (1 .. Name_Len) := Line (1 .. Last);
6505 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
6506 Source_Name := Name_Find;
6508 -- Check that there is no directory information
6510 for J in 1 .. Last loop
6511 if Line (J) = '/' or else Line (J) = Directory_Separator then
6512 Error_Msg_File_1 := Source_Name;
6516 "file name cannot include directory information ({)",
6522 Name_Loc := Source_Names.Get (Source_Name);
6524 if Name_Loc = No_Name_Location then
6526 (Name => Source_Name,
6527 Location => Location,
6528 Source => No_Source,
6533 Source_Names.Set (Source_Name, Name_Loc);
6537 Prj.Util.Close (File);
6540 end Get_Sources_From_File;
6547 (In_Tree : Project_Tree_Ref;
6548 Canonical_File_Name : File_Name_Type;
6549 Naming : Naming_Data;
6550 Exception_Id : out Ada_Naming_Exception_Id;
6551 Unit_Name : out Name_Id;
6552 Unit_Kind : out Spec_Or_Body;
6553 Needs_Pragma : out Boolean)
6555 Info_Id : Ada_Naming_Exception_Id :=
6556 Ada_Naming_Exceptions.Get (Canonical_File_Name);
6557 VMS_Name : File_Name_Type;
6560 if Info_Id = No_Ada_Naming_Exception then
6561 if Hostparm.OpenVMS then
6562 VMS_Name := Canonical_File_Name;
6563 Get_Name_String (VMS_Name);
6565 if Name_Buffer (Name_Len) = '.' then
6566 Name_Len := Name_Len - 1;
6567 VMS_Name := Name_Find;
6570 Info_Id := Ada_Naming_Exceptions.Get (VMS_Name);
6575 if Info_Id /= No_Ada_Naming_Exception then
6576 Exception_Id := Info_Id;
6577 Unit_Name := No_Name;
6578 Unit_Kind := Specification;
6579 Needs_Pragma := True;
6583 Needs_Pragma := False;
6584 Exception_Id := No_Ada_Naming_Exception;
6586 Get_Name_String (Canonical_File_Name);
6588 -- How about some comments and a name for this declare block ???
6589 -- In fact the whole code below needs more comments ???
6592 File : String := Name_Buffer (1 .. Name_Len);
6593 First : constant Positive := File'First;
6594 Last : Natural := File'Last;
6595 Standard_GNAT : Boolean;
6596 Spec : constant File_Name_Type :=
6597 Spec_Suffix_Id_Of (In_Tree, Name_Ada, Naming);
6598 Body_Suff : constant File_Name_Type :=
6599 Body_Suffix_Id_Of (In_Tree, Name_Ada, Naming);
6602 Standard_GNAT := Spec = Default_Ada_Spec_Suffix
6603 and then Body_Suff = Default_Ada_Body_Suffix;
6606 Spec_Suffix : constant String := Get_Name_String (Spec);
6607 Body_Suffix : constant String := Get_Name_String (Body_Suff);
6608 Sep_Suffix : constant String :=
6609 Get_Name_String (Naming.Separate_Suffix);
6611 May_Be_Spec : Boolean;
6612 May_Be_Body : Boolean;
6613 May_Be_Sep : Boolean;
6617 File'Length > Spec_Suffix'Length
6619 File (Last - Spec_Suffix'Length + 1 .. Last) = Spec_Suffix;
6622 File'Length > Body_Suffix'Length
6624 File (Last - Body_Suffix'Length + 1 .. Last) = Body_Suffix;
6627 File'Length > Sep_Suffix'Length
6629 File (Last - Sep_Suffix'Length + 1 .. Last) = Sep_Suffix;
6631 -- If two May_Be_ booleans are True, always choose the longer one
6634 if May_Be_Body and then
6635 Spec_Suffix'Length < Body_Suffix'Length
6637 Unit_Kind := Body_Part;
6639 if May_Be_Sep and then
6640 Body_Suffix'Length < Sep_Suffix'Length
6642 Last := Last - Sep_Suffix'Length;
6643 May_Be_Body := False;
6646 Last := Last - Body_Suffix'Length;
6647 May_Be_Sep := False;
6650 elsif May_Be_Sep and then
6651 Spec_Suffix'Length < Sep_Suffix'Length
6653 Unit_Kind := Body_Part;
6654 Last := Last - Sep_Suffix'Length;
6657 Unit_Kind := Specification;
6658 Last := Last - Spec_Suffix'Length;
6661 elsif May_Be_Body then
6662 Unit_Kind := Body_Part;
6664 if May_Be_Sep and then
6665 Body_Suffix'Length < Sep_Suffix'Length
6667 Last := Last - Sep_Suffix'Length;
6668 May_Be_Body := False;
6670 Last := Last - Body_Suffix'Length;
6671 May_Be_Sep := False;
6674 elsif May_Be_Sep then
6675 Unit_Kind := Body_Part;
6676 Last := Last - Sep_Suffix'Length;
6684 -- This is not a source file
6686 Unit_Name := No_Name;
6687 Unit_Kind := Specification;
6689 if Current_Verbosity = High then
6690 Write_Line (" Not a valid file name.");
6695 elsif Current_Verbosity = High then
6697 when Specification =>
6698 Write_Str (" Specification: ");
6699 Write_Line (File (First .. Last + Spec_Suffix'Length));
6703 Write_Str (" Body: ");
6704 Write_Line (File (First .. Last + Body_Suffix'Length));
6707 Write_Str (" Separate: ");
6708 Write_Line (File (First .. Last + Sep_Suffix'Length));
6714 Get_Name_String (Naming.Dot_Replacement);
6716 Standard_GNAT and then Name_Buffer (1 .. Name_Len) = "-";
6718 if Name_Buffer (1 .. Name_Len) /= "." then
6720 -- If Dot_Replacement is not a single dot, then there should not
6721 -- be any dot in the name.
6723 for Index in First .. Last loop
6724 if File (Index) = '.' then
6725 if Current_Verbosity = High then
6727 (" Not a valid file name (some dot not replaced).");
6730 Unit_Name := No_Name;
6736 -- Replace the substring Dot_Replacement with dots
6739 Index : Positive := First;
6742 while Index <= Last - Name_Len + 1 loop
6744 if File (Index .. Index + Name_Len - 1) =
6745 Name_Buffer (1 .. Name_Len)
6747 File (Index) := '.';
6749 if Name_Len > 1 and then Index < Last then
6750 File (Index + 1 .. Last - Name_Len + 1) :=
6751 File (Index + Name_Len .. Last);
6754 Last := Last - Name_Len + 1;
6762 -- Check if the casing is right
6765 Src : String := File (First .. Last);
6766 Src_Last : Positive := Last;
6769 case Naming.Casing is
6770 when All_Lower_Case =>
6773 Mapping => Lower_Case_Map);
6775 when All_Upper_Case =>
6778 Mapping => Upper_Case_Map);
6780 when Mixed_Case | Unknown =>
6784 if Src /= File (First .. Last) then
6785 if Current_Verbosity = High then
6786 Write_Line (" Not a valid file name (casing).");
6789 Unit_Name := No_Name;
6793 -- We put the name in lower case
6797 Mapping => Lower_Case_Map);
6799 -- In the standard GNAT naming scheme, check for special cases:
6800 -- children or separates of A, G, I or S, and run time sources.
6802 if Standard_GNAT and then Src'Length >= 3 then
6804 S1 : constant Character := Src (Src'First);
6805 S2 : constant Character := Src (Src'First + 1);
6806 S3 : constant Character := Src (Src'First + 2);
6814 -- Children or separates of packages A, G, I or S. These
6815 -- names are x__ ... or x~... (where x is a, g, i, or s).
6816 -- Both versions (x__... and x~...) are allowed in all
6817 -- platforms, because it is not possible to know the
6818 -- platform before processing of the project files.
6820 if S2 = '_' and then S3 = '_' then
6821 Src (Src'First + 1) := '.';
6822 Src_Last := Src_Last - 1;
6823 Src (Src'First + 2 .. Src_Last) :=
6824 Src (Src'First + 3 .. Src_Last + 1);
6827 Src (Src'First + 1) := '.';
6829 -- If it is potentially a run time source, disable
6830 -- filling of the mapping file to avoid warnings.
6833 Set_Mapping_File_Initial_State_To_Empty;
6839 if Current_Verbosity = High then
6841 Write_Line (Src (Src'First .. Src_Last));
6844 -- Now, we check if this name is a valid unit name
6847 (Name => Src (Src'First .. Src_Last), Unit => Unit_Name);
6857 function Hash (Unit : Unit_Info) return Header_Num is
6859 return Header_Num (Unit.Unit mod 2048);
6862 -----------------------
6863 -- Is_Illegal_Suffix --
6864 -----------------------
6866 function Is_Illegal_Suffix
6868 Dot_Replacement_Is_A_Single_Dot : Boolean) return Boolean
6871 if Suffix'Length = 0 or else Index (Suffix, ".") = 0 then
6875 -- If dot replacement is a single dot, and first character of suffix is
6878 if Dot_Replacement_Is_A_Single_Dot
6879 and then Suffix (Suffix'First) = '.'
6881 for Index in Suffix'First + 1 .. Suffix'Last loop
6883 -- If there is another dot
6885 if Suffix (Index) = '.' then
6887 -- It is illegal to have a letter following the initial dot
6889 return Is_Letter (Suffix (Suffix'First + 1));
6897 end Is_Illegal_Suffix;
6899 ----------------------
6900 -- Locate_Directory --
6901 ----------------------
6903 procedure Locate_Directory
6904 (Project : Project_Id;
6905 In_Tree : Project_Tree_Ref;
6906 Name : File_Name_Type;
6907 Parent : Path_Name_Type;
6908 Dir : out Path_Name_Type;
6909 Display : out Path_Name_Type;
6910 Create : String := "";
6911 Current_Dir : String;
6912 Location : Source_Ptr := No_Location)
6914 The_Parent : constant String :=
6915 Get_Name_String (Parent) & Directory_Separator;
6917 The_Parent_Last : constant Natural :=
6918 Compute_Directory_Last (The_Parent);
6920 Full_Name : File_Name_Type;
6922 The_Name : File_Name_Type;
6925 Get_Name_String (Name);
6927 -- Add Subdirs.all if it is a directory that may be created and
6928 -- Subdirs is not null;
6930 if Create /= "" and then Subdirs /= null then
6931 if Name_Buffer (Name_Len) /= Directory_Separator then
6932 Add_Char_To_Name_Buffer (Directory_Separator);
6935 Add_Str_To_Name_Buffer (Subdirs.all);
6938 -- Convert '/' to directory separator (for Windows)
6940 for J in 1 .. Name_Len loop
6941 if Name_Buffer (J) = '/' then
6942 Name_Buffer (J) := Directory_Separator;
6946 The_Name := Name_Find;
6948 if Current_Verbosity = High then
6949 Write_Str ("Locate_Directory (""");
6950 Write_Str (Get_Name_String (The_Name));
6951 Write_Str (""", """);
6952 Write_Str (The_Parent);
6959 if Is_Absolute_Path (Get_Name_String (The_Name)) then
6960 Full_Name := The_Name;
6964 Add_Str_To_Name_Buffer
6965 (The_Parent (The_Parent'First .. The_Parent_Last));
6966 Add_Str_To_Name_Buffer (Get_Name_String (The_Name));
6967 Full_Name := Name_Find;
6971 Full_Path_Name : constant String := Get_Name_String (Full_Name);
6974 if (Setup_Projects or else Subdirs /= null)
6975 and then Create'Length > 0
6976 and then not Is_Directory (Full_Path_Name)
6979 Create_Path (Full_Path_Name);
6981 if not Quiet_Output then
6983 Write_Str (" directory """);
6984 Write_Str (Full_Path_Name);
6985 Write_Line (""" created");
6992 "could not create " & Create &
6993 " directory " & Full_Path_Name,
6998 if Is_Directory (Full_Path_Name) then
7000 Normed : constant String :=
7003 Directory => Current_Dir,
7004 Resolve_Links => False,
7005 Case_Sensitive => True);
7007 Canonical_Path : constant String :=
7010 Directory => Current_Dir,
7012 Opt.Follow_Links_For_Dirs,
7013 Case_Sensitive => False);
7016 Name_Len := Normed'Length;
7017 Name_Buffer (1 .. Name_Len) := Normed;
7018 Display := Name_Find;
7020 Name_Len := Canonical_Path'Length;
7021 Name_Buffer (1 .. Name_Len) := Canonical_Path;
7026 end Locate_Directory;
7028 ---------------------------
7029 -- Find_Excluded_Sources --
7030 ---------------------------
7032 procedure Find_Excluded_Sources
7033 (Project : Project_Id;
7034 In_Tree : Project_Tree_Ref;
7035 Data : Project_Data)
7037 Excluded_Sources : Variable_Value;
7039 Excluded_Source_List_File : Variable_Value;
7041 Current : String_List_Id;
7043 Element : String_Element;
7045 Location : Source_Ptr;
7047 Name : File_Name_Type;
7049 File : Prj.Util.Text_File;
7050 Line : String (1 .. 300);
7053 Locally_Removed : Boolean := False;
7055 Excluded_Source_List_File :=
7057 (Name_Excluded_Source_List_File, Data.Decl.Attributes, In_Tree);
7061 (Name_Excluded_Source_Files, Data.Decl.Attributes, In_Tree);
7063 -- If Excluded_Source_Files is not declared, check
7064 -- Locally_Removed_Files.
7066 if Excluded_Sources.Default then
7067 Locally_Removed := True;
7070 (Name_Locally_Removed_Files, Data.Decl.Attributes, In_Tree);
7073 Excluded_Sources_Htable.Reset;
7075 -- If there are excluded sources, put them in the table
7077 if not Excluded_Sources.Default then
7078 if not Excluded_Source_List_File.Default then
7079 if Locally_Removed then
7082 "?both attributes Locally_Removed_Files and " &
7083 "Excluded_Source_List_File are present",
7084 Excluded_Source_List_File.Location);
7088 "?both attributes Excluded_Source_Files and " &
7089 "Excluded_Source_List_File are present",
7090 Excluded_Source_List_File.Location);
7094 Current := Excluded_Sources.Values;
7095 while Current /= Nil_String loop
7096 Element := In_Tree.String_Elements.Table (Current);
7098 if Osint.File_Names_Case_Sensitive then
7099 Name := File_Name_Type (Element.Value);
7101 Get_Name_String (Element.Value);
7102 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
7106 -- If the element has no location, then use the location
7107 -- of Excluded_Sources to report possible errors.
7109 if Element.Location = No_Location then
7110 Location := Excluded_Sources.Location;
7112 Location := Element.Location;
7115 Excluded_Sources_Htable.Set (Name, (Name, False, Location));
7116 Current := Element.Next;
7119 elsif not Excluded_Source_List_File.Default then
7120 Location := Excluded_Source_List_File.Location;
7123 Source_File_Path_Name : constant String :=
7126 (Excluded_Source_List_File.Value),
7127 Data.Directory.Name);
7130 if Source_File_Path_Name'Length = 0 then
7131 Err_Vars.Error_Msg_File_1 :=
7132 File_Name_Type (Excluded_Source_List_File.Value);
7135 "file with excluded sources { does not exist",
7136 Excluded_Source_List_File.Location);
7141 Prj.Util.Open (File, Source_File_Path_Name);
7143 if not Prj.Util.Is_Valid (File) then
7145 (Project, In_Tree, "file does not exist", Location);
7147 -- Read the lines one by one
7149 while not Prj.Util.End_Of_File (File) loop
7150 Prj.Util.Get_Line (File, Line, Last);
7152 -- A non empty, non comment line should contain a file
7156 and then (Last = 1 or else Line (1 .. 2) /= "--")
7159 Name_Buffer (1 .. Name_Len) := Line (1 .. Last);
7160 Canonical_Case_File_Name
7161 (Name_Buffer (1 .. Name_Len));
7164 -- Check that there is no directory information
7166 for J in 1 .. Last loop
7168 or else Line (J) = Directory_Separator
7170 Error_Msg_File_1 := Name;
7174 "file name cannot include " &
7175 "directory information ({)",
7181 Excluded_Sources_Htable.Set
7182 (Name, (Name, False, Location));
7186 Prj.Util.Close (File);
7191 end Find_Excluded_Sources;
7193 ---------------------------
7194 -- Find_Explicit_Sources --
7195 ---------------------------
7197 procedure Find_Explicit_Sources
7198 (Current_Dir : String;
7199 Project : Project_Id;
7200 In_Tree : Project_Tree_Ref;
7201 Data : in out Project_Data)
7203 Sources : constant Variable_Value :=
7206 Data.Decl.Attributes,
7208 Source_List_File : constant Variable_Value :=
7210 (Name_Source_List_File,
7211 Data.Decl.Attributes,
7213 Name_Loc : Name_Location;
7216 pragma Assert (Sources.Kind = List, "Source_Files is not a list");
7218 (Source_List_File.Kind = Single,
7219 "Source_List_File is not a single string");
7221 -- If the user has specified a Sources attribute
7223 if not Sources.Default then
7224 if not Source_List_File.Default then
7227 "?both attributes source_files and " &
7228 "source_list_file are present",
7229 Source_List_File.Location);
7232 -- Sources is a list of file names
7235 Current : String_List_Id := Sources.Values;
7236 Element : String_Element;
7237 Location : Source_Ptr;
7238 Name : File_Name_Type;
7241 if Get_Mode = Ada_Only then
7242 Data.Ada_Sources_Present := Current /= Nil_String;
7245 if Get_Mode = Multi_Language then
7246 if Current = Nil_String then
7247 Data.First_Language_Processing := No_Language_Index;
7249 -- This project contains no source. For projects that
7250 -- don't extend other projects, this also means that
7251 -- there is no need for an object directory, if not
7254 if Data.Extends = No_Project
7255 and then Data.Object_Directory = Data.Directory
7257 Data.Object_Directory := No_Path_Information;
7262 while Current /= Nil_String loop
7263 Element := In_Tree.String_Elements.Table (Current);
7264 Get_Name_String (Element.Value);
7266 if Osint.File_Names_Case_Sensitive then
7267 Name := File_Name_Type (Element.Value);
7269 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
7273 -- If the element has no location, then use the
7274 -- location of Sources to report possible errors.
7276 if Element.Location = No_Location then
7277 Location := Sources.Location;
7279 Location := Element.Location;
7282 -- Check that there is no directory information
7284 for J in 1 .. Name_Len loop
7285 if Name_Buffer (J) = '/'
7286 or else Name_Buffer (J) = Directory_Separator
7288 Error_Msg_File_1 := Name;
7292 "file name cannot include directory " &
7299 -- In Multi_Language mode, check whether the file is
7300 -- already there: the same file name may be in the list; if
7301 -- the source is missing, the error will be on the first
7302 -- mention of the source file name.
7306 Name_Loc := No_Name_Location;
7307 when Multi_Language =>
7308 Name_Loc := Source_Names.Get (Name);
7311 if Name_Loc = No_Name_Location then
7314 Location => Location,
7315 Source => No_Source,
7318 Source_Names.Set (Name, Name_Loc);
7321 Current := Element.Next;
7324 if Get_Mode = Ada_Only then
7325 Get_Path_Names_And_Record_Ada_Sources
7326 (Project, In_Tree, Data, Current_Dir);
7330 -- If we have no Source_Files attribute, check the Source_List_File
7333 elsif not Source_List_File.Default then
7335 -- Source_List_File is the name of the file
7336 -- that contains the source file names
7339 Source_File_Path_Name : constant String :=
7341 (File_Name_Type (Source_List_File.Value), Data.Directory.Name);
7344 if Source_File_Path_Name'Length = 0 then
7345 Err_Vars.Error_Msg_File_1 :=
7346 File_Name_Type (Source_List_File.Value);
7349 "file with sources { does not exist",
7350 Source_List_File.Location);
7353 Get_Sources_From_File
7354 (Source_File_Path_Name, Source_List_File.Location,
7357 if Get_Mode = Ada_Only then
7358 -- Look in the source directories to find those sources
7360 Get_Path_Names_And_Record_Ada_Sources
7361 (Project, In_Tree, Data, Current_Dir);
7367 -- Neither Source_Files nor Source_List_File has been
7368 -- specified. Find all the files that satisfy the naming
7369 -- scheme in all the source directories.
7371 if Get_Mode = Ada_Only then
7372 Find_Ada_Sources (Project, In_Tree, Data, Current_Dir);
7376 if Get_Mode = Multi_Language then
7378 (Project, In_Tree, Data,
7380 Sources.Default and then Source_List_File.Default);
7382 -- Check if all exceptions have been found.
7383 -- For Ada, it is an error if an exception is not found.
7384 -- For other language, the source is simply removed.
7388 Src_Data : Source_Data;
7391 Source := Data.First_Source;
7392 while Source /= No_Source loop
7393 Src_Data := In_Tree.Sources.Table (Source);
7395 if Src_Data.Naming_Exception
7396 and then Src_Data.Path = No_Path_Information
7398 if Src_Data.Unit /= No_Name then
7399 Error_Msg_Name_1 := Name_Id (Src_Data.Display_File);
7400 Error_Msg_Name_2 := Name_Id (Src_Data.Unit);
7403 "source file %% for unit %% not found",
7407 Remove_Source (Source, No_Source, Project, Data, In_Tree);
7410 Source := Src_Data.Next_In_Project;
7414 -- Check that all sources in Source_Files or the file
7415 -- Source_List_File has been found.
7418 Name_Loc : Name_Location;
7421 Name_Loc := Source_Names.Get_First;
7422 while Name_Loc /= No_Name_Location loop
7423 if (not Name_Loc.Except) and then (not Name_Loc.Found) then
7424 Error_Msg_Name_1 := Name_Id (Name_Loc.Name);
7428 "file %% not found",
7432 Name_Loc := Source_Names.Get_Next;
7437 if Get_Mode = Ada_Only
7438 and then Data.Extends = No_Project
7440 -- We should have found at least one source, if not report an error
7442 if Data.Ada_Sources = Nil_String then
7444 (Project, "Ada", In_Tree, Source_List_File.Location);
7448 end Find_Explicit_Sources;
7450 -------------------------------------------
7451 -- Get_Path_Names_And_Record_Ada_Sources --
7452 -------------------------------------------
7454 procedure Get_Path_Names_And_Record_Ada_Sources
7455 (Project : Project_Id;
7456 In_Tree : Project_Tree_Ref;
7457 Data : in out Project_Data;
7458 Current_Dir : String)
7460 Source_Dir : String_List_Id;
7461 Element : String_Element;
7462 Path : Path_Name_Type;
7464 Name : File_Name_Type;
7465 Canonical_Name : File_Name_Type;
7466 Name_Str : String (1 .. 1_024);
7467 Last : Natural := 0;
7469 Current_Source : String_List_Id := Nil_String;
7470 First_Error : Boolean := True;
7471 Source_Recorded : Boolean := False;
7474 -- We look in all source directories for the file names in the hash
7475 -- table Source_Names.
7477 Source_Dir := Data.Source_Dirs;
7478 while Source_Dir /= Nil_String loop
7479 Source_Recorded := False;
7480 Element := In_Tree.String_Elements.Table (Source_Dir);
7483 Dir_Path : constant String :=
7484 Get_Name_String (Element.Display_Value);
7486 if Current_Verbosity = High then
7487 Write_Str ("checking directory """);
7488 Write_Str (Dir_Path);
7492 Open (Dir, Dir_Path);
7495 Read (Dir, Name_Str, Last);
7499 Name_Buffer (1 .. Name_Len) := Name_Str (1 .. Last);
7502 if Osint.File_Names_Case_Sensitive then
7503 Canonical_Name := Name;
7505 Canonical_Case_File_Name (Name_Str (1 .. Last));
7506 Name_Buffer (1 .. Name_Len) := Name_Str (1 .. Last);
7507 Canonical_Name := Name_Find;
7510 NL := Source_Names.Get (Canonical_Name);
7512 if NL /= No_Name_Location and then not NL.Found then
7514 Source_Names.Set (Canonical_Name, NL);
7515 Name_Len := Dir_Path'Length;
7516 Name_Buffer (1 .. Name_Len) := Dir_Path;
7518 if Name_Buffer (Name_Len) /= Directory_Separator then
7519 Add_Char_To_Name_Buffer (Directory_Separator);
7522 Add_Str_To_Name_Buffer (Name_Str (1 .. Last));
7525 if Current_Verbosity = High then
7526 Write_Str (" found ");
7527 Write_Line (Get_Name_String (Name));
7530 -- Register the source if it is an Ada compilation unit
7538 Location => NL.Location,
7539 Current_Source => Current_Source,
7540 Source_Recorded => Source_Recorded,
7541 Current_Dir => Current_Dir);
7548 if Source_Recorded then
7549 In_Tree.String_Elements.Table (Source_Dir).Flag :=
7553 Source_Dir := Element.Next;
7556 -- It is an error if a source file name in a source list or
7557 -- in a source list file is not found.
7559 NL := Source_Names.Get_First;
7560 while NL /= No_Name_Location loop
7561 if not NL.Found then
7562 Err_Vars.Error_Msg_File_1 := NL.Name;
7567 "source file { cannot be found",
7569 First_Error := False;
7574 "\source file { cannot be found",
7579 NL := Source_Names.Get_Next;
7581 end Get_Path_Names_And_Record_Ada_Sources;
7583 --------------------------
7584 -- Check_Naming_Schemes --
7585 --------------------------
7587 procedure Check_Naming_Schemes
7588 (In_Tree : Project_Tree_Ref;
7589 Data : in out Project_Data;
7591 File_Name : File_Name_Type;
7592 Alternate_Languages : out Alternate_Language_Id;
7593 Language : out Language_Index;
7594 Language_Name : out Name_Id;
7595 Display_Language_Name : out Name_Id;
7597 Lang_Kind : out Language_Kind;
7598 Kind : out Source_Kind)
7600 Last : Positive := Filename'Last;
7601 Config : Language_Config;
7602 Lang : Name_List_Index := Data.Languages;
7603 Header_File : Boolean := False;
7604 First_Language : Language_Index;
7607 Last_Spec : Natural;
7608 Last_Body : Natural;
7613 Alternate_Languages := No_Alternate_Language;
7615 while Lang /= No_Name_List loop
7616 Language_Name := In_Tree.Name_Lists.Table (Lang).Name;
7617 Language := Data.First_Language_Processing;
7619 if Current_Verbosity = High then
7621 (" Testing language "
7622 & Get_Name_String (Language_Name)
7623 & " Header_File=" & Header_File'Img);
7626 while Language /= No_Language_Index loop
7627 if In_Tree.Languages_Data.Table (Language).Name =
7630 Display_Language_Name :=
7631 In_Tree.Languages_Data.Table (Language).Display_Name;
7632 Config := In_Tree.Languages_Data.Table (Language).Config;
7633 Lang_Kind := Config.Kind;
7635 if Config.Kind = File_Based then
7637 -- For file based languages, there is no Unit. Just
7638 -- check if the file name has the implementation or,
7639 -- if it is specified, the template suffix of the
7645 and then Config.Naming_Data.Body_Suffix /= No_File
7648 Impl_Suffix : constant String :=
7649 Get_Name_String (Config.Naming_Data.Body_Suffix);
7652 if Filename'Length > Impl_Suffix'Length
7655 (Last - Impl_Suffix'Length + 1 .. Last) =
7660 if Current_Verbosity = High then
7661 Write_Str (" source of language ");
7663 (Get_Name_String (Display_Language_Name));
7671 if Config.Naming_Data.Spec_Suffix /= No_File then
7673 Spec_Suffix : constant String :=
7675 (Config.Naming_Data.Spec_Suffix);
7678 if Filename'Length > Spec_Suffix'Length
7681 (Last - Spec_Suffix'Length + 1 .. Last) =
7686 if Current_Verbosity = High then
7687 Write_Str (" header file of language ");
7689 (Get_Name_String (Display_Language_Name));
7693 Alternate_Language_Table.Increment_Last
7694 (In_Tree.Alt_Langs);
7695 In_Tree.Alt_Langs.Table
7696 (Alternate_Language_Table.Last
7697 (In_Tree.Alt_Langs)) :=
7698 (Language => Language,
7699 Next => Alternate_Languages);
7700 Alternate_Languages :=
7701 Alternate_Language_Table.Last
7702 (In_Tree.Alt_Langs);
7704 Header_File := True;
7705 First_Language := Language;
7711 elsif not Header_File then
7712 -- Unit based language
7714 OK := Config.Naming_Data.Dot_Replacement /= No_File;
7719 -- ??? Are we doing this once per file in the project ?
7720 -- It should be done only once per project.
7722 case Config.Naming_Data.Casing is
7723 when All_Lower_Case =>
7724 for J in Filename'Range loop
7725 if Is_Letter (Filename (J)) then
7726 if not Is_Lower (Filename (J)) then
7733 when All_Upper_Case =>
7734 for J in Filename'Range loop
7735 if Is_Letter (Filename (J)) then
7736 if not Is_Upper (Filename (J)) then
7752 Last_Spec := Natural'Last;
7753 Last_Body := Natural'Last;
7754 Last_Sep := Natural'Last;
7756 if Config.Naming_Data.Separate_Suffix /= No_File
7758 Config.Naming_Data.Separate_Suffix /=
7759 Config.Naming_Data.Body_Suffix
7762 Suffix : constant String :=
7764 (Config.Naming_Data.Separate_Suffix);
7766 if Filename'Length > Suffix'Length
7769 (Last - Suffix'Length + 1 .. Last) =
7772 Last_Sep := Last - Suffix'Length;
7777 if Config.Naming_Data.Body_Suffix /= No_File then
7779 Suffix : constant String :=
7781 (Config.Naming_Data.Body_Suffix);
7783 if Filename'Length > Suffix'Length
7786 (Last - Suffix'Length + 1 .. Last) =
7789 Last_Body := Last - Suffix'Length;
7794 if Config.Naming_Data.Spec_Suffix /= No_File then
7796 Suffix : constant String :=
7798 (Config.Naming_Data.Spec_Suffix);
7800 if Filename'Length > Suffix'Length
7803 (Last - Suffix'Length + 1 .. Last) =
7806 Last_Spec := Last - Suffix'Length;
7812 Last_Min : constant Natural :=
7813 Natural'Min (Natural'Min (Last_Spec,
7818 OK := Last_Min < Last;
7823 if Last_Min = Last_Spec then
7826 elsif Last_Min = Last_Body then
7838 -- Replace dot replacements with dots
7843 J : Positive := Filename'First;
7845 Dot_Replacement : constant String :=
7847 (Config.Naming_Data.
7850 Max : constant Positive :=
7851 Last - Dot_Replacement'Length + 1;
7855 Name_Len := Name_Len + 1;
7857 if J <= Max and then
7859 (J .. J + Dot_Replacement'Length - 1) =
7862 Name_Buffer (Name_Len) := '.';
7863 J := J + Dot_Replacement'Length;
7866 if Filename (J) = '.' then
7871 Name_Buffer (Name_Len) :=
7872 GNAT.Case_Util.To_Lower (Filename (J));
7883 -- The name buffer should contain the name of the
7884 -- the unit, if it is one.
7886 -- Check that this is a valid unit name
7888 Check_Ada_Name (Name_Buffer (1 .. Name_Len), Unit);
7890 if Unit /= No_Name then
7892 if Current_Verbosity = High then
7894 Write_Str (" spec of ");
7896 Write_Str (" body of ");
7899 Write_Str (Get_Name_String (Unit));
7900 Write_Str (" (language ");
7902 (Get_Name_String (Display_Language_Name));
7906 -- Comments required, declare block should
7910 Unit_Except : constant Unit_Exception :=
7911 Unit_Exceptions.Get (Unit);
7913 procedure Masked_Unit (Spec : Boolean);
7914 -- Indicate that there is an exception for
7915 -- the same unit, so the file is not a
7916 -- source for the unit.
7922 procedure Masked_Unit (Spec : Boolean) is
7924 if Current_Verbosity = High then
7926 Write_Str (Filename);
7927 Write_Str (""" contains the ");
7936 (" of a unit that is found in """);
7941 (Unit_Except.Spec));
7945 (Unit_Except.Impl));
7948 Write_Line (""" (ignored)");
7951 Language := No_Language_Index;
7956 if Unit_Except.Spec /= No_File
7957 and then Unit_Except.Spec /= File_Name
7959 Masked_Unit (Spec => True);
7963 if Unit_Except.Impl /= No_File
7964 and then Unit_Except.Impl /= File_Name
7966 Masked_Unit (Spec => False);
7977 Language := In_Tree.Languages_Data.Table (Language).Next;
7980 Lang := In_Tree.Name_Lists.Table (Lang).Next;
7983 -- Comment needed here ???
7986 Language := First_Language;
7989 Language := No_Language_Index;
7991 if Current_Verbosity = High then
7992 Write_Line (" not a source of any language");
7995 end Check_Naming_Schemes;
8001 procedure Check_File
8002 (Project : Project_Id;
8003 In_Tree : Project_Tree_Ref;
8004 Data : in out Project_Data;
8006 File_Name : File_Name_Type;
8007 Display_File_Name : File_Name_Type;
8008 Source_Directory : String;
8009 For_All_Sources : Boolean)
8011 Display_Path : constant String :=
8014 Directory => Source_Directory,
8015 Resolve_Links => Opt.Follow_Links_For_Files,
8016 Case_Sensitive => True);
8018 Name_Loc : Name_Location := Source_Names.Get (File_Name);
8019 Path_Id : Path_Name_Type;
8020 Display_Path_Id : Path_Name_Type;
8021 Check_Name : Boolean := False;
8022 Alternate_Languages : Alternate_Language_Id := No_Alternate_Language;
8023 Language : Language_Index;
8025 Other_Part : Source_Id;
8027 Src_Ind : Source_File_Index;
8028 Src_Data : Source_Data;
8030 Source_To_Replace : Source_Id := No_Source;
8031 Language_Name : Name_Id;
8032 Display_Language_Name : Name_Id;
8033 Lang_Kind : Language_Kind;
8034 Kind : Source_Kind := Spec;
8037 Name_Len := Display_Path'Length;
8038 Name_Buffer (1 .. Name_Len) := Display_Path;
8039 Display_Path_Id := Name_Find;
8041 if Osint.File_Names_Case_Sensitive then
8042 Path_Id := Display_Path_Id;
8044 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
8045 Path_Id := Name_Find;
8048 if Name_Loc = No_Name_Location then
8049 Check_Name := For_All_Sources;
8052 if Name_Loc.Found then
8054 -- Check if it is OK to have the same file name in several
8055 -- source directories.
8057 if not Data.Known_Order_Of_Source_Dirs then
8058 Error_Msg_File_1 := File_Name;
8061 "{ is found in several source directories",
8066 Name_Loc.Found := True;
8068 Source_Names.Set (File_Name, Name_Loc);
8070 if Name_Loc.Source = No_Source then
8074 In_Tree.Sources.Table (Name_Loc.Source).Path :=
8075 (Path_Id, Display_Path_Id);
8077 Source_Paths_Htable.Set
8078 (In_Tree.Source_Paths_HT,
8082 -- Check if this is a subunit
8084 if In_Tree.Sources.Table (Name_Loc.Source).Unit /= No_Name
8086 In_Tree.Sources.Table (Name_Loc.Source).Kind = Impl
8088 Src_Ind := Sinput.P.Load_Project_File
8089 (Get_Name_String (Path_Id));
8091 if Sinput.P.Source_File_Is_Subunit (Src_Ind) then
8092 In_Tree.Sources.Table (Name_Loc.Source).Kind := Sep;
8100 Other_Part := No_Source;
8102 Check_Naming_Schemes
8103 (In_Tree => In_Tree,
8105 Filename => Get_Name_String (File_Name),
8106 File_Name => File_Name,
8107 Alternate_Languages => Alternate_Languages,
8108 Language => Language,
8109 Language_Name => Language_Name,
8110 Display_Language_Name => Display_Language_Name,
8112 Lang_Kind => Lang_Kind,
8115 if Language = No_Language_Index then
8117 -- A file name in a list must be a source of a language
8119 if Name_Loc.Found then
8120 Error_Msg_File_1 := File_Name;
8124 "language unknown for {",
8129 -- Check if the same file name or unit is used in the prj tree
8131 Source := In_Tree.First_Source;
8133 while Source /= No_Source loop
8134 Src_Data := In_Tree.Sources.Table (Source);
8137 and then Src_Data.Unit = Unit
8139 ((Src_Data.Kind = Spec and then Kind = Impl)
8141 (Src_Data.Kind = Impl and then Kind = Spec))
8143 Other_Part := Source;
8145 elsif (Unit /= No_Name
8146 and then Src_Data.Unit = Unit
8148 (Src_Data.Kind = Kind
8150 (Src_Data.Kind = Sep and then Kind = Impl)
8152 (Src_Data.Kind = Impl and then Kind = Sep)))
8153 or else (Unit = No_Name and then Src_Data.File = File_Name)
8155 -- Duplication of file/unit in same project is only
8156 -- allowed if order of source directories is known.
8158 if Project = Src_Data.Project then
8159 if Data.Known_Order_Of_Source_Dirs then
8162 elsif Unit /= No_Name then
8163 Error_Msg_Name_1 := Unit;
8165 (Project, In_Tree, "duplicate unit %%", No_Location);
8169 Error_Msg_File_1 := File_Name;
8171 (Project, In_Tree, "duplicate source file name {",
8176 -- Do not allow the same unit name in different
8177 -- projects, except if one is extending the other.
8179 -- For a file based language, the same file name
8180 -- replaces a file in a project being extended, but
8181 -- it is allowed to have the same file name in
8182 -- unrelated projects.
8185 (Project, Src_Data.Project, In_Tree)
8187 Source_To_Replace := Source;
8189 elsif Unit /= No_Name
8190 and then not Src_Data.Locally_Removed
8192 Error_Msg_Name_1 := Unit;
8195 "unit %% cannot belong to several projects",
8198 Error_Msg_Name_1 := In_Tree.Projects.Table (Project).Name;
8199 Error_Msg_Name_2 := Name_Id (Display_Path_Id);
8201 (Project, In_Tree, "\ project %%, %%", No_Location);
8204 In_Tree.Projects.Table (Src_Data.Project).Name;
8205 Error_Msg_Name_2 := Name_Id (Src_Data.Path.Display_Name);
8207 (Project, In_Tree, "\ project %%, %%", No_Location);
8213 Source := Src_Data.Next_In_Sources;
8222 Lang => Language_Name,
8223 Lang_Id => Language,
8224 Lang_Kind => Lang_Kind,
8226 Alternate_Languages => Alternate_Languages,
8227 File_Name => File_Name,
8228 Display_File => Display_File_Name,
8229 Other_Part => Other_Part,
8232 Display_Path => Display_Path_Id,
8233 Source_To_Replace => Source_To_Replace);
8239 ------------------------
8240 -- Search_Directories --
8241 ------------------------
8243 procedure Search_Directories
8244 (Project : Project_Id;
8245 In_Tree : Project_Tree_Ref;
8246 Data : in out Project_Data;
8247 For_All_Sources : Boolean)
8249 Source_Dir : String_List_Id;
8250 Element : String_Element;
8252 Name : String (1 .. 1_000);
8254 File_Name : File_Name_Type;
8255 Display_File_Name : File_Name_Type;
8258 if Current_Verbosity = High then
8259 Write_Line ("Looking for sources:");
8262 -- Loop through subdirectories
8264 Source_Dir := Data.Source_Dirs;
8265 while Source_Dir /= Nil_String loop
8267 Element := In_Tree.String_Elements.Table (Source_Dir);
8268 if Element.Value /= No_Name then
8269 Get_Name_String (Element.Display_Value);
8272 Source_Directory : constant String :=
8273 Name_Buffer (1 .. Name_Len) &
8274 Directory_Separator;
8276 Dir_Last : constant Natural :=
8277 Compute_Directory_Last
8281 if Current_Verbosity = High then
8282 Write_Str ("Source_Dir = ");
8283 Write_Line (Source_Directory);
8286 -- We look to every entry in the source directory
8288 Open (Dir, Source_Directory);
8291 Read (Dir, Name, Last);
8295 -- ??? Duplicate system call here, we just did a
8296 -- a similar one. Maybe Ada.Directories would be more
8300 (Source_Directory & Name (1 .. Last))
8302 if Current_Verbosity = High then
8303 Write_Str (" Checking ");
8304 Write_Line (Name (1 .. Last));
8308 Name_Buffer (1 .. Name_Len) := Name (1 .. Last);
8309 Display_File_Name := Name_Find;
8311 if Osint.File_Names_Case_Sensitive then
8312 File_Name := Display_File_Name;
8314 Canonical_Case_File_Name
8315 (Name_Buffer (1 .. Name_Len));
8316 File_Name := Name_Find;
8321 Excluded_Sources_Htable.Get (File_Name);
8324 if FF /= No_File_Found then
8325 if not FF.Found then
8327 Excluded_Sources_Htable.Set
8330 if Current_Verbosity = High then
8331 Write_Str (" excluded source """);
8332 Write_Str (Get_Name_String (File_Name));
8339 (Project => Project,
8342 Name => Name (1 .. Last),
8343 File_Name => File_Name,
8344 Display_File_Name => Display_File_Name,
8345 Source_Directory => Source_Directory
8346 (Source_Directory'First .. Dir_Last),
8347 For_All_Sources => For_All_Sources);
8358 when Directory_Error =>
8362 Source_Dir := Element.Next;
8365 if Current_Verbosity = High then
8366 Write_Line ("end Looking for sources.");
8368 end Search_Directories;
8370 ----------------------
8371 -- Look_For_Sources --
8372 ----------------------
8374 procedure Look_For_Sources
8375 (Project : Project_Id;
8376 In_Tree : Project_Tree_Ref;
8377 Data : in out Project_Data;
8378 Current_Dir : String)
8380 procedure Remove_Locally_Removed_Files_From_Units;
8381 -- Mark all locally removed sources as such in the Units table
8383 procedure Process_Sources_In_Multi_Language_Mode;
8384 -- Find all source files when in multi language mode
8386 ---------------------------------------------
8387 -- Remove_Locally_Removed_Files_From_Units --
8388 ---------------------------------------------
8390 procedure Remove_Locally_Removed_Files_From_Units is
8391 Excluded : File_Found;
8394 Extended : Project_Id;
8397 Excluded := Excluded_Sources_Htable.Get_First;
8398 while Excluded /= No_File_Found loop
8402 for Index in Unit_Table.First ..
8403 Unit_Table.Last (In_Tree.Units)
8405 Unit := In_Tree.Units.Table (Index);
8407 for Kind in Spec_Or_Body'Range loop
8408 if Unit.File_Names (Kind).Name = Excluded.File then
8411 -- Check that this is from the current project or
8412 -- that the current project extends.
8414 Extended := Unit.File_Names (Kind).Project;
8416 if Extended = Project
8417 or else Project_Extends (Project, Extended, In_Tree)
8419 Unit.File_Names (Kind).Path.Name := Slash;
8420 Unit.File_Names (Kind).Needs_Pragma := False;
8421 In_Tree.Units.Table (Index) := Unit;
8422 Add_Forbidden_File_Name
8423 (Unit.File_Names (Kind).Name);
8427 "cannot remove a source from " &
8434 end loop For_Each_Unit;
8437 Err_Vars.Error_Msg_File_1 := Excluded.File;
8439 (Project, In_Tree, "unknown file {", Excluded.Location);
8442 Excluded := Excluded_Sources_Htable.Get_Next;
8444 end Remove_Locally_Removed_Files_From_Units;
8446 --------------------------------------------
8447 -- Process_Sources_In_Multi_Language_Mode --
8448 --------------------------------------------
8450 procedure Process_Sources_In_Multi_Language_Mode is
8452 Src_Data : Source_Data;
8453 Name_Loc : Name_Location;
8458 -- First, put all naming exceptions if any, in the Source_Names table
8460 Unit_Exceptions.Reset;
8462 Source := Data.First_Source;
8463 while Source /= No_Source loop
8464 Src_Data := In_Tree.Sources.Table (Source);
8466 -- A file that is excluded cannot also be an exception file name
8468 if Excluded_Sources_Htable.Get (Src_Data.File) /=
8471 Error_Msg_File_1 := Src_Data.File;
8474 "{ cannot be both excluded and an exception file name",
8478 Name_Loc := (Name => Src_Data.File,
8479 Location => No_Location,
8481 Except => Src_Data.Unit /= No_Name,
8484 if Current_Verbosity = High then
8485 Write_Str ("Putting source #");
8486 Write_Str (Source'Img);
8487 Write_Str (", file ");
8488 Write_Str (Get_Name_String (Src_Data.File));
8489 Write_Line (" in Source_Names");
8492 Source_Names.Set (K => Src_Data.File, E => Name_Loc);
8494 -- If this is an Ada exception, record it in table Unit_Exceptions
8496 if Src_Data.Unit /= No_Name then
8498 Unit_Except : Unit_Exception :=
8499 Unit_Exceptions.Get (Src_Data.Unit);
8502 Unit_Except.Name := Src_Data.Unit;
8504 if Src_Data.Kind = Spec then
8505 Unit_Except.Spec := Src_Data.File;
8507 Unit_Except.Impl := Src_Data.File;
8510 Unit_Exceptions.Set (Src_Data.Unit, Unit_Except);
8514 Source := Src_Data.Next_In_Project;
8517 Find_Explicit_Sources
8518 (Current_Dir, Project, In_Tree, Data);
8520 -- Mark as such the sources that are declared as excluded
8522 FF := Excluded_Sources_Htable.Get_First;
8523 while FF /= No_File_Found loop
8525 Source := In_Tree.First_Source;
8527 while Source /= No_Source loop
8528 Src_Data := In_Tree.Sources.Table (Source);
8530 if Src_Data.File = FF.File then
8532 -- Check that this is from this project or a project that
8533 -- the current project extends.
8535 if Src_Data.Project = Project or else
8536 Is_Extending (Project, Src_Data.Project, In_Tree)
8538 Src_Data.Locally_Removed := True;
8539 Src_Data.In_Interfaces := False;
8540 In_Tree.Sources.Table (Source) := Src_Data;
8541 Add_Forbidden_File_Name (FF.File);
8547 Source := Src_Data.Next_In_Sources;
8550 if not FF.Found and not OK then
8551 Err_Vars.Error_Msg_File_1 := FF.File;
8552 Error_Msg (Project, In_Tree, "unknown file {", FF.Location);
8555 FF := Excluded_Sources_Htable.Get_Next;
8558 -- Check that two sources of this project do not have the same object
8561 Check_Object_File_Names : declare
8563 Src_Data : Source_Data;
8564 Source_Name : File_Name_Type;
8566 procedure Check_Object;
8567 -- Check if object file name of the current source is already in
8568 -- hash table Object_File_Names. If it is, report an error. If it
8569 -- is not, put it there with the file name of the current source.
8575 procedure Check_Object is
8577 Source_Name := Object_File_Names.Get (Src_Data.Object);
8579 if Source_Name /= No_File then
8580 Error_Msg_File_1 := Src_Data.File;
8581 Error_Msg_File_2 := Source_Name;
8585 "{ and { have the same object file name",
8589 Object_File_Names.Set (Src_Data.Object, Src_Data.File);
8593 -- Start of processing for Check_Object_File_Names
8596 Object_File_Names.Reset;
8597 Src_Id := In_Tree.First_Source;
8598 while Src_Id /= No_Source loop
8599 Src_Data := In_Tree.Sources.Table (Src_Id);
8601 if Src_Data.Compiled and then Src_Data.Object_Exists
8602 and then Project_Extends (Project, Src_Data.Project, In_Tree)
8604 if Src_Data.Unit = No_Name then
8605 if Src_Data.Kind = Impl then
8610 case Src_Data.Kind is
8612 if Src_Data.Other_Part = No_Source then
8620 if Src_Data.Other_Part /= No_Source then
8624 -- Check if it is a subunit
8627 Src_Ind : constant Source_File_Index :=
8628 Sinput.P.Load_Project_File
8630 (Src_Data.Path.Name));
8633 if Sinput.P.Source_File_Is_Subunit
8636 In_Tree.Sources.Table (Src_Id).Kind := Sep;
8646 Src_Id := Src_Data.Next_In_Sources;
8648 end Check_Object_File_Names;
8649 end Process_Sources_In_Multi_Language_Mode;
8651 -- Start of processing for Look_For_Sources
8655 Find_Excluded_Sources (Project, In_Tree, Data);
8659 if Is_A_Language (In_Tree, Data, Name_Ada) then
8660 Find_Explicit_Sources (Current_Dir, Project, In_Tree, Data);
8661 Remove_Locally_Removed_Files_From_Units;
8664 when Multi_Language =>
8665 if Data.First_Language_Processing /= No_Language_Index then
8666 Process_Sources_In_Multi_Language_Mode;
8669 end Look_For_Sources;
8675 function Path_Name_Of
8676 (File_Name : File_Name_Type;
8677 Directory : Path_Name_Type) return String
8679 Result : String_Access;
8680 The_Directory : constant String := Get_Name_String (Directory);
8683 Get_Name_String (File_Name);
8686 (File_Name => Name_Buffer (1 .. Name_Len),
8687 Path => The_Directory);
8689 if Result = null then
8692 Canonical_Case_File_Name (Result.all);
8697 -------------------------------
8698 -- Prepare_Ada_Naming_Exceptions --
8699 -------------------------------
8701 procedure Prepare_Ada_Naming_Exceptions
8702 (List : Array_Element_Id;
8703 In_Tree : Project_Tree_Ref;
8704 Kind : Spec_Or_Body)
8706 Current : Array_Element_Id;
8707 Element : Array_Element;
8711 -- Traverse the list
8714 while Current /= No_Array_Element loop
8715 Element := In_Tree.Array_Elements.Table (Current);
8717 if Element.Index /= No_Name then
8720 Unit => Element.Index,
8721 Next => No_Ada_Naming_Exception);
8722 Reverse_Ada_Naming_Exceptions.Set
8723 (Unit, (Element.Value.Value, Element.Value.Index));
8725 Ada_Naming_Exceptions.Get (File_Name_Type (Element.Value.Value));
8726 Ada_Naming_Exception_Table.Increment_Last;
8727 Ada_Naming_Exception_Table.Table
8728 (Ada_Naming_Exception_Table.Last) := Unit;
8729 Ada_Naming_Exceptions.Set
8730 (File_Name_Type (Element.Value.Value),
8731 Ada_Naming_Exception_Table.Last);
8734 Current := Element.Next;
8736 end Prepare_Ada_Naming_Exceptions;
8738 ---------------------
8739 -- Project_Extends --
8740 ---------------------
8742 function Project_Extends
8743 (Extending : Project_Id;
8744 Extended : Project_Id;
8745 In_Tree : Project_Tree_Ref) return Boolean
8747 Current : Project_Id := Extending;
8751 if Current = No_Project then
8754 elsif Current = Extended then
8758 Current := In_Tree.Projects.Table (Current).Extends;
8760 end Project_Extends;
8762 -----------------------
8763 -- Record_Ada_Source --
8764 -----------------------
8766 procedure Record_Ada_Source
8767 (File_Name : File_Name_Type;
8768 Path_Name : Path_Name_Type;
8769 Project : Project_Id;
8770 In_Tree : Project_Tree_Ref;
8771 Data : in out Project_Data;
8772 Location : Source_Ptr;
8773 Current_Source : in out String_List_Id;
8774 Source_Recorded : in out Boolean;
8775 Current_Dir : String)
8777 Canonical_File_Name : File_Name_Type;
8778 Canonical_Path_Name : Path_Name_Type;
8780 Exception_Id : Ada_Naming_Exception_Id;
8781 Unit_Name : Name_Id;
8782 Unit_Kind : Spec_Or_Body;
8783 Unit_Ind : Int := 0;
8785 Name_Index : Name_And_Index;
8786 Needs_Pragma : Boolean;
8788 The_Location : Source_Ptr := Location;
8789 Previous_Source : constant String_List_Id := Current_Source;
8790 Except_Name : Name_And_Index := No_Name_And_Index;
8792 Unit_Prj : Unit_Project;
8794 File_Name_Recorded : Boolean := False;
8797 if Osint.File_Names_Case_Sensitive then
8798 Canonical_File_Name := File_Name;
8799 Canonical_Path_Name := Path_Name;
8801 Get_Name_String (File_Name);
8802 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
8803 Canonical_File_Name := Name_Find;
8806 Canonical_Path : constant String :=
8808 (Get_Name_String (Path_Name),
8809 Directory => Current_Dir,
8810 Resolve_Links => Opt.Follow_Links_For_Files,
8811 Case_Sensitive => False);
8814 Add_Str_To_Name_Buffer (Canonical_Path);
8815 Canonical_Path_Name := Name_Find;
8819 -- Find out the unit name, the unit kind and if it needs
8820 -- a specific SFN pragma.
8823 (In_Tree => In_Tree,
8824 Canonical_File_Name => Canonical_File_Name,
8825 Naming => Data.Naming,
8826 Exception_Id => Exception_Id,
8827 Unit_Name => Unit_Name,
8828 Unit_Kind => Unit_Kind,
8829 Needs_Pragma => Needs_Pragma);
8831 if Exception_Id = No_Ada_Naming_Exception
8832 and then Unit_Name = No_Name
8834 if Current_Verbosity = High then
8836 Write_Str (Get_Name_String (Canonical_File_Name));
8837 Write_Line (""" is not a valid source file name (ignored).");
8841 -- Check to see if the source has been hidden by an exception,
8842 -- but only if it is not an exception.
8844 if not Needs_Pragma then
8846 Reverse_Ada_Naming_Exceptions.Get
8847 ((Unit_Kind, Unit_Name, No_Ada_Naming_Exception));
8849 if Except_Name /= No_Name_And_Index then
8850 if Current_Verbosity = High then
8852 Write_Str (Get_Name_String (Canonical_File_Name));
8853 Write_Str (""" contains a unit that is found in """);
8854 Write_Str (Get_Name_String (Except_Name.Name));
8855 Write_Line (""" (ignored).");
8858 -- The file is not included in the source of the project since
8859 -- it is hidden by the exception. So, nothing else to do.
8866 if Exception_Id /= No_Ada_Naming_Exception then
8867 Info := Ada_Naming_Exception_Table.Table (Exception_Id);
8868 Exception_Id := Info.Next;
8869 Info.Next := No_Ada_Naming_Exception;
8870 Name_Index := Reverse_Ada_Naming_Exceptions.Get (Info);
8872 Unit_Name := Info.Unit;
8873 Unit_Ind := Name_Index.Index;
8874 Unit_Kind := Info.Kind;
8877 -- Put the file name in the list of sources of the project
8879 String_Element_Table.Increment_Last (In_Tree.String_Elements);
8880 In_Tree.String_Elements.Table
8881 (String_Element_Table.Last (In_Tree.String_Elements)) :=
8882 (Value => Name_Id (Canonical_File_Name),
8883 Display_Value => Name_Id (File_Name),
8884 Location => No_Location,
8889 if Current_Source = Nil_String then
8891 String_Element_Table.Last (In_Tree.String_Elements);
8893 In_Tree.String_Elements.Table (Current_Source).Next :=
8894 String_Element_Table.Last (In_Tree.String_Elements);
8898 String_Element_Table.Last (In_Tree.String_Elements);
8900 -- Put the unit in unit list
8903 The_Unit : Unit_Index :=
8904 Units_Htable.Get (In_Tree.Units_HT, Unit_Name);
8906 The_Unit_Data : Unit_Data;
8909 if Current_Verbosity = High then
8910 Write_Str ("Putting ");
8911 Write_Str (Get_Name_String (Unit_Name));
8912 Write_Line (" in the unit list.");
8915 -- The unit is already in the list, but may be it is
8916 -- only the other unit kind (spec or body), or what is
8917 -- in the unit list is a unit of a project we are extending.
8919 if The_Unit /= No_Unit_Index then
8920 The_Unit_Data := In_Tree.Units.Table (The_Unit);
8922 if (The_Unit_Data.File_Names (Unit_Kind).Name =
8925 The_Unit_Data.File_Names
8926 (Unit_Kind).Path.Name = Slash)
8927 or else The_Unit_Data.File_Names (Unit_Kind).Name = No_File
8928 or else Project_Extends
8930 The_Unit_Data.File_Names (Unit_Kind).Project,
8934 The_Unit_Data.File_Names (Unit_Kind).Path.Name = Slash
8936 Remove_Forbidden_File_Name
8937 (The_Unit_Data.File_Names (Unit_Kind).Name);
8940 -- Record the file name in the hash table Files_Htable
8942 Unit_Prj := (Unit => The_Unit, Project => Project);
8945 Canonical_File_Name,
8948 The_Unit_Data.File_Names (Unit_Kind) :=
8949 (Name => Canonical_File_Name,
8951 Display_Name => File_Name,
8952 Path => (Canonical_Path_Name, Path_Name),
8954 Needs_Pragma => Needs_Pragma);
8955 In_Tree.Units.Table (The_Unit) := The_Unit_Data;
8956 Source_Recorded := True;
8958 elsif The_Unit_Data.File_Names (Unit_Kind).Project = Project
8959 and then (Data.Known_Order_Of_Source_Dirs
8961 The_Unit_Data.File_Names
8962 (Unit_Kind).Path.Name = Canonical_Path_Name)
8964 if Previous_Source = Nil_String then
8965 Data.Ada_Sources := Nil_String;
8967 In_Tree.String_Elements.Table (Previous_Source).Next :=
8969 String_Element_Table.Decrement_Last
8970 (In_Tree.String_Elements);
8973 Current_Source := Previous_Source;
8976 -- It is an error to have two units with the same name
8977 -- and the same kind (spec or body).
8979 if The_Location = No_Location then
8981 In_Tree.Projects.Table (Project).Location;
8984 Err_Vars.Error_Msg_Name_1 := Unit_Name;
8986 (Project, In_Tree, "duplicate unit %%", The_Location);
8988 Err_Vars.Error_Msg_Name_1 :=
8989 In_Tree.Projects.Table
8990 (The_Unit_Data.File_Names (Unit_Kind).Project).Name;
8991 Err_Vars.Error_Msg_File_1 :=
8993 (The_Unit_Data.File_Names (Unit_Kind).Path.Name);
8996 "\ project file %%, {", The_Location);
8998 Err_Vars.Error_Msg_Name_1 :=
8999 In_Tree.Projects.Table (Project).Name;
9000 Err_Vars.Error_Msg_File_1 :=
9001 File_Name_Type (Canonical_Path_Name);
9004 "\ project file %%, {", The_Location);
9007 -- It is a new unit, create a new record
9010 -- First, check if there is no other unit with this file
9011 -- name in another project. If it is, report error but note
9012 -- we do that only for the first unit in the source file.
9015 Files_Htable.Get (In_Tree.Files_HT, Canonical_File_Name);
9017 if not File_Name_Recorded and then
9018 Unit_Prj /= No_Unit_Project
9020 Error_Msg_File_1 := File_Name;
9022 In_Tree.Projects.Table (Unit_Prj.Project).Name;
9025 "{ is already a source of project %%",
9029 Unit_Table.Increment_Last (In_Tree.Units);
9030 The_Unit := Unit_Table.Last (In_Tree.Units);
9032 (In_Tree.Units_HT, Unit_Name, The_Unit);
9033 Unit_Prj := (Unit => The_Unit, Project => Project);
9036 Canonical_File_Name,
9038 The_Unit_Data.Name := Unit_Name;
9039 The_Unit_Data.File_Names (Unit_Kind) :=
9040 (Name => Canonical_File_Name,
9042 Display_Name => File_Name,
9043 Path => (Canonical_Path_Name, Path_Name),
9045 Needs_Pragma => Needs_Pragma);
9046 In_Tree.Units.Table (The_Unit) := The_Unit_Data;
9047 Source_Recorded := True;
9052 exit when Exception_Id = No_Ada_Naming_Exception;
9053 File_Name_Recorded := True;
9056 end Record_Ada_Source;
9062 procedure Remove_Source
9064 Replaced_By : Source_Id;
9065 Project : Project_Id;
9066 Data : in out Project_Data;
9067 In_Tree : Project_Tree_Ref)
9069 Src_Data : constant Source_Data := In_Tree.Sources.Table (Id);
9073 if Current_Verbosity = High then
9074 Write_Str ("Removing source #");
9075 Write_Line (Id'Img);
9078 if Replaced_By /= No_Source then
9079 In_Tree.Sources.Table (Id).Replaced_By := Replaced_By;
9080 In_Tree.Sources.Table (Replaced_By).Declared_In_Interfaces :=
9081 In_Tree.Sources.Table (Id).Declared_In_Interfaces;
9084 -- Remove the source from the global source list
9086 Source := In_Tree.First_Source;
9089 In_Tree.First_Source := Src_Data.Next_In_Sources;
9092 while In_Tree.Sources.Table (Source).Next_In_Sources /= Id loop
9093 Source := In_Tree.Sources.Table (Source).Next_In_Sources;
9096 In_Tree.Sources.Table (Source).Next_In_Sources :=
9097 Src_Data.Next_In_Sources;
9100 -- Remove the source from the project list
9102 if Src_Data.Project = Project then
9103 Source := Data.First_Source;
9106 Data.First_Source := Src_Data.Next_In_Project;
9108 if Src_Data.Next_In_Project = No_Source then
9109 Data.Last_Source := No_Source;
9113 while In_Tree.Sources.Table (Source).Next_In_Project /= Id loop
9114 Source := In_Tree.Sources.Table (Source).Next_In_Project;
9117 In_Tree.Sources.Table (Source).Next_In_Project :=
9118 Src_Data.Next_In_Project;
9120 if Src_Data.Next_In_Project = No_Source then
9121 In_Tree.Projects.Table (Src_Data.Project).Last_Source := Source;
9126 Source := In_Tree.Projects.Table (Src_Data.Project).First_Source;
9129 In_Tree.Projects.Table (Src_Data.Project).First_Source :=
9130 Src_Data.Next_In_Project;
9132 if Src_Data.Next_In_Project = No_Source then
9133 In_Tree.Projects.Table (Src_Data.Project).Last_Source :=
9138 while In_Tree.Sources.Table (Source).Next_In_Project /= Id loop
9139 Source := In_Tree.Sources.Table (Source).Next_In_Project;
9142 In_Tree.Sources.Table (Source).Next_In_Project :=
9143 Src_Data.Next_In_Project;
9145 if Src_Data.Next_In_Project = No_Source then
9146 In_Tree.Projects.Table (Src_Data.Project).Last_Source := Source;
9151 -- Remove source from the language list
9153 Source := In_Tree.Languages_Data.Table (Src_Data.Language).First_Source;
9156 In_Tree.Languages_Data.Table (Src_Data.Language).First_Source :=
9157 Src_Data.Next_In_Lang;
9160 while In_Tree.Sources.Table (Source).Next_In_Lang /= Id loop
9161 Source := In_Tree.Sources.Table (Source).Next_In_Lang;
9164 In_Tree.Sources.Table (Source).Next_In_Lang :=
9165 Src_Data.Next_In_Lang;
9169 -----------------------
9170 -- Report_No_Sources --
9171 -----------------------
9173 procedure Report_No_Sources
9174 (Project : Project_Id;
9176 In_Tree : Project_Tree_Ref;
9177 Location : Source_Ptr;
9178 Continuation : Boolean := False)
9181 case When_No_Sources is
9185 when Warning | Error =>
9187 Msg : constant String :=
9190 " sources in this project";
9193 Error_Msg_Warn := When_No_Sources = Warning;
9195 if Continuation then
9197 (Project, In_Tree, "\" & Msg, Location);
9201 (Project, In_Tree, Msg, Location);
9205 end Report_No_Sources;
9207 ----------------------
9208 -- Show_Source_Dirs --
9209 ----------------------
9211 procedure Show_Source_Dirs
9212 (Data : Project_Data;
9213 In_Tree : Project_Tree_Ref)
9215 Current : String_List_Id;
9216 Element : String_Element;
9219 Write_Line ("Source_Dirs:");
9221 Current := Data.Source_Dirs;
9222 while Current /= Nil_String loop
9223 Element := In_Tree.String_Elements.Table (Current);
9225 Write_Line (Get_Name_String (Element.Value));
9226 Current := Element.Next;
9229 Write_Line ("end Source_Dirs.");
9230 end Show_Source_Dirs;
9232 -------------------------
9233 -- Warn_If_Not_Sources --
9234 -------------------------
9236 -- comments needed in this body ???
9238 procedure Warn_If_Not_Sources
9239 (Project : Project_Id;
9240 In_Tree : Project_Tree_Ref;
9241 Conventions : Array_Element_Id;
9243 Extending : Boolean)
9245 Conv : Array_Element_Id;
9247 The_Unit_Id : Unit_Index;
9248 The_Unit_Data : Unit_Data;
9249 Location : Source_Ptr;
9252 Conv := Conventions;
9253 while Conv /= No_Array_Element loop
9254 Unit := In_Tree.Array_Elements.Table (Conv).Index;
9255 Error_Msg_Name_1 := Unit;
9256 Get_Name_String (Unit);
9257 To_Lower (Name_Buffer (1 .. Name_Len));
9259 The_Unit_Id := Units_Htable.Get (In_Tree.Units_HT, Unit);
9260 Location := In_Tree.Array_Elements.Table (Conv).Value.Location;
9262 if The_Unit_Id = No_Unit_Index then
9263 Error_Msg (Project, In_Tree, "?unknown unit %%", Location);
9266 The_Unit_Data := In_Tree.Units.Table (The_Unit_Id);
9268 In_Tree.Array_Elements.Table (Conv).Value.Value;
9271 if not Check_Project
9272 (The_Unit_Data.File_Names (Specification).Project,
9273 Project, In_Tree, Extending)
9277 "?source of spec of unit %% (%%)" &
9278 " cannot be found in this project",
9283 if not Check_Project
9284 (The_Unit_Data.File_Names (Body_Part).Project,
9285 Project, In_Tree, Extending)
9289 "?source of body of unit %% (%%)" &
9290 " cannot be found in this project",
9296 Conv := In_Tree.Array_Elements.Table (Conv).Next;
9298 end Warn_If_Not_Sources;