1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2004 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 package Source_Paths is new Table.Table
91 (Table_Component_Type => Name_Id,
92 Table_Index_Type => Natural,
95 Table_Increment => 50,
96 Table_Name => "Prj.Env.Source_Paths");
97 -- A table to store the source dirs before creating the source path file
99 package Object_Paths is new Table.Table
100 (Table_Component_Type => Name_Id,
101 Table_Index_Type => Natural,
102 Table_Low_Bound => 1,
104 Table_Increment => 50,
105 Table_Name => "Prj.Env.Source_Paths");
106 -- A table to store the object dirs, before creating the object path file
108 -----------------------
109 -- Local Subprograms --
110 -----------------------
112 function Body_Path_Name_Of (Unit : Unit_Id) return String;
113 -- Returns the path name of the body of a unit.
114 -- Compute it first, if necessary.
116 function Spec_Path_Name_Of (Unit : Unit_Id) return String;
117 -- Returns the path name of the spec of a unit.
118 -- Compute it first, if necessary.
120 procedure Add_To_Path (Source_Dirs : String_List_Id);
121 -- Add to Ada_Path_Buffer all the source directories in string list
122 -- Source_Dirs, if any. Increment Ada_Path_Length.
124 procedure Add_To_Path (Dir : String);
125 -- If Dir is not already in the global variable Ada_Path_Buffer, add it.
126 -- Increment Ada_Path_Length.
127 -- If Ada_Path_Length /= 0, prepend a Path_Separator character to
130 procedure Add_To_Source_Path (Source_Dirs : String_List_Id);
131 -- Add to Ada_Path_B all the source directories in string list
132 -- Source_Dirs, if any. Increment Ada_Path_Length.
134 procedure Add_To_Object_Path (Object_Dir : Name_Id);
135 -- Add Object_Dir to object path table. Make sure it is not duplicate
136 -- and it is the last one in the current table.
138 procedure Create_New_Path_File
139 (Path_FD : out File_Descriptor;
140 Path_Name : out Name_Id);
141 -- Create a new temporary path file. Get the file name in Path_Name.
142 -- The name is normally obtained by increasing the number in
143 -- Temp_Path_File_Name by 1.
145 procedure Set_Path_File_Var (Name : String; Value : String);
146 -- Call Setenv, after calling To_Host_File_Spec
148 function Ultimate_Extension_Of (Project : in Project_Id) return Project_Id;
149 -- Return a project that is either Project or an extended ancestor of
150 -- Project that itself is not extended.
152 ----------------------
153 -- Ada_Include_Path --
154 ----------------------
156 function Ada_Include_Path (Project : Project_Id) return String_Access is
158 procedure Add (Project : Project_Id);
159 -- Add all the source directories of a project to the path only if
160 -- this project has not been visited. Calls itself recursively for
161 -- projects being extended, and imported projects. Adds the project
162 -- to the list Seen if this is the call to Add for this project.
168 procedure Add (Project : Project_Id) is
170 -- If Seen is empty, then the project cannot have been visited
172 if not Projects.Table (Project).Seen then
173 Projects.Table (Project).Seen := True;
176 Data : constant Project_Data := Projects.Table (Project);
177 List : Project_List := Data.Imported_Projects;
180 -- Add to path all source directories of this project
182 Add_To_Path (Data.Source_Dirs);
184 -- Call Add to the project being extended, if any
186 if Data.Extends /= No_Project then
190 -- Call Add for each imported project, if any
192 while List /= Empty_Project_List loop
193 Add (Project_Lists.Table (List).Project);
194 List := Project_Lists.Table (List).Next;
200 -- Start of processing for Ada_Include_Path
203 -- If it is the first time we call this function for
204 -- this project, compute the source path
206 if Projects.Table (Project).Ada_Include_Path = null then
207 Ada_Path_Length := 0;
209 for Index in 1 .. Projects.Last loop
210 Projects.Table (Index).Seen := False;
214 Projects.Table (Project).Ada_Include_Path :=
215 new String'(Ada_Path_Buffer (1 .. Ada_Path_Length));
218 return Projects.Table (Project).Ada_Include_Path;
219 end Ada_Include_Path;
221 ----------------------
222 -- Ada_Include_Path --
223 ----------------------
225 function Ada_Include_Path
226 (Project : Project_Id;
227 Recursive : Boolean) return String
231 return Ada_Include_Path (Project).all;
233 Ada_Path_Length := 0;
234 Add_To_Path (Projects.Table (Project).Source_Dirs);
235 return Ada_Path_Buffer (1 .. Ada_Path_Length);
237 end Ada_Include_Path;
239 ----------------------
240 -- Ada_Objects_Path --
241 ----------------------
243 function Ada_Objects_Path
244 (Project : Project_Id;
245 Including_Libraries : Boolean := True) return String_Access
247 procedure Add (Project : Project_Id);
248 -- Add all the object directories of a project to the path only if
249 -- this project has not been visited. Calls itself recursively for
250 -- projects being extended, and imported projects. Adds the project
251 -- to the list Seen if this is the first call to Add for this project.
257 procedure Add (Project : Project_Id) is
259 -- If this project has not been seen yet
261 if not Projects.Table (Project).Seen then
262 Projects.Table (Project).Seen := True;
265 Data : constant Project_Data := Projects.Table (Project);
266 List : Project_List := Data.Imported_Projects;
269 -- Add to path the object directory of this project
270 -- except if we don't include library project and
271 -- this is a library project.
273 if (Data.Library and then Including_Libraries)
275 (Data.Object_Directory /= No_Name
277 (not Including_Libraries or else not Data.Library))
279 -- For a library project, add the library directory
282 Add_To_Path (Get_Name_String (Data.Library_Dir));
285 -- For a non library project, add the object directory
287 Add_To_Path (Get_Name_String (Data.Object_Directory));
291 -- Call Add to the project being extended, if any
293 if Data.Extends /= No_Project then
297 -- Call Add for each imported project, if any
299 while List /= Empty_Project_List loop
300 Add (Project_Lists.Table (List).Project);
301 List := Project_Lists.Table (List).Next;
308 -- Start of processing for Ada_Objects_Path
311 -- If it is the first time we call this function for
312 -- this project, compute the objects path
314 if Projects.Table (Project).Ada_Objects_Path = null then
315 Ada_Path_Length := 0;
317 for Index in 1 .. Projects.Last loop
318 Projects.Table (Index).Seen := False;
322 Projects.Table (Project).Ada_Objects_Path :=
323 new String'(Ada_Path_Buffer (1 .. Ada_Path_Length));
326 return Projects.Table (Project).Ada_Objects_Path;
327 end Ada_Objects_Path;
329 ------------------------
330 -- Add_To_Object_Path --
331 ------------------------
333 procedure Add_To_Object_Path (Object_Dir : Name_Id) is
335 -- Check if the directory is already in the table
337 for Index in 1 .. Object_Paths.Last loop
339 -- If it is, remove it, and add it as the last one
341 if Object_Paths.Table (Index) = Object_Dir then
342 for Index2 in Index + 1 .. Object_Paths.Last loop
343 Object_Paths.Table (Index2 - 1) :=
344 Object_Paths.Table (Index2);
347 Object_Paths.Table (Object_Paths.Last) := Object_Dir;
352 -- The directory is not already in the table, add it
354 Object_Paths.Increment_Last;
355 Object_Paths.Table (Object_Paths.Last) := Object_Dir;
356 end Add_To_Object_Path;
362 procedure Add_To_Path (Source_Dirs : String_List_Id) is
363 Current : String_List_Id := Source_Dirs;
364 Source_Dir : String_Element;
366 while Current /= Nil_String loop
367 Source_Dir := String_Elements.Table (Current);
368 Add_To_Path (Get_Name_String (Source_Dir.Display_Value));
369 Current := Source_Dir.Next;
373 procedure Add_To_Path (Dir : String) is
375 New_Buffer : String_Access;
378 function Is_Present (Path : String; Dir : String) return Boolean;
379 -- Return True if Dir is part of Path
385 function Is_Present (Path : String; Dir : String) return Boolean is
386 Last : constant Integer := Path'Last - Dir'Length + 1;
389 for J in Path'First .. Last loop
391 -- Note: the order of the conditions below is important, since
392 -- it ensures a minimal number of string comparisons.
395 or else Path (J - 1) = Path_Separator)
397 (J + Dir'Length > Path'Last
398 or else Path (J + Dir'Length) = Path_Separator)
399 and then Dir = Path (J .. J + Dir'Length - 1)
408 -- Start of processing for Add_To_Path
411 if Is_Present (Ada_Path_Buffer (1 .. Ada_Path_Length), Dir) then
413 -- Dir is already in the path, nothing to do
418 Min_Len := Ada_Path_Length + Dir'Length;
420 if Ada_Path_Length > 0 then
422 -- Add 1 for the Path_Separator character
424 Min_Len := Min_Len + 1;
427 -- If Ada_Path_Buffer is too small, increase it
429 Len := Ada_Path_Buffer'Last;
431 if Len < Min_Len then
434 exit when Len >= Min_Len;
437 New_Buffer := new String (1 .. Len);
438 New_Buffer (1 .. Ada_Path_Length) :=
439 Ada_Path_Buffer (1 .. Ada_Path_Length);
440 Free (Ada_Path_Buffer);
441 Ada_Path_Buffer := New_Buffer;
444 if Ada_Path_Length > 0 then
445 Ada_Path_Length := Ada_Path_Length + 1;
446 Ada_Path_Buffer (Ada_Path_Length) := Path_Separator;
450 (Ada_Path_Length + 1 .. Ada_Path_Length + Dir'Length) := Dir;
451 Ada_Path_Length := Ada_Path_Length + Dir'Length;
454 ------------------------
455 -- Add_To_Source_Path --
456 ------------------------
458 procedure Add_To_Source_Path (Source_Dirs : String_List_Id) is
459 Current : String_List_Id := Source_Dirs;
460 Source_Dir : String_Element;
464 -- Add each source directory
466 while Current /= Nil_String loop
467 Source_Dir := String_Elements.Table (Current);
470 -- Check if the source directory is already in the table
472 for Index in 1 .. Source_Paths.Last loop
473 -- If it is already, no need to add it
475 if Source_Paths.Table (Index) = Source_Dir.Value then
482 Source_Paths.Increment_Last;
483 Source_Paths.Table (Source_Paths.Last) := Source_Dir.Value;
486 -- Next source directory
488 Current := Source_Dir.Next;
490 end Add_To_Source_Path;
492 -----------------------
493 -- Body_Path_Name_Of --
494 -----------------------
496 function Body_Path_Name_Of (Unit : Unit_Id) return String is
497 Data : Unit_Data := Units.Table (Unit);
500 -- If we don't know the path name of the body of this unit,
501 -- we compute it, and we store it.
503 if Data.File_Names (Body_Part).Path = No_Name then
505 Current_Source : String_List_Id :=
506 Projects.Table (Data.File_Names (Body_Part).Project).Sources;
507 Path : GNAT.OS_Lib.String_Access;
510 -- By default, put the file name
512 Data.File_Names (Body_Part).Path :=
513 Data.File_Names (Body_Part).Name;
515 -- For each source directory
517 while Current_Source /= Nil_String loop
520 (Namet.Get_Name_String
521 (Data.File_Names (Body_Part).Name),
522 Namet.Get_Name_String
523 (String_Elements.Table (Current_Source).Value));
525 -- If the file is in this directory,
526 -- then we store the path, and we are done.
529 Name_Len := Path'Length;
530 Name_Buffer (1 .. Name_Len) := Path.all;
531 Data.File_Names (Body_Part).Path := Name_Enter;
536 String_Elements.Table (Current_Source).Next;
540 Units.Table (Unit) := Data;
544 -- Returned the stored value
546 return Namet.Get_Name_String (Data.File_Names (Body_Part).Path);
547 end Body_Path_Name_Of;
549 --------------------------------
550 -- Create_Config_Pragmas_File --
551 --------------------------------
553 procedure Create_Config_Pragmas_File
554 (For_Project : Project_Id;
555 Main_Project : Project_Id;
556 Include_Config_Files : Boolean := True)
558 pragma Unreferenced (Main_Project);
559 pragma Unreferenced (Include_Config_Files);
561 File_Name : Name_Id := No_Name;
562 File : File_Descriptor := Invalid_FD;
564 Current_Unit : Unit_Id := Units.First;
566 First_Project : Project_List := Empty_Project_List;
568 Current_Project : Project_List;
569 Current_Naming : Naming_Id;
574 procedure Check (Project : Project_Id);
575 -- ??? requires a comment
577 procedure Check_Temp_File;
578 -- Check that a temporary file has been opened.
579 -- If not, create one, and put its name in the project data,
580 -- with the indication that it is a temporary file.
583 (Unit_Name : Name_Id;
585 Unit_Kind : Spec_Or_Body);
586 -- Put an SFN pragma in the temporary file
588 procedure Put (File : File_Descriptor; S : String);
589 procedure Put_Line (File : File_Descriptor; S : String);
590 -- Output procedures, analogous to normal Text_IO procs of same name
596 procedure Check (Project : Project_Id) is
597 Data : constant Project_Data := Projects.Table (Project);
600 if Current_Verbosity = High then
601 Write_Str ("Checking project file """);
602 Write_Str (Namet.Get_Name_String (Data.Name));
607 -- Is this project in the list of the visited project?
609 Current_Project := First_Project;
610 while Current_Project /= Empty_Project_List
611 and then Project_Lists.Table (Current_Project).Project /= Project
613 Current_Project := Project_Lists.Table (Current_Project).Next;
616 -- If it is not, put it in the list, and visit it
618 if Current_Project = Empty_Project_List then
619 Project_Lists.Increment_Last;
620 Project_Lists.Table (Project_Lists.Last) :=
621 (Project => Project, Next => First_Project);
622 First_Project := Project_Lists.Last;
624 -- Is the naming scheme of this project one that we know?
626 Current_Naming := Default_Naming;
627 while Current_Naming <= Namings.Last and then
628 not Same_Naming_Scheme
629 (Left => Namings.Table (Current_Naming),
630 Right => Data.Naming) loop
631 Current_Naming := Current_Naming + 1;
634 -- If we don't know it, add it
636 if Current_Naming > Namings.Last then
637 Namings.Increment_Last;
638 Namings.Table (Namings.Last) := Data.Naming;
640 -- We need a temporary file to be created
644 -- Put the SFN pragmas for the naming scheme
649 (File, "pragma Source_File_Name_Project");
651 (File, " (Spec_File_Name => ""*" &
652 Namet.Get_Name_String (Data.Naming.Current_Spec_Suffix) &
655 (File, " Casing => " &
656 Image (Data.Naming.Casing) & ",");
658 (File, " Dot_Replacement => """ &
659 Namet.Get_Name_String (Data.Naming.Dot_Replacement) &
665 (File, "pragma Source_File_Name_Project");
667 (File, " (Body_File_Name => ""*" &
668 Namet.Get_Name_String (Data.Naming.Current_Body_Suffix) &
671 (File, " Casing => " &
672 Image (Data.Naming.Casing) & ",");
674 (File, " Dot_Replacement => """ &
675 Namet.Get_Name_String (Data.Naming.Dot_Replacement) &
678 -- and maybe separate
681 Data.Naming.Current_Body_Suffix /= Data.Naming.Separate_Suffix
684 (File, "pragma Source_File_Name_Project");
686 (File, " (Subunit_File_Name => ""*" &
687 Namet.Get_Name_String (Data.Naming.Separate_Suffix) &
690 (File, " Casing => " &
691 Image (Data.Naming.Casing) &
694 (File, " Dot_Replacement => """ &
695 Namet.Get_Name_String (Data.Naming.Dot_Replacement) &
700 if Data.Extends /= No_Project then
701 Check (Data.Extends);
705 Current : Project_List := Data.Imported_Projects;
708 while Current /= Empty_Project_List loop
709 Check (Project_Lists.Table (Current).Project);
710 Current := Project_Lists.Table (Current).Next;
716 ---------------------
717 -- Check_Temp_File --
718 ---------------------
720 procedure Check_Temp_File is
722 if File = Invalid_FD then
723 Tempdir.Create_Temp_File (File, Name => File_Name);
725 if File = Invalid_FD then
727 ("unable to create temporary configuration pragmas file");
728 elsif Opt.Verbose_Mode then
729 Write_Str ("Creating temp file """);
730 Write_Str (Get_Name_String (File_Name));
741 (Unit_Name : Name_Id;
743 Unit_Kind : Spec_Or_Body)
746 -- A temporary file needs to be open
750 -- Put the pragma SFN for the unit kind (spec or body)
752 Put (File, "pragma Source_File_Name_Project (");
753 Put (File, Namet.Get_Name_String (Unit_Name));
755 if Unit_Kind = Specification then
756 Put (File, ", Spec_File_Name => """);
758 Put (File, ", Body_File_Name => """);
761 Put (File, Namet.Get_Name_String (File_Name));
762 Put_Line (File, """);");
765 procedure Put (File : File_Descriptor; S : String) is
769 Last := Write (File, S (S'First)'Address, S'Length);
771 if Last /= S'Length then
772 Prj.Com.Fail ("Disk full");
775 if Current_Verbosity = High then
784 procedure Put_Line (File : File_Descriptor; S : String) is
785 S0 : String (1 .. S'Length + 1);
789 -- Add an ASCII.LF to the string. As this gnat.adc is supposed to
790 -- be used only by the compiler, we don't care about the characters
791 -- for the end of line. In fact we could have put a space, but
792 -- it is more convenient to be able to read gnat.adc during
793 -- development, for which the ASCII.LF is fine.
795 S0 (1 .. S'Length) := S;
796 S0 (S0'Last) := ASCII.LF;
797 Last := Write (File, S0'Address, S0'Length);
799 if Last /= S'Length + 1 then
800 Prj.Com.Fail ("Disk full");
803 if Current_Verbosity = High then
808 -- Start of processing for Create_Config_Pragmas_File
811 if not Projects.Table (For_Project).Config_Checked then
813 -- Remove any memory of processed naming schemes, if any
815 Namings.Set_Last (Default_Naming);
817 -- Check the naming schemes
821 -- Visit all the units and process those that need an SFN pragma
823 while Current_Unit <= Units.Last loop
825 Unit : constant Unit_Data :=
826 Units.Table (Current_Unit);
829 if Unit.File_Names (Specification).Needs_Pragma then
831 Unit.File_Names (Specification).Name,
835 if Unit.File_Names (Body_Part).Needs_Pragma then
837 Unit.File_Names (Body_Part).Name,
841 Current_Unit := Current_Unit + 1;
845 -- If there are no non standard naming scheme, issue the GNAT
846 -- standard naming scheme. This will tell the compiler that
847 -- a project file is used and will forbid any pragma SFN.
849 if File = Invalid_FD then
852 Put_Line (File, "pragma Source_File_Name_Project");
853 Put_Line (File, " (Spec_File_Name => ""*.ads"",");
854 Put_Line (File, " Dot_Replacement => ""-"",");
855 Put_Line (File, " Casing => lowercase);");
857 Put_Line (File, "pragma Source_File_Name_Project");
858 Put_Line (File, " (Body_File_Name => ""*.adb"",");
859 Put_Line (File, " Dot_Replacement => ""-"",");
860 Put_Line (File, " Casing => lowercase);");
863 -- Close the temporary file
865 GNAT.OS_Lib.Close (File, Status);
868 Prj.Com.Fail ("disk full");
871 if Opt.Verbose_Mode then
872 Write_Str ("Closing configuration file """);
873 Write_Str (Get_Name_String (File_Name));
877 Projects.Table (For_Project).Config_File_Name := File_Name;
878 Projects.Table (For_Project).Config_File_Temp := True;
880 Projects.Table (For_Project).Config_Checked := True;
882 end Create_Config_Pragmas_File;
884 -------------------------
885 -- Create_Mapping_File --
886 -------------------------
888 procedure Create_Mapping_File
889 (Project : Project_Id;
892 File : File_Descriptor := Invalid_FD;
893 The_Unit_Data : Unit_Data;
894 Data : File_Name_Data;
899 Present : Project_Flags (No_Project .. Projects.Last) :=
901 -- For each project in the closure of Project, the corresponding flag
902 -- will be set to True;
904 procedure Put_Name_Buffer;
905 -- Put the line contained in the Name_Buffer in the mapping file
907 procedure Put_Data (Spec : Boolean);
908 -- Put the mapping of the spec or body contained in Data in the file
911 procedure Recursive_Flag (Prj : Project_Id);
912 -- Set the flags corresponding to Prj, the projects it imports
913 -- (directly or indirectly) or extends to True. Call itself recursively.
919 procedure Put_Name_Buffer is
923 Name_Len := Name_Len + 1;
924 Name_Buffer (Name_Len) := ASCII.LF;
925 Last := Write (File, Name_Buffer (1)'Address, Name_Len);
927 if Last /= Name_Len then
928 Prj.Com.Fail ("Disk full");
936 procedure Put_Data (Spec : Boolean) is
938 -- Line with the unit name
940 Get_Name_String (The_Unit_Data.Name);
941 Name_Len := Name_Len + 1;
942 Name_Buffer (Name_Len) := '%';
943 Name_Len := Name_Len + 1;
946 Name_Buffer (Name_Len) := 's';
948 Name_Buffer (Name_Len) := 'b';
953 -- Line with the file name
955 Get_Name_String (Data.Name);
958 -- Line with the path name
960 Get_Name_String (Data.Path);
969 procedure Recursive_Flag (Prj : Project_Id) is
970 Imported : Project_List;
974 -- Nothing to do for non existent project or project that has
975 -- already been flagged.
977 if Prj = No_Project or else Present (Prj) then
981 -- Flag the current project
983 Present (Prj) := True;
984 Imported := Projects.Table (Prj).Imported_Projects;
986 -- Call itself for each project directly imported
988 while Imported /= Empty_Project_List loop
989 Proj := Project_Lists.Table (Imported).Project;
990 Imported := Project_Lists.Table (Imported).Next;
991 Recursive_Flag (Proj);
994 -- Call itself for an eventual project being extended
996 Recursive_Flag (Projects.Table (Prj).Extends);
999 -- Start of processing for Create_Mapping_File
1002 -- Flag the necessary projects
1004 Recursive_Flag (Project);
1006 -- Create the temporary file
1008 Tempdir.Create_Temp_File (File, Name => Name);
1010 if File = Invalid_FD then
1011 Prj.Com.Fail ("unable to create temporary mapping file");
1013 elsif Opt.Verbose_Mode then
1014 Write_Str ("Creating temp mapping file """);
1015 Write_Str (Get_Name_String (Name));
1019 if Fill_Mapping_File then
1020 -- For all units in table Units
1022 for Unit in 1 .. Units.Last loop
1023 The_Unit_Data := Units.Table (Unit);
1025 -- If the unit has a valid name
1027 if The_Unit_Data.Name /= No_Name then
1028 Data := The_Unit_Data.File_Names (Specification);
1030 -- If there is a spec, put it mapping in the file if it is
1031 -- from a project in the closure of Project.
1033 if Data.Name /= No_Name and then Present (Data.Project) then
1034 Put_Data (Spec => True);
1037 Data := The_Unit_Data.File_Names (Body_Part);
1039 -- If there is a body (or subunit) put its mapping in the file
1040 -- if it is from a project in the closure of Project.
1042 if Data.Name /= No_Name and then Present (Data.Project) then
1043 Put_Data (Spec => False);
1050 GNAT.OS_Lib.Close (File, Status);
1053 Prj.Com.Fail ("disk full");
1055 end Create_Mapping_File;
1057 --------------------------
1058 -- Create_New_Path_File --
1059 --------------------------
1061 procedure Create_New_Path_File
1062 (Path_FD : out File_Descriptor;
1063 Path_Name : out Name_Id)
1066 Tempdir.Create_Temp_File (Path_FD, Path_Name);
1068 if Path_Name /= No_Name then
1070 -- Record the name, so that the temp path file will be deleted
1071 -- at the end of the program.
1073 Path_Files.Increment_Last;
1074 Path_Files.Table (Path_Files.Last) := Path_Name;
1076 end Create_New_Path_File;
1078 ---------------------------
1079 -- Delete_All_Path_Files --
1080 ---------------------------
1082 procedure Delete_All_Path_Files is
1083 Disregard : Boolean := True;
1086 for Index in 1 .. Path_Files.Last loop
1087 if Path_Files.Table (Index) /= No_Name then
1089 (Get_Name_String (Path_Files.Table (Index)), Disregard);
1093 -- If any of the environment variables ADA_PRJ_INCLUDE_FILE or
1094 -- ADA_PRJ_OBJECTS_FILE has been set, then reset their value to
1095 -- the empty string. On VMS, this has the effect of deassigning
1096 -- the logical names.
1098 if Ada_Prj_Include_File_Set then
1099 Setenv (Project_Include_Path_File, "");
1100 Ada_Prj_Include_File_Set := False;
1103 if Ada_Prj_Objects_File_Set then
1104 Setenv (Project_Objects_Path_File, "");
1105 Ada_Prj_Objects_File_Set := False;
1107 end Delete_All_Path_Files;
1109 ------------------------------------
1110 -- File_Name_Of_Library_Unit_Body --
1111 ------------------------------------
1113 function File_Name_Of_Library_Unit_Body
1115 Project : Project_Id;
1116 Main_Project_Only : Boolean := True;
1117 Full_Path : Boolean := False) return String
1119 The_Project : Project_Id := Project;
1120 Data : Project_Data := Projects.Table (Project);
1121 Original_Name : String := Name;
1123 Extended_Spec_Name : String :=
1124 Name & Namet.Get_Name_String
1125 (Data.Naming.Current_Spec_Suffix);
1126 Extended_Body_Name : String :=
1127 Name & Namet.Get_Name_String
1128 (Data.Naming.Current_Body_Suffix);
1132 The_Original_Name : Name_Id;
1133 The_Spec_Name : Name_Id;
1134 The_Body_Name : Name_Id;
1137 Canonical_Case_File_Name (Original_Name);
1138 Name_Len := Original_Name'Length;
1139 Name_Buffer (1 .. Name_Len) := Original_Name;
1140 The_Original_Name := Name_Find;
1142 Canonical_Case_File_Name (Extended_Spec_Name);
1143 Name_Len := Extended_Spec_Name'Length;
1144 Name_Buffer (1 .. Name_Len) := Extended_Spec_Name;
1145 The_Spec_Name := Name_Find;
1147 Canonical_Case_File_Name (Extended_Body_Name);
1148 Name_Len := Extended_Body_Name'Length;
1149 Name_Buffer (1 .. Name_Len) := Extended_Body_Name;
1150 The_Body_Name := Name_Find;
1152 if Current_Verbosity = High then
1153 Write_Str ("Looking for file name of """);
1157 Write_Str (" Extended Spec Name = """);
1158 Write_Str (Extended_Spec_Name);
1161 Write_Str (" Extended Body Name = """);
1162 Write_Str (Extended_Body_Name);
1167 -- For extending project, search in the extended project
1168 -- if the source is not found. For non extending projects,
1169 -- this loop will be run only once.
1172 -- Loop through units
1173 -- Should have comment explaining reverse ???
1175 for Current in reverse Units.First .. Units.Last loop
1176 Unit := Units.Table (Current);
1180 if not Main_Project_Only
1181 or else Unit.File_Names (Body_Part).Project = The_Project
1184 Current_Name : constant Name_Id :=
1185 Unit.File_Names (Body_Part).Name;
1188 -- Case of a body present
1190 if Current_Name /= No_Name then
1191 if Current_Verbosity = High then
1192 Write_Str (" Comparing with """);
1193 Write_Str (Get_Name_String (Current_Name));
1198 -- If it has the name of the original name,
1199 -- return the original name
1201 if Unit.Name = The_Original_Name
1202 or else Current_Name = The_Original_Name
1204 if Current_Verbosity = High then
1209 return Get_Name_String
1210 (Unit.File_Names (Body_Part).Path);
1213 return Get_Name_String (Current_Name);
1216 -- If it has the name of the extended body name,
1217 -- return the extended body name
1219 elsif Current_Name = The_Body_Name then
1220 if Current_Verbosity = High then
1225 return Get_Name_String
1226 (Unit.File_Names (Body_Part).Path);
1229 return Extended_Body_Name;
1233 if Current_Verbosity = High then
1234 Write_Line (" not good");
1243 if not Main_Project_Only
1244 or else Unit.File_Names (Specification).Project = The_Project
1247 Current_Name : constant Name_Id :=
1248 Unit.File_Names (Specification).Name;
1251 -- Case of spec present
1253 if Current_Name /= No_Name then
1254 if Current_Verbosity = High then
1255 Write_Str (" Comparing with """);
1256 Write_Str (Get_Name_String (Current_Name));
1261 -- If name same as original name, return original name
1263 if Unit.Name = The_Original_Name
1264 or else Current_Name = The_Original_Name
1266 if Current_Verbosity = High then
1272 return Get_Name_String
1273 (Unit.File_Names (Specification).Path);
1275 return Get_Name_String (Current_Name);
1278 -- If it has the same name as the extended spec name,
1279 -- return the extended spec name.
1281 elsif Current_Name = The_Spec_Name then
1282 if Current_Verbosity = High then
1287 return Get_Name_String
1288 (Unit.File_Names (Specification).Path);
1290 return Extended_Spec_Name;
1294 if Current_Verbosity = High then
1295 Write_Line (" not good");
1303 -- If we are not in an extending project, give up
1305 exit when (not Main_Project_Only) or else Data.Extends = No_Project;
1307 -- Otherwise, look in the project we are extending
1309 The_Project := Data.Extends;
1310 Data := Projects.Table (The_Project);
1313 -- We don't know this file name, return an empty string
1316 end File_Name_Of_Library_Unit_Body;
1318 -------------------------
1319 -- For_All_Object_Dirs --
1320 -------------------------
1322 procedure For_All_Object_Dirs (Project : Project_Id) is
1323 Seen : Project_List := Empty_Project_List;
1325 procedure Add (Project : Project_Id);
1326 -- Process a project. Remember the processes visited to avoid
1327 -- processing a project twice. Recursively process an eventual
1328 -- extended project, and all imported projects.
1334 procedure Add (Project : Project_Id) is
1335 Data : constant Project_Data := Projects.Table (Project);
1336 List : Project_List := Data.Imported_Projects;
1339 -- If the list of visited project is empty, then
1340 -- for sure we never visited this project.
1342 if Seen = Empty_Project_List then
1343 Project_Lists.Increment_Last;
1344 Seen := Project_Lists.Last;
1345 Project_Lists.Table (Seen) :=
1346 (Project => Project, Next => Empty_Project_List);
1349 -- Check if the project is in the list
1352 Current : Project_List := Seen;
1356 -- If it is, then there is nothing else to do
1358 if Project_Lists.Table (Current).Project = Project then
1362 exit when Project_Lists.Table (Current).Next =
1364 Current := Project_Lists.Table (Current).Next;
1367 -- This project has never been visited, add it
1370 Project_Lists.Increment_Last;
1371 Project_Lists.Table (Current).Next := Project_Lists.Last;
1372 Project_Lists.Table (Project_Lists.Last) :=
1373 (Project => Project, Next => Empty_Project_List);
1377 -- If there is an object directory, call Action
1380 if Data.Object_Directory /= No_Name then
1381 Get_Name_String (Data.Object_Directory);
1382 Action (Name_Buffer (1 .. Name_Len));
1385 -- If we are extending a project, visit it
1387 if Data.Extends /= No_Project then
1391 -- And visit all imported projects
1393 while List /= Empty_Project_List loop
1394 Add (Project_Lists.Table (List).Project);
1395 List := Project_Lists.Table (List).Next;
1399 -- Start of processing for For_All_Object_Dirs
1402 -- Visit this project, and its imported projects,
1406 end For_All_Object_Dirs;
1408 -------------------------
1409 -- For_All_Source_Dirs --
1410 -------------------------
1412 procedure For_All_Source_Dirs (Project : Project_Id) is
1413 Seen : Project_List := Empty_Project_List;
1415 procedure Add (Project : Project_Id);
1416 -- Process a project. Remember the processes visited to avoid
1417 -- processing a project twice. Recursively process an eventual
1418 -- extended project, and all imported projects.
1424 procedure Add (Project : Project_Id) is
1425 Data : constant Project_Data := Projects.Table (Project);
1426 List : Project_List := Data.Imported_Projects;
1429 -- If the list of visited project is empty, then
1430 -- for sure we never visited this project.
1432 if Seen = Empty_Project_List then
1433 Project_Lists.Increment_Last;
1434 Seen := Project_Lists.Last;
1435 Project_Lists.Table (Seen) :=
1436 (Project => Project, Next => Empty_Project_List);
1439 -- Check if the project is in the list
1442 Current : Project_List := Seen;
1446 -- If it is, then there is nothing else to do
1448 if Project_Lists.Table (Current).Project = Project then
1452 exit when Project_Lists.Table (Current).Next =
1454 Current := Project_Lists.Table (Current).Next;
1457 -- This project has never been visited, add it
1460 Project_Lists.Increment_Last;
1461 Project_Lists.Table (Current).Next := Project_Lists.Last;
1462 Project_Lists.Table (Project_Lists.Last) :=
1463 (Project => Project, Next => Empty_Project_List);
1468 Current : String_List_Id := Data.Source_Dirs;
1469 The_String : String_Element;
1472 -- If there are Ada sources, call action with the name of every
1473 -- source directory.
1475 if Projects.Table (Project).Sources_Present then
1476 while Current /= Nil_String loop
1477 The_String := String_Elements.Table (Current);
1478 Action (Get_Name_String (The_String.Value));
1479 Current := The_String.Next;
1484 -- If we are extending a project, visit it
1486 if Data.Extends /= No_Project then
1490 -- And visit all imported projects
1492 while List /= Empty_Project_List loop
1493 Add (Project_Lists.Table (List).Project);
1494 List := Project_Lists.Table (List).Next;
1498 -- Start of processing for For_All_Source_Dirs
1501 -- Visit this project, and its imported projects recursively
1504 end For_All_Source_Dirs;
1510 procedure Get_Reference
1511 (Source_File_Name : String;
1512 Project : out Project_Id;
1516 -- Body below could use some comments ???
1518 if Current_Verbosity > Default then
1519 Write_Str ("Getting Reference_Of (""");
1520 Write_Str (Source_File_Name);
1521 Write_Str (""") ... ");
1525 Original_Name : String := Source_File_Name;
1529 Canonical_Case_File_Name (Original_Name);
1531 for Id in Units.First .. Units.Last loop
1532 Unit := Units.Table (Id);
1534 if (Unit.File_Names (Specification).Name /= No_Name
1536 Namet.Get_Name_String
1537 (Unit.File_Names (Specification).Name) = Original_Name)
1538 or else (Unit.File_Names (Specification).Path /= No_Name
1540 Namet.Get_Name_String
1541 (Unit.File_Names (Specification).Path) =
1544 Project := Ultimate_Extension_Of
1545 (Unit.File_Names (Specification).Project);
1546 Path := Unit.File_Names (Specification).Display_Path;
1548 if Current_Verbosity > Default then
1549 Write_Str ("Done: Specification.");
1555 elsif (Unit.File_Names (Body_Part).Name /= No_Name
1557 Namet.Get_Name_String
1558 (Unit.File_Names (Body_Part).Name) = Original_Name)
1559 or else (Unit.File_Names (Body_Part).Path /= No_Name
1560 and then Namet.Get_Name_String
1561 (Unit.File_Names (Body_Part).Path) =
1564 Project := Ultimate_Extension_Of
1565 (Unit.File_Names (Body_Part).Project);
1566 Path := Unit.File_Names (Body_Part).Display_Path;
1568 if Current_Verbosity > Default then
1569 Write_Str ("Done: Body.");
1578 Project := No_Project;
1581 if Current_Verbosity > Default then
1582 Write_Str ("Cannot be found.");
1591 -- This is a place holder for possible required initialization in
1592 -- the future. In the current version no initialization is required.
1594 procedure Initialize is
1599 ------------------------------------
1600 -- Path_Name_Of_Library_Unit_Body --
1601 ------------------------------------
1603 -- Could use some comments in the body here ???
1605 function Path_Name_Of_Library_Unit_Body
1607 Project : Project_Id) return String
1609 Data : constant Project_Data := Projects.Table (Project);
1610 Original_Name : String := Name;
1612 Extended_Spec_Name : String :=
1613 Name & Namet.Get_Name_String
1614 (Data.Naming.Current_Spec_Suffix);
1615 Extended_Body_Name : String :=
1616 Name & Namet.Get_Name_String
1617 (Data.Naming.Current_Body_Suffix);
1619 First : Unit_Id := Units.First;
1624 Canonical_Case_File_Name (Original_Name);
1625 Canonical_Case_File_Name (Extended_Spec_Name);
1626 Canonical_Case_File_Name (Extended_Body_Name);
1628 if Current_Verbosity = High then
1629 Write_Str ("Looking for path name of """);
1633 Write_Str (" Extended Spec Name = """);
1634 Write_Str (Extended_Spec_Name);
1637 Write_Str (" Extended Body Name = """);
1638 Write_Str (Extended_Body_Name);
1643 while First <= Units.Last
1644 and then Units.Table (First).File_Names (Body_Part).Project /= Project
1650 while Current <= Units.Last loop
1651 Unit := Units.Table (Current);
1653 if Unit.File_Names (Body_Part).Project = Project
1654 and then Unit.File_Names (Body_Part).Name /= No_Name
1657 Current_Name : constant String :=
1658 Namet.Get_Name_String (Unit.File_Names (Body_Part).Name);
1660 if Current_Verbosity = High then
1661 Write_Str (" Comparing with """);
1662 Write_Str (Current_Name);
1667 if Current_Name = Original_Name then
1668 if Current_Verbosity = High then
1672 return Body_Path_Name_Of (Current);
1674 elsif Current_Name = Extended_Body_Name then
1675 if Current_Verbosity = High then
1679 return Body_Path_Name_Of (Current);
1682 if Current_Verbosity = High then
1683 Write_Line (" not good");
1688 elsif Unit.File_Names (Specification).Name /= No_Name then
1690 Current_Name : constant String :=
1691 Namet.Get_Name_String
1692 (Unit.File_Names (Specification).Name);
1695 if Current_Verbosity = High then
1696 Write_Str (" Comparing with """);
1697 Write_Str (Current_Name);
1702 if Current_Name = Original_Name then
1703 if Current_Verbosity = High then
1707 return Spec_Path_Name_Of (Current);
1709 elsif Current_Name = Extended_Spec_Name then
1710 if Current_Verbosity = High then
1714 return Spec_Path_Name_Of (Current);
1717 if Current_Verbosity = High then
1718 Write_Line (" not good");
1723 Current := Current + 1;
1727 end Path_Name_Of_Library_Unit_Body;
1733 -- Could use some comments in this body ???
1735 procedure Print_Sources is
1739 Write_Line ("List of Sources:");
1741 for Id in Units.First .. Units.Last loop
1742 Unit := Units.Table (Id);
1744 Write_Line (Namet.Get_Name_String (Unit.Name));
1746 if Unit.File_Names (Specification).Name /= No_Name then
1747 if Unit.File_Names (Specification).Project = No_Project then
1748 Write_Line (" No project");
1751 Write_Str (" Project: ");
1754 (Unit.File_Names (Specification).Project).Path_Name);
1755 Write_Line (Name_Buffer (1 .. Name_Len));
1758 Write_Str (" spec: ");
1760 (Namet.Get_Name_String
1761 (Unit.File_Names (Specification).Name));
1764 if Unit.File_Names (Body_Part).Name /= No_Name then
1765 if Unit.File_Names (Body_Part).Project = No_Project then
1766 Write_Line (" No project");
1769 Write_Str (" Project: ");
1772 (Unit.File_Names (Body_Part).Project).Path_Name);
1773 Write_Line (Name_Buffer (1 .. Name_Len));
1776 Write_Str (" body: ");
1778 (Namet.Get_Name_String
1779 (Unit.File_Names (Body_Part).Name));
1783 Write_Line ("end of List of Sources.");
1792 Main_Project : Project_Id) return Project_Id
1794 Result : Project_Id := No_Project;
1796 Original_Name : String := Name;
1798 Data : constant Project_Data := Projects.Table (Main_Project);
1800 Extended_Spec_Name : String :=
1801 Name & Namet.Get_Name_String
1802 (Data.Naming.Current_Spec_Suffix);
1803 Extended_Body_Name : String :=
1804 Name & Namet.Get_Name_String
1805 (Data.Naming.Current_Body_Suffix);
1809 Current_Name : Name_Id;
1811 The_Original_Name : Name_Id;
1812 The_Spec_Name : Name_Id;
1813 The_Body_Name : Name_Id;
1816 Canonical_Case_File_Name (Original_Name);
1817 Name_Len := Original_Name'Length;
1818 Name_Buffer (1 .. Name_Len) := Original_Name;
1819 The_Original_Name := Name_Find;
1821 Canonical_Case_File_Name (Extended_Spec_Name);
1822 Name_Len := Extended_Spec_Name'Length;
1823 Name_Buffer (1 .. Name_Len) := Extended_Spec_Name;
1824 The_Spec_Name := Name_Find;
1826 Canonical_Case_File_Name (Extended_Body_Name);
1827 Name_Len := Extended_Body_Name'Length;
1828 Name_Buffer (1 .. Name_Len) := Extended_Body_Name;
1829 The_Body_Name := Name_Find;
1831 for Current in reverse Units.First .. Units.Last loop
1832 Unit := Units.Table (Current);
1836 Current_Name := Unit.File_Names (Body_Part).Name;
1838 -- Case of a body present
1840 if Current_Name /= No_Name then
1842 -- If it has the name of the original name or the body name,
1843 -- we have found the project.
1845 if Unit.Name = The_Original_Name
1846 or else Current_Name = The_Original_Name
1847 or else Current_Name = The_Body_Name
1849 Result := Unit.File_Names (Body_Part).Project;
1856 Current_Name := Unit.File_Names (Specification).Name;
1858 if Current_Name /= No_Name then
1860 -- If name same as the original name, or the spec name, we have
1861 -- found the project.
1863 if Unit.Name = The_Original_Name
1864 or else Current_Name = The_Original_Name
1865 or else Current_Name = The_Spec_Name
1867 Result := Unit.File_Names (Specification).Project;
1873 -- Get the ultimate extending project
1875 if Result /= No_Project then
1876 while Projects.Table (Result).Extended_By /= No_Project loop
1877 Result := Projects.Table (Result).Extended_By;
1888 procedure Set_Ada_Paths
1889 (Project : Project_Id;
1890 Including_Libraries : Boolean)
1892 Source_FD : File_Descriptor := Invalid_FD;
1893 Object_FD : File_Descriptor := Invalid_FD;
1895 Process_Source_Dirs : Boolean := False;
1896 Process_Object_Dirs : Boolean := False;
1899 -- For calls to Close
1903 procedure Add (Proj : Project_Id);
1904 -- Add all the source/object directories of a project to the path only
1905 -- if this project has not been visited. Calls an internal procedure
1906 -- recursively for projects being extended, and imported projects.
1912 procedure Add (Proj : Project_Id) is
1914 procedure Recursive_Add (Project : Project_Id);
1915 -- Recursive procedure to add the source/object paths of extended/
1916 -- imported projects.
1922 procedure Recursive_Add (Project : Project_Id) is
1924 -- If Seen is False, then the project has not yet been visited
1926 if not Projects.Table (Project).Seen then
1927 Projects.Table (Project).Seen := True;
1930 Data : constant Project_Data := Projects.Table (Project);
1931 List : Project_List := Data.Imported_Projects;
1934 if Process_Source_Dirs then
1936 -- Add to path all source directories of this project
1937 -- if there are Ada sources.
1939 if Projects.Table (Project).Sources_Present then
1940 Add_To_Source_Path (Data.Source_Dirs);
1944 if Process_Object_Dirs then
1946 -- Add to path the object directory of this project
1947 -- except if we don't include library project and
1948 -- this is a library project.
1950 if (Data.Library and then Including_Libraries)
1952 (Data.Object_Directory /= No_Name
1954 (not Including_Libraries or else not Data.Library))
1956 -- For a library project, add the library directory
1958 if Data.Library then
1959 Add_To_Object_Path (Data.Library_Dir);
1962 -- For a non library project, add the object
1965 Add_To_Object_Path (Data.Object_Directory);
1970 -- Call Add to the project being extended, if any
1972 if Data.Extends /= No_Project then
1973 Recursive_Add (Data.Extends);
1976 -- Call Add for each imported project, if any
1978 while List /= Empty_Project_List loop
1979 Recursive_Add (Project_Lists.Table (List).Project);
1980 List := Project_Lists.Table (List).Next;
1987 Source_Paths.Set_Last (0);
1988 Object_Paths.Set_Last (0);
1990 for Index in 1 .. Projects.Last loop
1991 Projects.Table (Index).Seen := False;
1994 Recursive_Add (Proj);
1997 -- Start of processing for Set_Ada_Paths
2000 -- If it is the first time we call this procedure for
2001 -- this project, compute the source path and/or the object path.
2003 if Projects.Table (Project).Include_Path_File = No_Name then
2004 Process_Source_Dirs := True;
2005 Create_New_Path_File
2006 (Source_FD, Projects.Table (Project).Include_Path_File);
2009 -- For the object path, we make a distinction depending on
2010 -- Including_Libraries.
2012 if Including_Libraries then
2013 if Projects.Table (Project).Objects_Path_File_With_Libs = No_Name then
2014 Process_Object_Dirs := True;
2015 Create_New_Path_File
2016 (Object_FD, Projects.Table (Project).
2017 Objects_Path_File_With_Libs);
2022 Projects.Table (Project).Objects_Path_File_Without_Libs = No_Name
2024 Process_Object_Dirs := True;
2025 Create_New_Path_File
2026 (Object_FD, Projects.Table (Project).
2027 Objects_Path_File_Without_Libs);
2031 -- If there is something to do, set Seen to False for all projects,
2032 -- then call the recursive procedure Add for Project.
2034 if Process_Source_Dirs or Process_Object_Dirs then
2038 -- Write and close any file that has been created.
2040 if Source_FD /= Invalid_FD then
2041 for Index in 1 .. Source_Paths.Last loop
2042 Get_Name_String (Source_Paths.Table (Index));
2043 Name_Len := Name_Len + 1;
2044 Name_Buffer (Name_Len) := ASCII.LF;
2045 Len := Write (Source_FD, Name_Buffer (1)'Address, Name_Len);
2047 if Len /= Name_Len then
2048 Prj.Com.Fail ("disk full");
2052 Close (Source_FD, Status);
2055 Prj.Com.Fail ("disk full");
2059 if Object_FD /= Invalid_FD then
2060 for Index in 1 .. Object_Paths.Last loop
2061 Get_Name_String (Object_Paths.Table (Index));
2062 Name_Len := Name_Len + 1;
2063 Name_Buffer (Name_Len) := ASCII.LF;
2064 Len := Write (Object_FD, Name_Buffer (1)'Address, Name_Len);
2066 if Len /= Name_Len then
2067 Prj.Com.Fail ("disk full");
2071 Close (Object_FD, Status);
2074 Prj.Com.Fail ("disk full");
2078 -- Set the env vars, if they need to be changed, and set the
2079 -- corresponding flags.
2081 if Current_Source_Path_File /=
2082 Projects.Table (Project).Include_Path_File
2084 Current_Source_Path_File :=
2085 Projects.Table (Project).Include_Path_File;
2087 (Project_Include_Path_File,
2088 Get_Name_String (Current_Source_Path_File));
2089 Ada_Prj_Include_File_Set := True;
2092 if Including_Libraries then
2093 if Current_Object_Path_File
2094 /= Projects.Table (Project).Objects_Path_File_With_Libs
2096 Current_Object_Path_File :=
2097 Projects.Table (Project).Objects_Path_File_With_Libs;
2099 (Project_Objects_Path_File,
2100 Get_Name_String (Current_Object_Path_File));
2101 Ada_Prj_Objects_File_Set := True;
2105 if Current_Object_Path_File
2106 /= Projects.Table (Project).Objects_Path_File_Without_Libs
2108 Current_Object_Path_File :=
2109 Projects.Table (Project).Objects_Path_File_Without_Libs;
2111 (Project_Objects_Path_File,
2112 Get_Name_String (Current_Object_Path_File));
2113 Ada_Prj_Objects_File_Set := True;
2118 ---------------------------------------------
2119 -- Set_Mapping_File_Initial_State_To_Empty --
2120 ---------------------------------------------
2122 procedure Set_Mapping_File_Initial_State_To_Empty is
2124 Fill_Mapping_File := False;
2125 end Set_Mapping_File_Initial_State_To_Empty;
2127 -----------------------
2128 -- Set_Path_File_Var --
2129 -----------------------
2131 procedure Set_Path_File_Var (Name : String; Value : String) is
2132 Host_Spec : String_Access := To_Host_File_Spec (Value);
2135 if Host_Spec = null then
2137 ("could not convert file name """, Value, """ to host spec");
2139 Setenv (Name, Host_Spec.all);
2142 end Set_Path_File_Var;
2144 -----------------------
2145 -- Spec_Path_Name_Of --
2146 -----------------------
2148 function Spec_Path_Name_Of (Unit : Unit_Id) return String is
2149 Data : Unit_Data := Units.Table (Unit);
2152 if Data.File_Names (Specification).Path = No_Name then
2154 Current_Source : String_List_Id :=
2155 Projects.Table (Data.File_Names (Specification).Project).Sources;
2156 Path : GNAT.OS_Lib.String_Access;
2159 Data.File_Names (Specification).Path :=
2160 Data.File_Names (Specification).Name;
2162 while Current_Source /= Nil_String loop
2163 Path := Locate_Regular_File
2164 (Namet.Get_Name_String
2165 (Data.File_Names (Specification).Name),
2166 Namet.Get_Name_String
2167 (String_Elements.Table (Current_Source).Value));
2169 if Path /= null then
2170 Name_Len := Path'Length;
2171 Name_Buffer (1 .. Name_Len) := Path.all;
2172 Data.File_Names (Specification).Path := Name_Enter;
2176 String_Elements.Table (Current_Source).Next;
2180 Units.Table (Unit) := Data;
2184 return Namet.Get_Name_String (Data.File_Names (Specification).Path);
2185 end Spec_Path_Name_Of;
2187 ---------------------------
2188 -- Ultimate_Extension_Of --
2189 ---------------------------
2191 function Ultimate_Extension_Of (Project : in Project_Id) return Project_Id
2193 Result : Project_Id := Project;
2196 while Projects.Table (Result).Extended_By /= No_Project loop
2197 Result := Projects.Table (Result).Extended_By;
2201 end Ultimate_Extension_Of;
2203 -- Package initialization
2204 -- What is relationshiop to procedure Initialize
2207 Path_Files.Set_Last (0);