1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2003 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Namet; use Namet;
29 with Osint; use Osint;
30 with Output; use Output;
31 with Prj.Com; use Prj.Com;
35 with GNAT.OS_Lib; use GNAT.OS_Lib;
37 package body Prj.Env is
39 type Naming_Id is new Nat;
41 Current_Source_Path_File : Name_Id := No_Name;
42 -- Current value of project source path file env var.
43 -- Used to avoid setting the env var to the same value.
45 Current_Object_Path_File : Name_Id := No_Name;
46 -- Current value of project object path file env var.
47 -- Used to avoid setting the env var to the same value.
49 Ada_Path_Buffer : String_Access := new String (1 .. 1024);
50 -- A buffer where values for ADA_INCLUDE_PATH
51 -- and ADA_OBJECTS_PATH are stored.
53 Ada_Path_Length : Natural := 0;
54 -- Index of the last valid character in Ada_Path_Buffer.
56 Ada_Prj_Include_File_Set : Boolean := False;
57 Ada_Prj_Objects_File_Set : Boolean := False;
58 -- These flags are set to True when the corresponding environment variables
59 -- are set and are used to give these environment variables an empty string
60 -- value at the end of the program. This has no practical effect on most
61 -- platforms, except on VMS where the logical names are deassigned, thus
62 -- avoiding the pollution of the environment of the caller.
64 package Namings is new Table.Table (
65 Table_Component_Type => Naming_Data,
66 Table_Index_Type => Naming_Id,
69 Table_Increment => 100,
70 Table_Name => "Prj.Env.Namings");
72 Default_Naming : constant Naming_Id := Namings.First;
74 Fill_Mapping_File : Boolean := True;
76 package Path_Files is new Table.Table (
77 Table_Component_Type => Name_Id,
78 Table_Index_Type => Natural,
81 Table_Increment => 50,
82 Table_Name => "Prj.Env.Path_Files");
83 -- Table storing all the temp path file names.
84 -- Used by Delete_All_Path_Files.
86 type Project_Flags is array (Project_Id range <>) of Boolean;
87 -- A Boolean array type used in Create_Mapping_File to select the projects
88 -- in the closure of a specific project.
90 -----------------------
91 -- Local Subprograms --
92 -----------------------
94 function Body_Path_Name_Of (Unit : Unit_Id) return String;
95 -- Returns the path name of the body of a unit.
96 -- Compute it first, if necessary.
98 function Spec_Path_Name_Of (Unit : Unit_Id) return String;
99 -- Returns the path name of the spec of a unit.
100 -- Compute it first, if necessary.
102 procedure Add_To_Path (Source_Dirs : String_List_Id);
103 -- Add to Ada_Path_Buffer all the source directories in string list
104 -- Source_Dirs, if any. Increment Ada_Path_Length.
106 procedure Add_To_Path (Dir : String);
107 -- If Dir is not already in the global variable Ada_Path_Buffer, add it.
108 -- Increment Ada_Path_Length.
109 -- If Ada_Path_Length /= 0, prepend a Path_Separator character to
112 procedure Add_To_Path_File
113 (Source_Dirs : String_List_Id;
114 Path_File : File_Descriptor);
115 -- Add to Ada_Path_Buffer all the source directories in string list
116 -- Source_Dirs, if any. Increment Ada_Path_Length.
118 procedure Add_To_Path_File
120 Path_File : File_Descriptor);
121 -- Add Path to path file
123 procedure Create_New_Path_File
124 (Path_FD : out File_Descriptor;
125 Path_Name : out Name_Id);
126 -- Create a new temporary path file. Get the file name in Path_Name.
127 -- The name is normally obtained by increasing the number in
128 -- Temp_Path_File_Name by 1.
130 procedure Set_Path_File_Var (Name : String; Value : String);
131 -- Call Setenv, after calling To_Host_File_Spec
133 function Ultimate_Extension_Of (Project : in Project_Id) return Project_Id;
134 -- Return a project that is either Project or an extended ancestor of
135 -- Project that itself is not extended.
137 ----------------------
138 -- Ada_Include_Path --
139 ----------------------
141 function Ada_Include_Path (Project : Project_Id) return String_Access is
143 procedure Add (Project : Project_Id);
144 -- Add all the source directories of a project to the path only if
145 -- this project has not been visited. Calls itself recursively for
146 -- projects being extended, and imported projects. Adds the project
147 -- to the list Seen if this is the call to Add for this project.
153 procedure Add (Project : Project_Id) is
155 -- If Seen is empty, then the project cannot have been visited
157 if not Projects.Table (Project).Seen then
158 Projects.Table (Project).Seen := True;
161 Data : constant Project_Data := Projects.Table (Project);
162 List : Project_List := Data.Imported_Projects;
165 -- Add to path all source directories of this project
167 Add_To_Path (Data.Source_Dirs);
169 -- Call Add to the project being extended, if any
171 if Data.Extends /= No_Project then
175 -- Call Add for each imported project, if any
177 while List /= Empty_Project_List loop
178 Add (Project_Lists.Table (List).Project);
179 List := Project_Lists.Table (List).Next;
185 -- Start of processing for Ada_Include_Path
188 -- If it is the first time we call this function for
189 -- this project, compute the source path
191 if Projects.Table (Project).Ada_Include_Path = null then
192 Ada_Path_Length := 0;
194 for Index in 1 .. Projects.Last loop
195 Projects.Table (Index).Seen := False;
199 Projects.Table (Project).Ada_Include_Path :=
200 new String'(Ada_Path_Buffer (1 .. Ada_Path_Length));
203 return Projects.Table (Project).Ada_Include_Path;
204 end Ada_Include_Path;
206 function Ada_Include_Path
207 (Project : Project_Id;
213 return Ada_Include_Path (Project).all;
215 Ada_Path_Length := 0;
216 Add_To_Path (Projects.Table (Project).Source_Dirs);
217 return Ada_Path_Buffer (1 .. Ada_Path_Length);
219 end Ada_Include_Path;
221 ----------------------
222 -- Ada_Objects_Path --
223 ----------------------
225 function Ada_Objects_Path
226 (Project : Project_Id;
227 Including_Libraries : Boolean := True)
230 procedure Add (Project : Project_Id);
231 -- Add all the object directories of a project to the path only if
232 -- this project has not been visited. Calls itself recursively for
233 -- projects being extended, and imported projects. Adds the project
234 -- to the list Seen if this is the first call to Add for this project.
240 procedure Add (Project : Project_Id) is
242 -- If this project has not been seen yet
244 if not Projects.Table (Project).Seen then
245 Projects.Table (Project).Seen := True;
248 Data : constant Project_Data := Projects.Table (Project);
249 List : Project_List := Data.Imported_Projects;
252 -- Add to path the object directory of this project
253 -- except if we don't include library project and
254 -- this is a library project.
256 if (Data.Library and then Including_Libraries)
258 (Data.Object_Directory /= No_Name
260 (not Including_Libraries or else not Data.Library))
262 -- For a library project, add the library directory
265 Add_To_Path (Get_Name_String (Data.Library_Dir));
268 -- For a non library project, add the object directory
270 Add_To_Path (Get_Name_String (Data.Object_Directory));
274 -- Call Add to the project being extended, if any
276 if Data.Extends /= No_Project then
280 -- Call Add for each imported project, if any
282 while List /= Empty_Project_List loop
283 Add (Project_Lists.Table (List).Project);
284 List := Project_Lists.Table (List).Next;
291 -- Start of processing for Ada_Objects_Path
294 -- If it is the first time we call this function for
295 -- this project, compute the objects path
297 if Projects.Table (Project).Ada_Objects_Path = null then
298 Ada_Path_Length := 0;
300 for Index in 1 .. Projects.Last loop
301 Projects.Table (Index).Seen := False;
305 Projects.Table (Project).Ada_Objects_Path :=
306 new String'(Ada_Path_Buffer (1 .. Ada_Path_Length));
309 return Projects.Table (Project).Ada_Objects_Path;
310 end Ada_Objects_Path;
316 procedure Add_To_Path (Source_Dirs : String_List_Id) is
317 Current : String_List_Id := Source_Dirs;
318 Source_Dir : String_Element;
321 while Current /= Nil_String loop
322 Source_Dir := String_Elements.Table (Current);
323 Add_To_Path (Get_Name_String (Source_Dir.Value));
324 Current := Source_Dir.Next;
328 procedure Add_To_Path (Dir : String) is
330 New_Buffer : String_Access;
333 function Is_Present (Path : String; Dir : String) return Boolean;
334 -- Return True if Dir is part of Path
340 function Is_Present (Path : String; Dir : String) return Boolean is
341 Last : constant Integer := Path'Last - Dir'Length + 1;
343 for J in Path'First .. Last loop
344 -- Note: the order of the conditions below is important, since
345 -- it ensures a minimal number of string comparisons.
348 or else Path (J - 1) = Path_Separator)
350 (J + Dir'Length > Path'Last
351 or else Path (J + Dir'Length) = Path_Separator)
352 and then Dir = Path (J .. J + Dir'Length - 1)
362 if Is_Present (Ada_Path_Buffer (1 .. Ada_Path_Length), Dir) then
363 -- Dir is already in the path, nothing to do
368 Min_Len := Ada_Path_Length + Dir'Length;
370 if Ada_Path_Length > 0 then
371 -- Add 1 for the Path_Separator character
373 Min_Len := Min_Len + 1;
376 -- If Ada_Path_Buffer is too small, increase it
378 Len := Ada_Path_Buffer'Last;
380 if Len < Min_Len then
383 exit when Len >= Min_Len;
386 New_Buffer := new String (1 .. Len);
387 New_Buffer (1 .. Ada_Path_Length) :=
388 Ada_Path_Buffer (1 .. Ada_Path_Length);
389 Free (Ada_Path_Buffer);
390 Ada_Path_Buffer := New_Buffer;
393 if Ada_Path_Length > 0 then
394 Ada_Path_Length := Ada_Path_Length + 1;
395 Ada_Path_Buffer (Ada_Path_Length) := Path_Separator;
399 (Ada_Path_Length + 1 .. Ada_Path_Length + Dir'Length) := Dir;
400 Ada_Path_Length := Ada_Path_Length + Dir'Length;
403 ----------------------
404 -- Add_To_Path_File --
405 ----------------------
407 procedure Add_To_Path_File
408 (Source_Dirs : String_List_Id;
409 Path_File : File_Descriptor)
411 Current : String_List_Id := Source_Dirs;
412 Source_Dir : String_Element;
415 while Current /= Nil_String loop
416 Source_Dir := String_Elements.Table (Current);
417 Add_To_Path_File (Get_Name_String (Source_Dir.Value), Path_File);
418 Current := Source_Dir.Next;
420 end Add_To_Path_File;
422 procedure Add_To_Path_File
424 Path_File : File_Descriptor)
426 Line : String (1 .. Path'Length + 1);
430 Line (1 .. Path'Length) := Path;
431 Line (Line'Last) := ASCII.LF;
432 Len := Write (Path_File, Line (1)'Address, Line'Length);
434 if Len /= Line'Length then
435 Prj.Com.Fail ("disk full");
437 end Add_To_Path_File;
439 -----------------------
440 -- Body_Path_Name_Of --
441 -----------------------
443 function Body_Path_Name_Of (Unit : Unit_Id) return String is
444 Data : Unit_Data := Units.Table (Unit);
447 -- If we don't know the path name of the body of this unit,
448 -- we compute it, and we store it.
450 if Data.File_Names (Body_Part).Path = No_Name then
452 Current_Source : String_List_Id :=
453 Projects.Table (Data.File_Names (Body_Part).Project).Sources;
454 Path : GNAT.OS_Lib.String_Access;
457 -- By default, put the file name
459 Data.File_Names (Body_Part).Path :=
460 Data.File_Names (Body_Part).Name;
462 -- For each source directory
464 while Current_Source /= Nil_String loop
467 (Namet.Get_Name_String
468 (Data.File_Names (Body_Part).Name),
469 Namet.Get_Name_String
470 (String_Elements.Table (Current_Source).Value));
472 -- If the file is in this directory,
473 -- then we store the path, and we are done.
476 Name_Len := Path'Length;
477 Name_Buffer (1 .. Name_Len) := Path.all;
478 Data.File_Names (Body_Part).Path := Name_Enter;
483 String_Elements.Table (Current_Source).Next;
487 Units.Table (Unit) := Data;
491 -- Returned the value stored
493 return Namet.Get_Name_String (Data.File_Names (Body_Part).Path);
494 end Body_Path_Name_Of;
496 --------------------------------
497 -- Create_Config_Pragmas_File --
498 --------------------------------
500 procedure Create_Config_Pragmas_File
501 (For_Project : Project_Id;
502 Main_Project : Project_Id;
503 Include_Config_Files : Boolean := True)
505 pragma Unreferenced (Main_Project);
506 pragma Unreferenced (Include_Config_Files);
508 File_Name : Name_Id := No_Name;
509 File : File_Descriptor := Invalid_FD;
511 Current_Unit : Unit_Id := Units.First;
513 First_Project : Project_List := Empty_Project_List;
515 Current_Project : Project_List;
516 Current_Naming : Naming_Id;
521 procedure Check (Project : Project_Id);
523 procedure Check_Temp_File;
524 -- Check that a temporary file has been opened.
525 -- If not, create one, and put its name in the project data,
526 -- with the indication that it is a temporary file.
529 (Unit_Name : Name_Id;
531 Unit_Kind : Spec_Or_Body);
532 -- Put an SFN pragma in the temporary file.
534 procedure Put (File : File_Descriptor; S : String);
536 procedure Put_Line (File : File_Descriptor; S : String);
542 procedure Check (Project : Project_Id) is
543 Data : constant Project_Data := Projects.Table (Project);
546 if Current_Verbosity = High then
547 Write_Str ("Checking project file """);
548 Write_Str (Namet.Get_Name_String (Data.Name));
553 -- Is this project in the list of the visited project?
555 Current_Project := First_Project;
556 while Current_Project /= Empty_Project_List
557 and then Project_Lists.Table (Current_Project).Project /= Project
559 Current_Project := Project_Lists.Table (Current_Project).Next;
562 -- If it is not, put it in the list, and visit it
564 if Current_Project = Empty_Project_List then
565 Project_Lists.Increment_Last;
566 Project_Lists.Table (Project_Lists.Last) :=
567 (Project => Project, Next => First_Project);
568 First_Project := Project_Lists.Last;
570 -- Is the naming scheme of this project one that we know?
572 Current_Naming := Default_Naming;
573 while Current_Naming <= Namings.Last and then
574 not Same_Naming_Scheme
575 (Left => Namings.Table (Current_Naming),
576 Right => Data.Naming) loop
577 Current_Naming := Current_Naming + 1;
580 -- If we don't know it, add it
582 if Current_Naming > Namings.Last then
583 Namings.Increment_Last;
584 Namings.Table (Namings.Last) := Data.Naming;
586 -- We need a temporary file to be created
590 -- Put the SFN pragmas for the naming scheme
595 (File, "pragma Source_File_Name_Project");
597 (File, " (Spec_File_Name => ""*" &
598 Namet.Get_Name_String (Data.Naming.Current_Spec_Suffix) &
601 (File, " Casing => " &
602 Image (Data.Naming.Casing) & ",");
604 (File, " Dot_Replacement => """ &
605 Namet.Get_Name_String (Data.Naming.Dot_Replacement) &
611 (File, "pragma Source_File_Name_Project");
613 (File, " (Body_File_Name => ""*" &
614 Namet.Get_Name_String (Data.Naming.Current_Body_Suffix) &
617 (File, " Casing => " &
618 Image (Data.Naming.Casing) & ",");
620 (File, " Dot_Replacement => """ &
621 Namet.Get_Name_String (Data.Naming.Dot_Replacement) &
624 -- and maybe separate
627 Data.Naming.Current_Body_Suffix /= Data.Naming.Separate_Suffix
630 (File, "pragma Source_File_Name_Project");
632 (File, " (Subunit_File_Name => ""*" &
633 Namet.Get_Name_String (Data.Naming.Separate_Suffix) &
636 (File, " Casing => " &
637 Image (Data.Naming.Casing) &
640 (File, " Dot_Replacement => """ &
641 Namet.Get_Name_String (Data.Naming.Dot_Replacement) &
646 if Data.Extends /= No_Project then
647 Check (Data.Extends);
651 Current : Project_List := Data.Imported_Projects;
654 while Current /= Empty_Project_List loop
655 Check (Project_Lists.Table (Current).Project);
656 Current := Project_Lists.Table (Current).Next;
662 ---------------------
663 -- Check_Temp_File --
664 ---------------------
666 procedure Check_Temp_File is
668 if File = Invalid_FD then
669 Tempdir.Create_Temp_File (File, Name => File_Name);
671 if File = Invalid_FD then
673 ("unable to create temporary configuration pragmas file");
674 elsif Opt.Verbose_Mode then
675 Write_Str ("Creating temp file """);
676 Write_Str (Get_Name_String (File_Name));
687 (Unit_Name : Name_Id;
689 Unit_Kind : Spec_Or_Body)
692 -- A temporary file needs to be open
696 -- Put the pragma SFN for the unit kind (spec or body)
698 Put (File, "pragma Source_File_Name_Project (");
699 Put (File, Namet.Get_Name_String (Unit_Name));
701 if Unit_Kind = Specification then
702 Put (File, ", Spec_File_Name => """);
704 Put (File, ", Body_File_Name => """);
707 Put (File, Namet.Get_Name_String (File_Name));
708 Put_Line (File, """);");
711 procedure Put (File : File_Descriptor; S : String) is
715 Last := Write (File, S (S'First)'Address, S'Length);
717 if Last /= S'Length then
718 Prj.Com.Fail ("Disk full");
721 if Current_Verbosity = High then
730 procedure Put_Line (File : File_Descriptor; S : String) is
731 S0 : String (1 .. S'Length + 1);
735 -- Add an ASCII.LF to the string. As this gnat.adc is supposed to
736 -- be used only by the compiler, we don't care about the characters
737 -- for the end of line. In fact we could have put a space, but
738 -- it is more convenient to be able to read gnat.adc during
739 -- development, for which the ASCII.LF is fine.
741 S0 (1 .. S'Length) := S;
742 S0 (S0'Last) := ASCII.LF;
743 Last := Write (File, S0'Address, S0'Length);
745 if Last /= S'Length + 1 then
746 Prj.Com.Fail ("Disk full");
749 if Current_Verbosity = High then
754 -- Start of processing for Create_Config_Pragmas_File
757 if not Projects.Table (For_Project).Config_Checked then
759 -- Remove any memory of processed naming schemes, if any
761 Namings.Set_Last (Default_Naming);
763 -- Check the naming schemes
767 -- Visit all the units and process those that need an SFN pragma
769 while Current_Unit <= Units.Last loop
771 Unit : constant Unit_Data :=
772 Units.Table (Current_Unit);
775 if Unit.File_Names (Specification).Needs_Pragma then
777 Unit.File_Names (Specification).Name,
781 if Unit.File_Names (Body_Part).Needs_Pragma then
783 Unit.File_Names (Body_Part).Name,
787 Current_Unit := Current_Unit + 1;
791 -- If there are no non standard naming scheme, issue the GNAT
792 -- standard naming scheme. This will tell the compiler that
793 -- a project file is used and will forbid any pragma SFN.
795 if File = Invalid_FD then
798 Put_Line (File, "pragma Source_File_Name_Project");
799 Put_Line (File, " (Spec_File_Name => ""*.ads"",");
800 Put_Line (File, " Dot_Replacement => ""-"",");
801 Put_Line (File, " Casing => lowercase);");
803 Put_Line (File, "pragma Source_File_Name_Project");
804 Put_Line (File, " (Body_File_Name => ""*.adb"",");
805 Put_Line (File, " Dot_Replacement => ""-"",");
806 Put_Line (File, " Casing => lowercase);");
809 -- Close the temporary file
811 GNAT.OS_Lib.Close (File, Status);
814 Prj.Com.Fail ("disk full");
817 if Opt.Verbose_Mode then
818 Write_Str ("Closing configuration file """);
819 Write_Str (Get_Name_String (File_Name));
823 Projects.Table (For_Project).Config_File_Name := File_Name;
824 Projects.Table (For_Project).Config_File_Temp := True;
826 Projects.Table (For_Project).Config_Checked := True;
828 end Create_Config_Pragmas_File;
830 -------------------------
831 -- Create_Mapping_File --
832 -------------------------
834 procedure Create_Mapping_File
835 (Project : Project_Id;
838 File : File_Descriptor := Invalid_FD;
839 The_Unit_Data : Unit_Data;
840 Data : File_Name_Data;
845 Present : Project_Flags (No_Project .. Projects.Last) :=
847 -- For each project in the closure of Project, the corresponding flag
848 -- will be set to True;
850 procedure Put_Name_Buffer;
851 -- Put the line contained in the Name_Buffer in the mapping file
853 procedure Put_Data (Spec : Boolean);
854 -- Put the mapping of the spec or body contained in Data in the file
857 procedure Recursive_Flag (Prj : Project_Id);
858 -- Set the flags corresponding to Prj, the projects it imports
859 -- (directly or indirectly) or extends to True. Call itself recursively.
865 procedure Put_Name_Buffer is
869 Name_Len := Name_Len + 1;
870 Name_Buffer (Name_Len) := ASCII.LF;
871 Last := Write (File, Name_Buffer (1)'Address, Name_Len);
873 if Last /= Name_Len then
874 Prj.Com.Fail ("Disk full");
882 procedure Put_Data (Spec : Boolean) is
884 -- Line with the unit name
886 Get_Name_String (The_Unit_Data.Name);
887 Name_Len := Name_Len + 1;
888 Name_Buffer (Name_Len) := '%';
889 Name_Len := Name_Len + 1;
892 Name_Buffer (Name_Len) := 's';
894 Name_Buffer (Name_Len) := 'b';
899 -- Line with the file name
901 Get_Name_String (Data.Name);
904 -- Line with the path name
906 Get_Name_String (Data.Path);
915 procedure Recursive_Flag (Prj : Project_Id) is
916 Imported : Project_List;
920 -- Nothing to do for non existent project or project that has
921 -- already been flagged.
923 if Prj = No_Project or else Present (Prj) then
927 -- Flag the current project
929 Present (Prj) := True;
930 Imported := Projects.Table (Prj).Imported_Projects;
932 -- Call itself for each project directly imported
934 while Imported /= Empty_Project_List loop
935 Proj := Project_Lists.Table (Imported).Project;
936 Imported := Project_Lists.Table (Imported).Next;
937 Recursive_Flag (Proj);
940 -- Call itself for an eventual project being extended
942 Recursive_Flag (Projects.Table (Prj).Extends);
945 -- Start of processing for Create_Mapping_File
948 -- Flag the necessary projects
950 Recursive_Flag (Project);
952 -- Create the temporary file
954 Tempdir.Create_Temp_File (File, Name => Name);
956 if File = Invalid_FD then
957 Prj.Com.Fail ("unable to create temporary mapping file");
959 elsif Opt.Verbose_Mode then
960 Write_Str ("Creating temp mapping file """);
961 Write_Str (Get_Name_String (Name));
965 if Fill_Mapping_File then
966 -- For all units in table Units
968 for Unit in 1 .. Units.Last loop
969 The_Unit_Data := Units.Table (Unit);
971 -- If the unit has a valid name
973 if The_Unit_Data.Name /= No_Name then
974 Data := The_Unit_Data.File_Names (Specification);
976 -- If there is a spec, put it mapping in the file if it is
977 -- from a project in the closure of Project.
979 if Data.Name /= No_Name and then Present (Data.Project) then
980 Put_Data (Spec => True);
983 Data := The_Unit_Data.File_Names (Body_Part);
985 -- If there is a body (or subunit) put its mapping in the file
986 -- if it is from a project in the closure of Project.
988 if Data.Name /= No_Name and then Present (Data.Project) then
989 Put_Data (Spec => False);
996 GNAT.OS_Lib.Close (File, Status);
999 Prj.Com.Fail ("disk full");
1002 end Create_Mapping_File;
1004 --------------------------
1005 -- Create_New_Path_File --
1006 --------------------------
1008 procedure Create_New_Path_File
1009 (Path_FD : out File_Descriptor;
1010 Path_Name : out Name_Id)
1013 Tempdir.Create_Temp_File (Path_FD, Path_Name);
1015 if Path_Name /= No_Name then
1017 -- Record the name, so that the temp path file will be deleted
1018 -- at the end of the program.
1020 Path_Files.Increment_Last;
1021 Path_Files.Table (Path_Files.Last) := Path_Name;
1023 end Create_New_Path_File;
1025 ---------------------------
1026 -- Delete_All_Path_Files --
1027 ---------------------------
1029 procedure Delete_All_Path_Files is
1030 Disregard : Boolean := True;
1033 for Index in 1 .. Path_Files.Last loop
1034 if Path_Files.Table (Index) /= No_Name then
1036 (Get_Name_String (Path_Files.Table (Index)), Disregard);
1040 -- If any of the environment variables ADA_PRJ_INCLUDE_FILE or
1041 -- ADA_PRJ_OBJECTS_FILE has been set, then reset their value to
1042 -- the empty string. On VMS, this has the effect of deassigning
1043 -- the logical names.
1045 if Ada_Prj_Include_File_Set then
1046 Setenv (Project_Include_Path_File, "");
1047 Ada_Prj_Include_File_Set := False;
1050 if Ada_Prj_Objects_File_Set then
1051 Setenv (Project_Objects_Path_File, "");
1052 Ada_Prj_Objects_File_Set := False;
1054 end Delete_All_Path_Files;
1056 ------------------------------------
1057 -- File_Name_Of_Library_Unit_Body --
1058 ------------------------------------
1060 function File_Name_Of_Library_Unit_Body
1062 Project : Project_Id;
1063 Main_Project_Only : Boolean := True;
1064 Full_Path : Boolean := False)
1067 The_Project : Project_Id := Project;
1068 Data : Project_Data := Projects.Table (Project);
1069 Original_Name : String := Name;
1071 Extended_Spec_Name : String :=
1072 Name & Namet.Get_Name_String
1073 (Data.Naming.Current_Spec_Suffix);
1074 Extended_Body_Name : String :=
1075 Name & Namet.Get_Name_String
1076 (Data.Naming.Current_Body_Suffix);
1080 The_Original_Name : Name_Id;
1081 The_Spec_Name : Name_Id;
1082 The_Body_Name : Name_Id;
1085 Canonical_Case_File_Name (Original_Name);
1086 Name_Len := Original_Name'Length;
1087 Name_Buffer (1 .. Name_Len) := Original_Name;
1088 The_Original_Name := Name_Find;
1090 Canonical_Case_File_Name (Extended_Spec_Name);
1091 Name_Len := Extended_Spec_Name'Length;
1092 Name_Buffer (1 .. Name_Len) := Extended_Spec_Name;
1093 The_Spec_Name := Name_Find;
1095 Canonical_Case_File_Name (Extended_Body_Name);
1096 Name_Len := Extended_Body_Name'Length;
1097 Name_Buffer (1 .. Name_Len) := Extended_Body_Name;
1098 The_Body_Name := Name_Find;
1100 if Current_Verbosity = High then
1101 Write_Str ("Looking for file name of """);
1105 Write_Str (" Extended Spec Name = """);
1106 Write_Str (Extended_Spec_Name);
1109 Write_Str (" Extended Body Name = """);
1110 Write_Str (Extended_Body_Name);
1115 -- For extending project, search in the extended project
1116 -- if the source is not found. For non extending projects,
1117 -- this loop will be run only once.
1122 for Current in reverse Units.First .. Units.Last loop
1123 Unit := Units.Table (Current);
1127 if not Main_Project_Only
1128 or else Unit.File_Names (Body_Part).Project = The_Project
1131 Current_Name : constant Name_Id :=
1132 Unit.File_Names (Body_Part).Name;
1135 -- Case of a body present
1137 if Current_Name /= No_Name then
1138 if Current_Verbosity = High then
1139 Write_Str (" Comparing with """);
1140 Write_Str (Get_Name_String (Current_Name));
1145 -- If it has the name of the original name,
1146 -- return the original name
1148 if Unit.Name = The_Original_Name
1149 or else Current_Name = The_Original_Name
1151 if Current_Verbosity = High then
1156 return Get_Name_String
1157 (Unit.File_Names (Body_Part).Path);
1160 return Get_Name_String (Current_Name);
1163 -- If it has the name of the extended body name,
1164 -- return the extended body name
1166 elsif Current_Name = The_Body_Name then
1167 if Current_Verbosity = High then
1172 return Get_Name_String
1173 (Unit.File_Names (Body_Part).Path);
1176 return Extended_Body_Name;
1180 if Current_Verbosity = High then
1181 Write_Line (" not good");
1190 if not Main_Project_Only
1191 or else Unit.File_Names (Specification).Project = The_Project
1194 Current_Name : constant Name_Id :=
1195 Unit.File_Names (Specification).Name;
1198 -- Case of spec present
1200 if Current_Name /= No_Name then
1201 if Current_Verbosity = High then
1202 Write_Str (" Comparing with """);
1203 Write_Str (Get_Name_String (Current_Name));
1208 -- If name same as the original name, return original
1211 if Unit.Name = The_Original_Name
1212 or else Current_Name = The_Original_Name
1214 if Current_Verbosity = High then
1220 return Get_Name_String
1221 (Unit.File_Names (Specification).Path);
1224 return Get_Name_String (Current_Name);
1227 -- If it has the same name as the extended spec name,
1228 -- return the extended spec name.
1230 elsif Current_Name = The_Spec_Name then
1231 if Current_Verbosity = High then
1236 return Get_Name_String
1237 (Unit.File_Names (Specification).Path);
1240 return Extended_Spec_Name;
1244 if Current_Verbosity = High then
1245 Write_Line (" not good");
1253 -- If we are not in an extending project, give up
1255 exit when (not Main_Project_Only) or else Data.Extends = No_Project;
1257 -- Otherwise, look in the project we are extending
1259 The_Project := Data.Extends;
1260 Data := Projects.Table (The_Project);
1263 -- We don't know this file name, return an empty string
1266 end File_Name_Of_Library_Unit_Body;
1268 -------------------------
1269 -- For_All_Object_Dirs --
1270 -------------------------
1272 procedure For_All_Object_Dirs (Project : Project_Id) is
1273 Seen : Project_List := Empty_Project_List;
1275 procedure Add (Project : Project_Id);
1276 -- Process a project. Remember the processes visited to avoid
1277 -- processing a project twice. Recursively process an eventual
1278 -- extended project, and all imported projects.
1284 procedure Add (Project : Project_Id) is
1285 Data : constant Project_Data := Projects.Table (Project);
1286 List : Project_List := Data.Imported_Projects;
1289 -- If the list of visited project is empty, then
1290 -- for sure we never visited this project.
1292 if Seen = Empty_Project_List then
1293 Project_Lists.Increment_Last;
1294 Seen := Project_Lists.Last;
1295 Project_Lists.Table (Seen) :=
1296 (Project => Project, Next => Empty_Project_List);
1299 -- Check if the project is in the list
1302 Current : Project_List := Seen;
1306 -- If it is, then there is nothing else to do
1308 if Project_Lists.Table (Current).Project = Project then
1312 exit when Project_Lists.Table (Current).Next =
1314 Current := Project_Lists.Table (Current).Next;
1317 -- This project has never been visited, add it
1320 Project_Lists.Increment_Last;
1321 Project_Lists.Table (Current).Next := Project_Lists.Last;
1322 Project_Lists.Table (Project_Lists.Last) :=
1323 (Project => Project, Next => Empty_Project_List);
1327 -- If there is an object directory, call Action
1330 if Data.Object_Directory /= No_Name then
1331 Get_Name_String (Data.Object_Directory);
1332 Action (Name_Buffer (1 .. Name_Len));
1335 -- If we are extending a project, visit it
1337 if Data.Extends /= No_Project then
1341 -- And visit all imported projects
1343 while List /= Empty_Project_List loop
1344 Add (Project_Lists.Table (List).Project);
1345 List := Project_Lists.Table (List).Next;
1349 -- Start of processing for For_All_Object_Dirs
1352 -- Visit this project, and its imported projects,
1356 end For_All_Object_Dirs;
1358 -------------------------
1359 -- For_All_Source_Dirs --
1360 -------------------------
1362 procedure For_All_Source_Dirs (Project : Project_Id) is
1363 Seen : Project_List := Empty_Project_List;
1365 procedure Add (Project : Project_Id);
1366 -- Process a project. Remember the processes visited to avoid
1367 -- processing a project twice. Recursively process an eventual
1368 -- extended project, and all imported projects.
1374 procedure Add (Project : Project_Id) is
1375 Data : constant Project_Data := Projects.Table (Project);
1376 List : Project_List := Data.Imported_Projects;
1379 -- If the list of visited project is empty, then
1380 -- for sure we never visited this project.
1382 if Seen = Empty_Project_List then
1383 Project_Lists.Increment_Last;
1384 Seen := Project_Lists.Last;
1385 Project_Lists.Table (Seen) :=
1386 (Project => Project, Next => Empty_Project_List);
1389 -- Check if the project is in the list
1392 Current : Project_List := Seen;
1396 -- If it is, then there is nothing else to do
1398 if Project_Lists.Table (Current).Project = Project then
1402 exit when Project_Lists.Table (Current).Next =
1404 Current := Project_Lists.Table (Current).Next;
1407 -- This project has never been visited, add it
1410 Project_Lists.Increment_Last;
1411 Project_Lists.Table (Current).Next := Project_Lists.Last;
1412 Project_Lists.Table (Project_Lists.Last) :=
1413 (Project => Project, Next => Empty_Project_List);
1418 Current : String_List_Id := Data.Source_Dirs;
1419 The_String : String_Element;
1422 -- Call action with the name of every source directorie
1424 while Current /= Nil_String loop
1425 The_String := String_Elements.Table (Current);
1426 Action (Get_Name_String (The_String.Value));
1427 Current := The_String.Next;
1431 -- If we are extending a project, visit it
1433 if Data.Extends /= No_Project then
1437 -- And visit all imported projects
1439 while List /= Empty_Project_List loop
1440 Add (Project_Lists.Table (List).Project);
1441 List := Project_Lists.Table (List).Next;
1445 -- Start of processing for For_All_Source_Dirs
1448 -- Visit this project, and its imported projects recursively
1451 end For_All_Source_Dirs;
1457 procedure Get_Reference
1458 (Source_File_Name : String;
1459 Project : out Project_Id;
1463 if Current_Verbosity > Default then
1464 Write_Str ("Getting Reference_Of (""");
1465 Write_Str (Source_File_Name);
1466 Write_Str (""") ... ");
1470 Original_Name : String := Source_File_Name;
1474 Canonical_Case_File_Name (Original_Name);
1476 for Id in Units.First .. Units.Last loop
1477 Unit := Units.Table (Id);
1479 if (Unit.File_Names (Specification).Name /= No_Name
1481 Namet.Get_Name_String
1482 (Unit.File_Names (Specification).Name) = Original_Name)
1483 or else (Unit.File_Names (Specification).Path /= No_Name
1485 Namet.Get_Name_String
1486 (Unit.File_Names (Specification).Path) =
1489 Project := Ultimate_Extension_Of
1490 (Unit.File_Names (Specification).Project);
1491 Path := Unit.File_Names (Specification).Display_Path;
1493 if Current_Verbosity > Default then
1494 Write_Str ("Done: Specification.");
1500 elsif (Unit.File_Names (Body_Part).Name /= No_Name
1502 Namet.Get_Name_String
1503 (Unit.File_Names (Body_Part).Name) = Original_Name)
1504 or else (Unit.File_Names (Body_Part).Path /= No_Name
1505 and then Namet.Get_Name_String
1506 (Unit.File_Names (Body_Part).Path) =
1509 Project := Ultimate_Extension_Of
1510 (Unit.File_Names (Body_Part).Project);
1511 Path := Unit.File_Names (Body_Part).Display_Path;
1513 if Current_Verbosity > Default then
1514 Write_Str ("Done: Body.");
1524 Project := No_Project;
1527 if Current_Verbosity > Default then
1528 Write_Str ("Cannot be found.");
1537 procedure Initialize is
1539 -- There is nothing to do anymore
1544 ------------------------------------
1545 -- Path_Name_Of_Library_Unit_Body --
1546 ------------------------------------
1548 function Path_Name_Of_Library_Unit_Body
1550 Project : Project_Id)
1553 Data : constant Project_Data := Projects.Table (Project);
1554 Original_Name : String := Name;
1556 Extended_Spec_Name : String :=
1557 Name & Namet.Get_Name_String
1558 (Data.Naming.Current_Spec_Suffix);
1559 Extended_Body_Name : String :=
1560 Name & Namet.Get_Name_String
1561 (Data.Naming.Current_Body_Suffix);
1563 First : Unit_Id := Units.First;
1568 Canonical_Case_File_Name (Original_Name);
1569 Canonical_Case_File_Name (Extended_Spec_Name);
1570 Canonical_Case_File_Name (Extended_Body_Name);
1572 if Current_Verbosity = High then
1573 Write_Str ("Looking for path name of """);
1577 Write_Str (" Extended Spec Name = """);
1578 Write_Str (Extended_Spec_Name);
1581 Write_Str (" Extended Body Name = """);
1582 Write_Str (Extended_Body_Name);
1587 while First <= Units.Last
1588 and then Units.Table (First).File_Names (Body_Part).Project /= Project
1594 while Current <= Units.Last loop
1595 Unit := Units.Table (Current);
1597 if Unit.File_Names (Body_Part).Project = Project
1598 and then Unit.File_Names (Body_Part).Name /= No_Name
1601 Current_Name : constant String :=
1602 Namet.Get_Name_String (Unit.File_Names (Body_Part).Name);
1604 if Current_Verbosity = High then
1605 Write_Str (" Comparing with """);
1606 Write_Str (Current_Name);
1611 if Current_Name = Original_Name then
1612 if Current_Verbosity = High then
1616 return Body_Path_Name_Of (Current);
1618 elsif Current_Name = Extended_Body_Name then
1619 if Current_Verbosity = High then
1623 return Body_Path_Name_Of (Current);
1626 if Current_Verbosity = High then
1627 Write_Line (" not good");
1632 elsif Unit.File_Names (Specification).Name /= No_Name then
1634 Current_Name : constant String :=
1635 Namet.Get_Name_String
1636 (Unit.File_Names (Specification).Name);
1639 if Current_Verbosity = High then
1640 Write_Str (" Comparing with """);
1641 Write_Str (Current_Name);
1646 if Current_Name = Original_Name then
1647 if Current_Verbosity = High then
1651 return Spec_Path_Name_Of (Current);
1653 elsif Current_Name = Extended_Spec_Name then
1655 if Current_Verbosity = High then
1659 return Spec_Path_Name_Of (Current);
1662 if Current_Verbosity = High then
1663 Write_Line (" not good");
1668 Current := Current + 1;
1672 end Path_Name_Of_Library_Unit_Body;
1678 procedure Print_Sources is
1682 Write_Line ("List of Sources:");
1684 for Id in Units.First .. Units.Last loop
1685 Unit := Units.Table (Id);
1687 Write_Line (Namet.Get_Name_String (Unit.Name));
1689 if Unit.File_Names (Specification).Name /= No_Name then
1690 if Unit.File_Names (Specification).Project = No_Project then
1691 Write_Line (" No project");
1694 Write_Str (" Project: ");
1697 (Unit.File_Names (Specification).Project).Path_Name);
1698 Write_Line (Name_Buffer (1 .. Name_Len));
1701 Write_Str (" spec: ");
1703 (Namet.Get_Name_String
1704 (Unit.File_Names (Specification).Name));
1707 if Unit.File_Names (Body_Part).Name /= No_Name then
1708 if Unit.File_Names (Body_Part).Project = No_Project then
1709 Write_Line (" No project");
1712 Write_Str (" Project: ");
1715 (Unit.File_Names (Body_Part).Project).Path_Name);
1716 Write_Line (Name_Buffer (1 .. Name_Len));
1719 Write_Str (" body: ");
1721 (Namet.Get_Name_String
1722 (Unit.File_Names (Body_Part).Name));
1727 Write_Line ("end of List of Sources.");
1736 Main_Project : Project_Id)
1739 Result : Project_Id := No_Project;
1741 Original_Name : String := Name;
1743 Data : constant Project_Data := Projects.Table (Main_Project);
1745 Extended_Spec_Name : String :=
1746 Name & Namet.Get_Name_String
1747 (Data.Naming.Current_Spec_Suffix);
1748 Extended_Body_Name : String :=
1749 Name & Namet.Get_Name_String
1750 (Data.Naming.Current_Body_Suffix);
1754 Current_Name : Name_Id;
1756 The_Original_Name : Name_Id;
1757 The_Spec_Name : Name_Id;
1758 The_Body_Name : Name_Id;
1761 Canonical_Case_File_Name (Original_Name);
1762 Name_Len := Original_Name'Length;
1763 Name_Buffer (1 .. Name_Len) := Original_Name;
1764 The_Original_Name := Name_Find;
1766 Canonical_Case_File_Name (Extended_Spec_Name);
1767 Name_Len := Extended_Spec_Name'Length;
1768 Name_Buffer (1 .. Name_Len) := Extended_Spec_Name;
1769 The_Spec_Name := Name_Find;
1771 Canonical_Case_File_Name (Extended_Body_Name);
1772 Name_Len := Extended_Body_Name'Length;
1773 Name_Buffer (1 .. Name_Len) := Extended_Body_Name;
1774 The_Body_Name := Name_Find;
1776 for Current in reverse Units.First .. Units.Last loop
1777 Unit := Units.Table (Current);
1780 Current_Name := Unit.File_Names (Body_Part).Name;
1781 -- Case of a body present
1783 if Current_Name /= No_Name then
1784 -- If it has the name of the original name or the body name,
1785 -- we have found the project.
1787 if Unit.Name = The_Original_Name
1788 or else Current_Name = The_Original_Name
1789 or else Current_Name = The_Body_Name
1791 Result := Unit.File_Names (Body_Part).Project;
1798 Current_Name := Unit.File_Names (Specification).Name;
1800 if Current_Name /= No_Name then
1801 -- If name same as the original name, or the spec name, we have
1802 -- found the project.
1804 if Unit.Name = The_Original_Name
1805 or else Current_Name = The_Original_Name
1806 or else Current_Name = The_Spec_Name
1808 Result := Unit.File_Names (Specification).Project;
1814 -- Get the ultimate extending project
1816 if Result /= No_Project then
1817 while Projects.Table (Result).Extended_By /= No_Project loop
1818 Result := Projects.Table (Result).Extended_By;
1829 procedure Set_Ada_Paths
1830 (Project : Project_Id;
1831 Including_Libraries : Boolean)
1833 Source_FD : File_Descriptor := Invalid_FD;
1834 Object_FD : File_Descriptor := Invalid_FD;
1836 Process_Source_Dirs : Boolean := False;
1837 Process_Object_Dirs : Boolean := False;
1840 -- For calls to Close
1842 procedure Add (Project : Project_Id);
1843 -- Add all the source/object directories of a project to the path only
1844 -- if this project has not been visited. Calls itself recursively for
1845 -- projects being extended, and imported projects.
1851 procedure Add (Project : Project_Id) is
1853 -- If Seen is False, then the project has not yet been visited
1855 if not Projects.Table (Project).Seen then
1856 Projects.Table (Project).Seen := True;
1859 Data : constant Project_Data := Projects.Table (Project);
1860 List : Project_List := Data.Imported_Projects;
1863 if Process_Source_Dirs then
1865 -- Add to path all source directories of this project
1867 Add_To_Path_File (Data.Source_Dirs, Source_FD);
1870 if Process_Object_Dirs then
1872 -- Add to path the object directory of this project
1873 -- except if we don't include library project and
1874 -- this is a library project.
1876 if (Data.Library and then Including_Libraries)
1878 (Data.Object_Directory /= No_Name
1880 (not Including_Libraries or else not Data.Library))
1882 -- For a library project, add the library directory
1884 if Data.Library then
1886 New_Path : constant String :=
1887 Get_Name_String (Data.Library_Dir);
1890 Add_To_Path_File (New_Path, Object_FD);
1894 -- For a non library project, add the object directory
1897 New_Path : constant String :=
1898 Get_Name_String (Data.Object_Directory);
1900 Add_To_Path_File (New_Path, Object_FD);
1906 -- Call Add to the project being extended, if any
1908 if Data.Extends /= No_Project then
1912 -- Call Add for each imported project, if any
1914 while List /= Empty_Project_List loop
1915 Add (Project_Lists.Table (List).Project);
1916 List := Project_Lists.Table (List).Next;
1922 -- Start of processing for Set_Ada_Paths
1925 -- If it is the first time we call this procedure for
1926 -- this project, compute the source path and/or the object path.
1928 if Projects.Table (Project).Include_Path_File = No_Name then
1929 Process_Source_Dirs := True;
1930 Create_New_Path_File
1931 (Source_FD, Projects.Table (Project).Include_Path_File);
1934 -- For the object path, we make a distinction depending on
1935 -- Including_Libraries.
1937 if Including_Libraries then
1938 if Projects.Table (Project).Objects_Path_File_With_Libs = No_Name then
1939 Process_Object_Dirs := True;
1940 Create_New_Path_File
1941 (Object_FD, Projects.Table (Project).
1942 Objects_Path_File_With_Libs);
1947 Projects.Table (Project).Objects_Path_File_Without_Libs = No_Name
1949 Process_Object_Dirs := True;
1950 Create_New_Path_File
1951 (Object_FD, Projects.Table (Project).
1952 Objects_Path_File_Without_Libs);
1956 -- If there is something to do, set Seen to False for all projects,
1957 -- then call the recursive procedure Add for Project.
1959 if Process_Source_Dirs or Process_Object_Dirs then
1960 for Index in 1 .. Projects.Last loop
1961 Projects.Table (Index).Seen := False;
1967 -- Close any file that has been created.
1969 if Source_FD /= Invalid_FD then
1970 Close (Source_FD, Status);
1973 Prj.Com.Fail ("disk full");
1977 if Object_FD /= Invalid_FD then
1978 Close (Object_FD, Status);
1981 Prj.Com.Fail ("disk full");
1985 -- Set the env vars, if they need to be changed, and set the
1986 -- corresponding flags.
1989 Current_Source_Path_File /= Projects.Table (Project).Include_Path_File
1991 Current_Source_Path_File :=
1992 Projects.Table (Project).Include_Path_File;
1994 (Project_Include_Path_File,
1995 Get_Name_String (Current_Source_Path_File));
1996 Ada_Prj_Include_File_Set := True;
1999 if Including_Libraries then
2000 if Current_Object_Path_File
2001 /= Projects.Table (Project).Objects_Path_File_With_Libs
2003 Current_Object_Path_File :=
2004 Projects.Table (Project).Objects_Path_File_With_Libs;
2006 (Project_Objects_Path_File,
2007 Get_Name_String (Current_Object_Path_File));
2008 Ada_Prj_Objects_File_Set := True;
2012 if Current_Object_Path_File
2013 /= Projects.Table (Project).Objects_Path_File_Without_Libs
2015 Current_Object_Path_File :=
2016 Projects.Table (Project).Objects_Path_File_Without_Libs;
2018 (Project_Objects_Path_File,
2019 Get_Name_String (Current_Object_Path_File));
2020 Ada_Prj_Objects_File_Set := True;
2025 ---------------------------------------------
2026 -- Set_Mapping_File_Initial_State_To_Empty --
2027 ---------------------------------------------
2029 procedure Set_Mapping_File_Initial_State_To_Empty is
2031 Fill_Mapping_File := False;
2032 end Set_Mapping_File_Initial_State_To_Empty;
2034 -----------------------
2035 -- Set_Path_File_Var --
2036 -----------------------
2038 procedure Set_Path_File_Var (Name : String; Value : String) is
2039 Host_Spec : String_Access := To_Host_File_Spec (Value);
2042 if Host_Spec = null then
2044 ("could not convert file name """, Value, """ to host spec");
2046 Setenv (Name, Host_Spec.all);
2049 end Set_Path_File_Var;
2051 -----------------------
2052 -- Spec_Path_Name_Of --
2053 -----------------------
2055 function Spec_Path_Name_Of (Unit : Unit_Id) return String is
2056 Data : Unit_Data := Units.Table (Unit);
2059 if Data.File_Names (Specification).Path = No_Name then
2061 Current_Source : String_List_Id :=
2062 Projects.Table (Data.File_Names (Specification).Project).Sources;
2063 Path : GNAT.OS_Lib.String_Access;
2066 Data.File_Names (Specification).Path :=
2067 Data.File_Names (Specification).Name;
2069 while Current_Source /= Nil_String loop
2070 Path := Locate_Regular_File
2071 (Namet.Get_Name_String
2072 (Data.File_Names (Specification).Name),
2073 Namet.Get_Name_String
2074 (String_Elements.Table (Current_Source).Value));
2076 if Path /= null then
2077 Name_Len := Path'Length;
2078 Name_Buffer (1 .. Name_Len) := Path.all;
2079 Data.File_Names (Specification).Path := Name_Enter;
2083 String_Elements.Table (Current_Source).Next;
2087 Units.Table (Unit) := Data;
2091 return Namet.Get_Name_String (Data.File_Names (Specification).Path);
2092 end Spec_Path_Name_Of;
2094 ---------------------------
2095 -- Ultimate_Extension_Of --
2096 ---------------------------
2098 function Ultimate_Extension_Of (Project : in Project_Id) return Project_Id
2100 Result : Project_Id := Project;
2103 while Projects.Table (Result).Extended_By /= No_Project loop
2104 Result := Projects.Table (Result).Extended_By;
2108 end Ultimate_Extension_Of;
2111 Path_Files.Set_Last (0);