1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Ada.Characters.Handling; use Ada.Characters.Handling;
27 with Ada.Unchecked_Deallocation;
30 with Osint; use Osint;
31 with Output; use Output;
33 with Prj.Err; use Prj.Err;
34 with Snames; use Snames;
35 with Uintp; use Uintp;
37 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
39 with System.Case_Util; use System.Case_Util;
44 Object_Suffix : constant String := Get_Target_Object_Suffix.all;
45 -- File suffix for object files
47 Initial_Buffer_Size : constant := 100;
48 -- Initial size for extensible buffer used in Add_To_Buffer
50 The_Empty_String : Name_Id := No_Name;
52 subtype Known_Casing is Casing_Type range All_Upper_Case .. Mixed_Case;
54 type Cst_String_Access is access constant String;
56 All_Lower_Case_Image : aliased constant String := "lowercase";
57 All_Upper_Case_Image : aliased constant String := "UPPERCASE";
58 Mixed_Case_Image : aliased constant String := "MixedCase";
60 The_Casing_Images : constant array (Known_Casing) of Cst_String_Access :=
61 (All_Lower_Case => All_Lower_Case_Image'Access,
62 All_Upper_Case => All_Upper_Case_Image'Access,
63 Mixed_Case => Mixed_Case_Image'Access);
65 Project_Empty : constant Project_Data :=
66 (Qualifier => Unspecified,
67 Externally_Built => False,
68 Config => Default_Project_Config,
70 Display_Name => No_Name,
71 Path => No_Path_Information,
73 Location => No_Location,
75 Directory => No_Path_Information,
77 Library_Dir => No_Path_Information,
78 Library_Src_Dir => No_Path_Information,
79 Library_ALI_Dir => No_Path_Information,
80 Library_Name => No_Name,
81 Library_Kind => Static,
82 Lib_Internal_Name => No_Name,
83 Standalone_Library => False,
84 Lib_Interface_ALIs => Nil_String,
85 Lib_Auto_Init => False,
86 Libgnarl_Needed => Unknown,
87 Symbol_Data => No_Symbols,
88 Interfaces_Defined => False,
90 Include_Data_Set => False,
91 Source_Dirs => Nil_String,
92 Source_Dir_Ranks => No_Number_List,
93 Object_Directory => No_Path_Information,
94 Library_TS => Empty_Time_Stamp,
95 Exec_Directory => No_Path_Information,
96 Extends => No_Project,
97 Extended_By => No_Project,
98 Languages => No_Language_Index,
99 Decl => No_Declarations,
100 Imported_Projects => null,
101 All_Imported_Projects => null,
102 Ada_Include_Path => null,
103 Imported_Directories_Switches => null,
104 Ada_Objects_Path => null,
105 Objects_Path => null,
106 Include_Path_File => No_Path,
107 Objects_Path_File_With_Libs => No_Path,
108 Objects_Path_File_Without_Libs => No_Path,
109 Config_File_Name => No_Path,
110 Config_File_Temp => False,
111 Config_Checked => False,
112 Need_To_Build_Lib => False,
114 Unkept_Comments => False);
116 procedure Free (Project : in out Project_Id);
117 -- Free memory allocated for Project
119 procedure Free_List (Languages : in out Language_Ptr);
120 procedure Free_List (Source : in out Source_Id);
121 procedure Free_List (Languages : in out Language_List);
122 -- Free memory allocated for the list of languages or sources
124 procedure Free_Units (Table : in out Units_Htable.Instance);
125 -- Free memory allocated for unit information in the project
127 procedure Language_Changed (Iter : in out Source_Iterator);
128 procedure Project_Changed (Iter : in out Source_Iterator);
129 -- Called when a new project or language was selected for this iterator
131 function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean;
132 -- Return True if there is at least one ALI file in the directory Dir
138 procedure Add_To_Buffer
140 To : in out String_Access;
141 Last : in out Natural)
145 To := new String (1 .. Initial_Buffer_Size);
149 -- If Buffer is too small, double its size
151 while Last + S'Length > To'Last loop
153 New_Buffer : constant String_Access :=
154 new String (1 .. 2 * Last);
157 New_Buffer (1 .. Last) := To (1 .. Last);
163 To (Last + 1 .. Last + S'Length) := S;
164 Last := Last + S'Length;
167 ---------------------------
168 -- Delete_Temporary_File --
169 ---------------------------
171 procedure Delete_Temporary_File
172 (Tree : Project_Tree_Ref;
173 Path : Path_Name_Type)
176 pragma Warnings (Off, Dont_Care);
179 if not Debug.Debug_Flag_N then
180 if Current_Verbosity = High then
181 Write_Line ("Removing temp file: " & Get_Name_String (Path));
184 Delete_File (Get_Name_String (Path), Dont_Care);
187 1 .. Temp_Files_Table.Last (Tree.Private_Part.Temp_Files)
189 if Tree.Private_Part.Temp_Files.Table (Index) = Path then
190 Tree.Private_Part.Temp_Files.Table (Index) := No_Path;
194 end Delete_Temporary_File;
196 ---------------------------
197 -- Delete_All_Temp_Files --
198 ---------------------------
200 procedure Delete_All_Temp_Files (Tree : Project_Tree_Ref) is
202 pragma Warnings (Off, Dont_Care);
204 Path : Path_Name_Type;
207 if not Debug.Debug_Flag_N then
209 1 .. Temp_Files_Table.Last (Tree.Private_Part.Temp_Files)
211 Path := Tree.Private_Part.Temp_Files.Table (Index);
213 if Path /= No_Path then
214 if Current_Verbosity = High then
215 Write_Line ("Removing temp file: "
216 & Get_Name_String (Path));
219 Delete_File (Get_Name_String (Path), Dont_Care);
223 Temp_Files_Table.Free (Tree.Private_Part.Temp_Files);
224 Temp_Files_Table.Init (Tree.Private_Part.Temp_Files);
227 -- If any of the environment variables ADA_PRJ_INCLUDE_FILE or
228 -- ADA_PRJ_OBJECTS_FILE has been set, then reset their value to
229 -- the empty string. On VMS, this has the effect of deassigning
230 -- the logical names.
232 if Tree.Private_Part.Current_Source_Path_File /= No_Path then
233 Setenv (Project_Include_Path_File, "");
236 if Tree.Private_Part.Current_Object_Path_File /= No_Path then
237 Setenv (Project_Objects_Path_File, "");
239 end Delete_All_Temp_Files;
241 ---------------------
242 -- Dependency_Name --
243 ---------------------
245 function Dependency_Name
246 (Source_File_Name : File_Name_Type;
247 Dependency : Dependency_File_Kind) return File_Name_Type
258 (Source_File_Name, Makefile_Dependency_Suffix));
264 (Source_File_Name, ALI_Dependency_Suffix));
272 function Empty_File return File_Name_Type is
274 return File_Name_Type (The_Empty_String);
281 function Empty_Project return Project_Data is
283 Prj.Initialize (Tree => No_Project_Tree);
284 return Project_Empty;
291 function Empty_String return Name_Id is
293 return The_Empty_String;
300 procedure Expect (The_Token : Token_Type; Token_Image : String) is
302 if Token /= The_Token then
303 -- ??? Should pass user flags here instead
304 Error_Msg (Gnatmake_Flags, Token_Image & " expected", Token_Ptr);
313 (File : File_Name_Type;
314 With_Suffix : String) return File_Name_Type
319 Get_Name_String (File);
320 Last := Name_Len + 1;
322 while Name_Len /= 0 and then Name_Buffer (Name_Len) /= '.' loop
323 Name_Len := Name_Len - 1;
326 if Name_Len <= 1 then
330 for J in With_Suffix'Range loop
331 Name_Buffer (Name_Len) := With_Suffix (J);
332 Name_Len := Name_Len + 1;
335 Name_Len := Name_Len - 1;
340 ---------------------
341 -- Project_Changed --
342 ---------------------
344 procedure Project_Changed (Iter : in out Source_Iterator) is
346 Iter.Language := Iter.Project.Project.Languages;
347 Language_Changed (Iter);
350 ----------------------
351 -- Language_Changed --
352 ----------------------
354 procedure Language_Changed (Iter : in out Source_Iterator) is
356 Iter.Current := No_Source;
358 if Iter.Language_Name /= No_Name then
359 while Iter.Language /= null
360 and then Iter.Language.Name /= Iter.Language_Name
362 Iter.Language := Iter.Language.Next;
366 -- If there is no matching language in this project, move to next
368 if Iter.Language = No_Language_Index then
369 if Iter.All_Projects then
370 Iter.Project := Iter.Project.Next;
372 if Iter.Project /= null then
373 Project_Changed (Iter);
377 Iter.Project := null;
381 Iter.Current := Iter.Language.First_Source;
383 if Iter.Current = No_Source then
384 Iter.Language := Iter.Language.Next;
385 Language_Changed (Iter);
388 end Language_Changed;
390 ---------------------
391 -- For_Each_Source --
392 ---------------------
394 function For_Each_Source
395 (In_Tree : Project_Tree_Ref;
396 Project : Project_Id := No_Project;
397 Language : Name_Id := No_Name) return Source_Iterator
399 Iter : Source_Iterator;
401 Iter := Source_Iterator'
403 Project => In_Tree.Projects,
404 All_Projects => Project = No_Project,
405 Language_Name => Language,
406 Language => No_Language_Index,
407 Current => No_Source);
409 if Project /= null then
410 while Iter.Project /= null
411 and then Iter.Project.Project /= Project
413 Iter.Project := Iter.Project.Next;
417 Project_Changed (Iter);
426 function Element (Iter : Source_Iterator) return Source_Id is
435 procedure Next (Iter : in out Source_Iterator) is
437 Iter.Current := Iter.Current.Next_In_Lang;
438 if Iter.Current = No_Source then
439 Iter.Language := Iter.Language.Next;
440 Language_Changed (Iter);
444 --------------------------------
445 -- For_Every_Project_Imported --
446 --------------------------------
448 procedure For_Every_Project_Imported
450 With_State : in out State;
451 Imported_First : Boolean := False)
453 use Project_Boolean_Htable;
454 Seen : Project_Boolean_Htable.Instance := Project_Boolean_Htable.Nil;
456 procedure Recursive_Check (Project : Project_Id);
457 -- Check if a project has already been seen. If not seen, mark it as
458 -- Seen, Call Action, and check all its imported projects.
460 ---------------------
461 -- Recursive_Check --
462 ---------------------
464 procedure Recursive_Check (Project : Project_Id) is
468 if not Get (Seen, Project) then
469 Set (Seen, Project, True);
471 if not Imported_First then
472 Action (Project, With_State);
475 -- Visited all extended projects
477 if Project.Extends /= No_Project then
478 Recursive_Check (Project.Extends);
481 -- Visited all imported projects
483 List := Project.Imported_Projects;
484 while List /= null loop
485 Recursive_Check (List.Project);
489 if Imported_First then
490 Action (Project, With_State);
495 -- Start of processing for For_Every_Project_Imported
498 Recursive_Check (Project => By);
500 end For_Every_Project_Imported;
507 (In_Tree : Project_Tree_Ref;
508 Project : Project_Id;
509 In_Imported_Only : Boolean := False;
510 In_Extended_Only : Boolean := False;
511 Base_Name : File_Name_Type) return Source_Id
513 Result : Source_Id := No_Source;
515 procedure Look_For_Sources (Proj : Project_Id; Src : in out Source_Id);
516 -- Look for Base_Name in the sources of Proj
518 ----------------------
519 -- Look_For_Sources --
520 ----------------------
522 procedure Look_For_Sources (Proj : Project_Id; Src : in out Source_Id) is
523 Iterator : Source_Iterator;
526 Iterator := For_Each_Source (In_Tree => In_Tree, Project => Proj);
527 while Element (Iterator) /= No_Source loop
528 if Element (Iterator).File = Base_Name then
529 Src := Element (Iterator);
535 end Look_For_Sources;
537 procedure For_Imported_Projects is new For_Every_Project_Imported
538 (State => Source_Id, Action => Look_For_Sources);
542 -- Start of processing for Find_Source
545 if In_Extended_Only then
547 while Proj /= No_Project loop
548 Look_For_Sources (Proj, Result);
549 exit when Result /= No_Source;
551 Proj := Proj.Extends;
554 elsif In_Imported_Only then
555 Look_For_Sources (Project, Result);
557 if Result = No_Source then
558 For_Imported_Projects
560 With_State => Result);
563 Look_For_Sources (No_Project, Result);
573 function Hash is new System.HTable.Hash (Header_Num => Header_Num);
574 -- Used in implementation of other functions Hash below
576 function Hash (Name : File_Name_Type) return Header_Num is
578 return Hash (Get_Name_String (Name));
581 function Hash (Name : Name_Id) return Header_Num is
583 return Hash (Get_Name_String (Name));
586 function Hash (Name : Path_Name_Type) return Header_Num is
588 return Hash (Get_Name_String (Name));
591 function Hash (Project : Project_Id) return Header_Num is
593 if Project = No_Project then
594 return Header_Num'First;
596 return Hash (Get_Name_String (Project.Name));
604 function Image (The_Casing : Casing_Type) return String is
606 return The_Casing_Images (The_Casing).all;
609 -----------------------------
610 -- Is_Standard_GNAT_Naming --
611 -----------------------------
613 function Is_Standard_GNAT_Naming
614 (Naming : Lang_Naming_Data) return Boolean
617 return Get_Name_String (Naming.Spec_Suffix) = ".ads"
618 and then Get_Name_String (Naming.Body_Suffix) = ".adb"
619 and then Get_Name_String (Naming.Dot_Replacement) = "-";
620 end Is_Standard_GNAT_Naming;
626 procedure Initialize (Tree : Project_Tree_Ref) is
628 if The_Empty_String = No_Name then
631 The_Empty_String := Name_Find;
634 Set_Name_Table_Byte (Name_Project, Token_Type'Pos (Tok_Project));
635 Set_Name_Table_Byte (Name_Extends, Token_Type'Pos (Tok_Extends));
636 Set_Name_Table_Byte (Name_External, Token_Type'Pos (Tok_External));
639 if Tree /= No_Project_Tree then
648 function Is_Extending
649 (Extending : Project_Id;
650 Extended : Project_Id) return Boolean
656 while Proj /= No_Project loop
657 if Proj = Extended then
661 Proj := Proj.Extends;
672 (Source_File_Name : File_Name_Type;
673 Object_File_Suffix : Name_Id := No_Name) return File_Name_Type
676 if Object_File_Suffix = No_Name then
678 (Source_File_Name, Object_Suffix);
681 (Source_File_Name, Get_Name_String (Object_File_Suffix));
685 ----------------------
686 -- Record_Temp_File --
687 ----------------------
689 procedure Record_Temp_File
690 (Tree : Project_Tree_Ref;
691 Path : Path_Name_Type)
694 Temp_Files_Table.Append (Tree.Private_Part.Temp_Files, Path);
695 end Record_Temp_File;
701 procedure Free (Project : in out Project_Id) is
702 procedure Unchecked_Free is new Ada.Unchecked_Deallocation
703 (Project_Data, Project_Id);
706 if Project /= null then
707 Free (Project.Include_Path);
708 Free (Project.Ada_Include_Path);
709 Free (Project.Objects_Path);
710 Free (Project.Ada_Objects_Path);
711 Free_List (Project.Imported_Projects, Free_Project => False);
712 Free_List (Project.All_Imported_Projects, Free_Project => False);
713 Free_List (Project.Languages);
715 Unchecked_Free (Project);
723 procedure Free_List (Languages : in out Language_List) is
724 procedure Unchecked_Free is new Ada.Unchecked_Deallocation
725 (Language_List_Element, Language_List);
728 while Languages /= null loop
729 Tmp := Languages.Next;
730 Unchecked_Free (Languages);
739 procedure Free_List (Source : in out Source_Id) is
740 procedure Unchecked_Free is new
741 Ada.Unchecked_Deallocation (Source_Data, Source_Id);
746 while Source /= No_Source loop
747 Tmp := Source.Next_In_Lang;
748 Free_List (Source.Alternate_Languages);
750 if Source.Unit /= null
751 and then Source.Kind in Spec_Or_Body
753 Source.Unit.File_Names (Source.Kind) := null;
756 Unchecked_Free (Source);
766 (List : in out Project_List;
767 Free_Project : Boolean)
769 procedure Unchecked_Free is new
770 Ada.Unchecked_Deallocation (Project_List_Element, Project_List);
775 while List /= null loop
782 Unchecked_Free (List);
791 procedure Free_List (Languages : in out Language_Ptr) is
792 procedure Unchecked_Free is new
793 Ada.Unchecked_Deallocation (Language_Data, Language_Ptr);
798 while Languages /= null loop
799 Tmp := Languages.Next;
800 Free_List (Languages.First_Source);
801 Unchecked_Free (Languages);
810 procedure Free_Units (Table : in out Units_Htable.Instance) is
811 procedure Unchecked_Free is new
812 Ada.Unchecked_Deallocation (Unit_Data, Unit_Index);
817 Unit := Units_Htable.Get_First (Table);
818 while Unit /= No_Unit_Index loop
819 if Unit.File_Names (Spec) /= null then
820 Unit.File_Names (Spec).Unit := No_Unit_Index;
823 if Unit.File_Names (Impl) /= null then
824 Unit.File_Names (Impl).Unit := No_Unit_Index;
827 Unchecked_Free (Unit);
828 Unit := Units_Htable.Get_Next (Table);
831 Units_Htable.Reset (Table);
838 procedure Free (Tree : in out Project_Tree_Ref) is
839 procedure Unchecked_Free is new
840 Ada.Unchecked_Deallocation (Project_Tree_Data, Project_Tree_Ref);
844 Name_List_Table.Free (Tree.Name_Lists);
845 Number_List_Table.Free (Tree.Number_Lists);
846 String_Element_Table.Free (Tree.String_Elements);
847 Variable_Element_Table.Free (Tree.Variable_Elements);
848 Array_Element_Table.Free (Tree.Array_Elements);
849 Array_Table.Free (Tree.Arrays);
850 Package_Table.Free (Tree.Packages);
851 Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
853 Free_List (Tree.Projects, Free_Project => True);
854 Free_Units (Tree.Units_HT);
858 Temp_Files_Table.Free (Tree.Private_Part.Temp_Files);
860 Unchecked_Free (Tree);
868 procedure Reset (Tree : Project_Tree_Ref) is
872 Name_List_Table.Init (Tree.Name_Lists);
873 Number_List_Table.Init (Tree.Number_Lists);
874 String_Element_Table.Init (Tree.String_Elements);
875 Variable_Element_Table.Init (Tree.Variable_Elements);
876 Array_Element_Table.Init (Tree.Array_Elements);
877 Array_Table.Init (Tree.Arrays);
878 Package_Table.Init (Tree.Packages);
879 Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
881 Free_List (Tree.Projects, Free_Project => True);
882 Free_Units (Tree.Units_HT);
884 -- Private part table
886 Temp_Files_Table.Init (Tree.Private_Part.Temp_Files);
888 Tree.Private_Part.Current_Source_Path_File := No_Path;
889 Tree.Private_Part.Current_Object_Path_File := No_Path;
896 function Switches_Name
897 (Source_File_Name : File_Name_Type) return File_Name_Type
900 return Extend_Name (Source_File_Name, Switches_Dependency_Suffix);
907 function Value (Image : String) return Casing_Type is
909 for Casing in The_Casing_Images'Range loop
910 if To_Lower (Image) = To_Lower (The_Casing_Images (Casing).all) then
915 raise Constraint_Error;
918 ---------------------
919 -- Has_Ada_Sources --
920 ---------------------
922 function Has_Ada_Sources (Data : Project_Id) return Boolean is
926 Lang := Data.Languages;
927 while Lang /= No_Language_Index loop
928 if Lang.Name = Name_Ada then
929 return Lang.First_Source /= No_Source;
937 ------------------------
938 -- Contains_ALI_Files --
939 ------------------------
941 function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean is
942 Dir_Name : constant String := Get_Name_String (Dir);
944 Name : String (1 .. 1_000);
946 Result : Boolean := False;
949 Open (Direct, Dir_Name);
951 -- For each file in the directory, check if it is an ALI file
954 Read (Direct, Name, Last);
956 Canonical_Case_File_Name (Name (1 .. Last));
957 Result := Last >= 5 and then Name (Last - 3 .. Last) = ".ali";
965 -- If there is any problem, close the directory if open and return True.
966 -- The library directory will be added to the path.
969 if Is_Open (Direct) then
974 end Contains_ALI_Files;
976 --------------------------
977 -- Get_Object_Directory --
978 --------------------------
980 function Get_Object_Directory
981 (Project : Project_Id;
982 Including_Libraries : Boolean;
983 Only_If_Ada : Boolean := False) return Path_Name_Type
986 if (Project.Library and then Including_Libraries)
988 (Project.Object_Directory /= No_Path_Information
989 and then (not Including_Libraries or else not Project.Library))
991 -- For a library project, add the library ALI directory if there is
992 -- no object directory or if the library ALI directory contains ALI
993 -- files; otherwise add the object directory.
995 if Project.Library then
996 if Project.Object_Directory = No_Path_Information
997 or else Contains_ALI_Files (Project.Library_ALI_Dir.Name)
999 return Project.Library_ALI_Dir.Name;
1001 return Project.Object_Directory.Name;
1004 -- For a non-library project, add object directory if it is not a
1005 -- virtual project, and if there are Ada sources in the project or
1006 -- one of the projects it extends. If there are no Ada sources,
1007 -- adding the object directory could disrupt the order of the
1008 -- object dirs in the path.
1010 elsif not Project.Virtual then
1012 Add_Object_Dir : Boolean;
1016 Add_Object_Dir := not Only_If_Ada;
1018 while not Add_Object_Dir and then Prj /= No_Project loop
1019 if Has_Ada_Sources (Prj) then
1020 Add_Object_Dir := True;
1026 if Add_Object_Dir then
1027 return Project.Object_Directory.Name;
1034 end Get_Object_Directory;
1036 -----------------------------------
1037 -- Ultimate_Extending_Project_Of --
1038 -----------------------------------
1040 function Ultimate_Extending_Project_Of
1041 (Proj : Project_Id) return Project_Id
1047 while Prj /= null and then Prj.Extended_By /= No_Project loop
1048 Prj := Prj.Extended_By;
1052 end Ultimate_Extending_Project_Of;
1054 -----------------------------------
1055 -- Compute_All_Imported_Projects --
1056 -----------------------------------
1058 procedure Compute_All_Imported_Projects (Project : Project_Id) is
1060 procedure Recursive_Add (Prj : Project_Id; Dummy : in out Boolean);
1061 -- Recursively add the projects imported by project Project, but not
1062 -- those that are extended.
1068 procedure Recursive_Add (Prj : Project_Id; Dummy : in out Boolean) is
1069 pragma Unreferenced (Dummy);
1070 List : Project_List;
1074 -- A project is not importing itself
1076 Prj2 := Ultimate_Extending_Project_Of (Prj);
1078 if Project /= Prj2 then
1080 -- Check that the project is not already in the list. We know the
1081 -- one passed to Recursive_Add have never been visited before, but
1082 -- the one passed it are the extended projects.
1084 List := Project.All_Imported_Projects;
1085 while List /= null loop
1086 if List.Project = Prj2 then
1093 -- Add it to the list
1095 Project.All_Imported_Projects :=
1096 new Project_List_Element'
1098 Next => Project.All_Imported_Projects);
1102 procedure For_All_Projects is
1103 new For_Every_Project_Imported (Boolean, Recursive_Add);
1105 Dummy : Boolean := False;
1108 Free_List (Project.All_Imported_Projects, Free_Project => False);
1109 For_All_Projects (Project, Dummy);
1110 end Compute_All_Imported_Projects;
1116 function Is_Compilable (Source : Source_Id) return Boolean is
1118 return Source.Language.Config.Compiler_Driver /= No_File
1119 and then Length_Of_Name (Source.Language.Config.Compiler_Driver) /= 0
1120 and then not Source.Locally_Removed;
1123 ------------------------------
1124 -- Object_To_Global_Archive --
1125 ------------------------------
1127 function Object_To_Global_Archive (Source : Source_Id) return Boolean is
1129 return Source.Language.Config.Kind = File_Based
1130 and then Source.Kind = Impl
1131 and then Source.Language.Config.Objects_Linked
1132 and then Is_Compilable (Source)
1133 and then Source.Language.Config.Object_Generated;
1134 end Object_To_Global_Archive;
1136 ----------------------------
1137 -- Get_Language_From_Name --
1138 ----------------------------
1140 function Get_Language_From_Name
1141 (Project : Project_Id;
1142 Name : String) return Language_Ptr
1145 Result : Language_Ptr;
1148 Name_Len := Name'Length;
1149 Name_Buffer (1 .. Name_Len) := Name;
1150 To_Lower (Name_Buffer (1 .. Name_Len));
1153 Result := Project.Languages;
1154 while Result /= No_Language_Index loop
1155 if Result.Name = N then
1159 Result := Result.Next;
1162 return No_Language_Index;
1163 end Get_Language_From_Name;
1169 function Other_Part (Source : Source_Id) return Source_Id is
1171 if Source.Unit /= No_Unit_Index then
1174 return Source.Unit.File_Names (Spec);
1176 return Source.Unit.File_Names (Impl);
1189 function Create_Flags
1190 (Report_Error : Error_Handler;
1191 When_No_Sources : Error_Warning;
1192 Require_Sources_Other_Lang : Boolean := True;
1193 Allow_Duplicate_Basenames : Boolean := True;
1194 Compiler_Driver_Mandatory : Boolean := False;
1195 Error_On_Unknown_Language : Boolean := True;
1196 Require_Obj_Dirs : Error_Warning := Error)
1197 return Processing_Flags
1200 return Processing_Flags'
1201 (Report_Error => Report_Error,
1202 When_No_Sources => When_No_Sources,
1203 Require_Sources_Other_Lang => Require_Sources_Other_Lang,
1204 Allow_Duplicate_Basenames => Allow_Duplicate_Basenames,
1205 Error_On_Unknown_Language => Error_On_Unknown_Language,
1206 Compiler_Driver_Mandatory => Compiler_Driver_Mandatory,
1207 Require_Obj_Dirs => Require_Obj_Dirs);
1211 -- Make sure that the standard config and user project file extensions are
1212 -- compatible with canonical case file naming.
1214 Canonical_Case_File_Name (Config_Project_File_Extension);
1215 Canonical_Case_File_Name (Project_File_Extension);