1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2004-2011, 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 ------------------------------------------------------------------------------
28 with Err_Vars; use Err_Vars;
32 with Osint; use Osint;
33 with Output; use Output;
37 with Prj.Util; use Prj.Util;
39 with Snames; use Snames;
43 with Ada.Command_Line; use Ada.Command_Line;
44 with Ada.Unchecked_Deallocation;
46 with GNAT.Case_Util; use GNAT.Case_Util;
47 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
49 with GNAT.Regexp; use GNAT.Regexp;
51 package body Makeutl is
53 type Linker_Options_Data is record
55 Options : String_List_Id;
58 Linker_Option_Initial_Count : constant := 20;
60 Linker_Options_Buffer : String_List_Access :=
61 new String_List (1 .. Linker_Option_Initial_Count);
63 Last_Linker_Option : Natural := 0;
65 package Linker_Opts is new Table.Table (
66 Table_Component_Type => Linker_Options_Data,
67 Table_Index_Type => Integer,
70 Table_Increment => 100,
71 Table_Name => "Make.Linker_Opts");
73 procedure Add_Linker_Option (Option : String);
80 (Option : String_Access;
81 To : in out String_List_Access;
82 Last : in out Natural)
85 if Last = To'Last then
87 New_Options : constant String_List_Access :=
88 new String_List (1 .. To'Last * 2);
91 New_Options (To'Range) := To.all;
93 -- Set all elements of the original options to null to avoid
94 -- deallocation of copies.
96 To.all := (others => null);
109 To : in out String_List_Access;
110 Last : in out Natural)
113 Add (Option => new String'(Option), To => To, Last => Last);
116 -----------------------
117 -- Add_Linker_Option --
118 -----------------------
120 procedure Add_Linker_Option (Option : String) is
122 if Option'Length > 0 then
123 if Last_Linker_Option = Linker_Options_Buffer'Last then
125 New_Buffer : constant String_List_Access :=
127 (1 .. Linker_Options_Buffer'Last +
128 Linker_Option_Initial_Count);
130 New_Buffer (Linker_Options_Buffer'Range) :=
131 Linker_Options_Buffer.all;
132 Linker_Options_Buffer.all := (others => null);
133 Free (Linker_Options_Buffer);
134 Linker_Options_Buffer := New_Buffer;
138 Last_Linker_Option := Last_Linker_Option + 1;
139 Linker_Options_Buffer (Last_Linker_Option) := new String'(Option);
141 end Add_Linker_Option;
143 -------------------------
144 -- Base_Name_Index_For --
145 -------------------------
147 function Base_Name_Index_For
150 Index_Separator : Character) return File_Name_Type
152 Result : File_Name_Type;
156 Add_Str_To_Name_Buffer (Base_Name (Main));
158 -- Remove the extension, if any, that is the last part of the base name
159 -- starting with a dot and following some characters.
161 for J in reverse 2 .. Name_Len loop
162 if Name_Buffer (J) = '.' then
168 -- Add the index info, if index is different from 0
170 if Main_Index > 0 then
171 Add_Char_To_Name_Buffer (Index_Separator);
174 Img : constant String := Main_Index'Img;
176 Add_Str_To_Name_Buffer (Img (2 .. Img'Last));
182 end Base_Name_Index_For;
184 ------------------------------
185 -- Check_Source_Info_In_ALI --
186 ------------------------------
188 function Check_Source_Info_In_ALI
190 Tree : Project_Tree_Ref) return Boolean
195 -- Loop through units
197 for U in ALIs.Table (The_ALI).First_Unit ..
198 ALIs.Table (The_ALI).Last_Unit
200 -- Check if the file name is one of the source of the unit
202 Get_Name_String (Units.Table (U).Uname);
203 Name_Len := Name_Len - 2;
204 Unit_Name := Name_Find;
206 if File_Not_A_Source_Of (Tree, Unit_Name, Units.Table (U).Sfile) then
210 -- Loop to do same check for each of the withed units
212 for W in Units.Table (U).First_With .. Units.Table (U).Last_With loop
214 WR : ALI.With_Record renames Withs.Table (W);
217 if WR.Sfile /= No_File then
218 Get_Name_String (WR.Uname);
219 Name_Len := Name_Len - 2;
220 Unit_Name := Name_Find;
222 if File_Not_A_Source_Of (Tree, Unit_Name, WR.Sfile) then
230 -- Loop to check subunits and replaced sources
232 for D in ALIs.Table (The_ALI).First_Sdep ..
233 ALIs.Table (The_ALI).Last_Sdep
236 SD : Sdep_Record renames Sdep.Table (D);
239 Unit_Name := SD.Subunit_Name;
241 if Unit_Name = No_Name then
243 -- Check if this source file has been replaced by a source with
244 -- a different file name.
246 if Tree /= null and then Tree.Replaced_Source_Number > 0 then
248 Replacement : constant File_Name_Type :=
249 Replaced_Source_HTable.Get
250 (Tree.Replaced_Sources, SD.Sfile);
253 if Replacement /= No_File then
257 Get_Name_String (SD.Sfile) &
258 " has been replaced by " &
259 Get_Name_String (Replacement));
268 -- For separates, the file is no longer associated with the
269 -- unit ("proc-sep.adb" is not associated with unit "proc.sep")
270 -- so we need to check whether the source file still exists in
271 -- the source tree: it will if it matches the naming scheme
272 -- (and then will be for the same unit).
276 Project => No_Project,
277 Base_Name => SD.Sfile) = No_Source
279 -- If this is not a runtime file or if, when gnatmake switch
280 -- -a is used, we are not able to find this subunit in the
281 -- source directories, then recompilation is needed.
283 if not Fname.Is_Internal_File_Name (SD.Sfile)
285 (Check_Readonly_Files
286 and then Full_Source_Name (SD.Sfile) = No_File)
290 ("While parsing ALI file, file "
291 & Get_Name_String (SD.Sfile)
292 & " is indicated as containing subunit "
293 & Get_Name_String (Unit_Name)
294 & " but this does not match what was found while"
295 & " parsing the project. Will recompile");
306 end Check_Source_Info_In_ALI;
308 --------------------------------
309 -- Create_Binder_Mapping_File --
310 --------------------------------
312 function Create_Binder_Mapping_File
313 (Project_Tree : Project_Tree_Ref) return Path_Name_Type
315 Mapping_Path : Path_Name_Type := No_Path;
317 Mapping_FD : File_Descriptor := Invalid_FD;
318 -- A File Descriptor for an eventual mapping file
320 ALI_Unit : Unit_Name_Type := No_Unit_Name;
321 -- The unit name of an ALI file
323 ALI_Name : File_Name_Type := No_File;
324 -- The file name of the ALI file
326 ALI_Project : Project_Id := No_Project;
327 -- The project of the ALI file
330 OK : Boolean := False;
337 Tempdir.Create_Temp_File (Mapping_FD, Mapping_Path);
338 Record_Temp_File (Project_Tree.Shared, Mapping_Path);
340 if Mapping_FD /= Invalid_FD then
343 -- Traverse all units
345 Unit := Units_Htable.Get_First (Project_Tree.Units_HT);
346 while Unit /= No_Unit_Index loop
347 if Unit.Name /= No_Name then
349 -- If there is a body, put it in the mapping
351 if Unit.File_Names (Impl) /= No_Source
352 and then Unit.File_Names (Impl).Project /= No_Project
354 Get_Name_String (Unit.Name);
355 Add_Str_To_Name_Buffer ("%b");
356 ALI_Unit := Name_Find;
358 Lib_File_Name (Unit.File_Names (Impl).Display_File);
359 ALI_Project := Unit.File_Names (Impl).Project;
361 -- Otherwise, if there is a spec, put it in the mapping
363 elsif Unit.File_Names (Spec) /= No_Source
364 and then Unit.File_Names (Spec).Project /= No_Project
366 Get_Name_String (Unit.Name);
367 Add_Str_To_Name_Buffer ("%s");
368 ALI_Unit := Name_Find;
370 Lib_File_Name (Unit.File_Names (Spec).Display_File);
371 ALI_Project := Unit.File_Names (Spec).Project;
377 -- If we have something to put in the mapping then do it now.
378 -- However, if the project is extended, we don't put anything
379 -- in the mapping file, since we don't know where the ALI file
380 -- is: it might be in the extended project object directory as
381 -- well as in the extending project object directory.
383 if ALI_Name /= No_File
384 and then ALI_Project.Extended_By = No_Project
385 and then ALI_Project.Extends = No_Project
387 -- First check if the ALI file exists. If it does not, do
388 -- not put the unit in the mapping file.
391 ALI : constant String := Get_Name_String (ALI_Name);
394 -- For library projects, use the library ALI directory,
395 -- for other projects, use the object directory.
397 if ALI_Project.Library then
399 (ALI_Project.Library_ALI_Dir.Display_Name);
402 (ALI_Project.Object_Directory.Display_Name);
405 Add_Str_To_Name_Buffer (ALI);
406 Add_Char_To_Name_Buffer (ASCII.LF);
409 ALI_Path_Name : constant String :=
410 Name_Buffer (1 .. Name_Len);
414 (ALI_Path_Name (1 .. ALI_Path_Name'Last - 1))
416 -- First line is the unit name
418 Get_Name_String (ALI_Unit);
419 Add_Char_To_Name_Buffer (ASCII.LF);
423 Name_Buffer (1)'Address,
425 OK := Bytes = Name_Len;
429 -- Second line it the ALI file name
431 Get_Name_String (ALI_Name);
432 Add_Char_To_Name_Buffer (ASCII.LF);
436 Name_Buffer (1)'Address,
438 OK := (Bytes = Name_Len);
442 -- Third line it the ALI path name
447 ALI_Path_Name (1)'Address,
448 ALI_Path_Name'Length);
449 OK := (Bytes = ALI_Path_Name'Length);
451 -- If OK is False, it means we were unable to
452 -- write a line. No point in continuing with the
462 Unit := Units_Htable.Get_Next (Project_Tree.Units_HT);
465 Close (Mapping_FD, Status);
470 -- If the creation of the mapping file was successful, we add the switch
471 -- to the arguments of gnatbind.
479 end Create_Binder_Mapping_File;
485 function Create_Name (Name : String) return File_Name_Type is
488 Add_Str_To_Name_Buffer (Name);
492 function Create_Name (Name : String) return Name_Id is
495 Add_Str_To_Name_Buffer (Name);
499 function Create_Name (Name : String) return Path_Name_Type is
502 Add_Str_To_Name_Buffer (Name);
506 ----------------------------
507 -- Executable_Prefix_Path --
508 ----------------------------
510 function Executable_Prefix_Path return String is
511 Exec_Name : constant String := Command_Name;
513 function Get_Install_Dir (S : String) return String;
514 -- S is the executable name preceded by the absolute or relative path,
515 -- e.g. "c:\usr\bin\gcc.exe". Returns the absolute directory where "bin"
516 -- lies (in the example "C:\usr"). If the executable is not in a "bin"
517 -- directory, return "".
519 ---------------------
520 -- Get_Install_Dir --
521 ---------------------
523 function Get_Install_Dir (S : String) return String is
525 Path_Last : Integer := 0;
528 for J in reverse Exec'Range loop
529 if Exec (J) = Directory_Separator then
535 if Path_Last >= Exec'First + 2 then
536 To_Lower (Exec (Path_Last - 2 .. Path_Last));
539 if Path_Last < Exec'First + 2
540 or else Exec (Path_Last - 2 .. Path_Last) /= "bin"
541 or else (Path_Last - 3 >= Exec'First
542 and then Exec (Path_Last - 3) /= Directory_Separator)
547 return Normalize_Pathname
548 (Exec (Exec'First .. Path_Last - 4),
549 Resolve_Links => Opt.Follow_Links_For_Dirs)
550 & Directory_Separator;
553 -- Beginning of Executable_Prefix_Path
556 -- For VMS, the path returned is always /gnu/
558 if Hostparm.OpenVMS then
562 -- First determine if a path prefix was placed in front of the
565 for J in reverse Exec_Name'Range loop
566 if Exec_Name (J) = Directory_Separator then
567 return Get_Install_Dir (Exec_Name);
571 -- If we get here, the user has typed the executable name with no
575 Path : String_Access := Locate_Exec_On_Path (Exec_Name);
581 Dir : constant String := Get_Install_Dir (Path.all);
588 end Executable_Prefix_Path;
594 procedure Fail_Program
595 (Project_Tree : Project_Tree_Ref;
597 Flush_Messages : Boolean := True)
600 if Flush_Messages then
601 if Total_Errors_Detected /= 0 or else Warnings_Detected /= 0 then
606 Finish_Program (Project_Tree, E_Fatal, S => S);
613 procedure Finish_Program
614 (Project_Tree : Project_Tree_Ref;
615 Exit_Code : Osint.Exit_Code_Type := Osint.E_Success;
619 if not Debug.Debug_Flag_N then
620 Delete_Temp_Config_Files (Project_Tree);
622 if Project_Tree /= null then
623 Delete_All_Temp_Files (Project_Tree.Shared);
628 if Exit_Code /= E_Success then
635 -- Output Namet statistics
639 Exit_Program (Exit_Code);
642 --------------------------
643 -- File_Not_A_Source_Of --
644 --------------------------
646 function File_Not_A_Source_Of
647 (Project_Tree : Project_Tree_Ref;
649 Sfile : File_Name_Type) return Boolean
651 Unit : constant Unit_Index :=
652 Units_Htable.Get (Project_Tree.Units_HT, Uname);
654 At_Least_One_File : Boolean := False;
657 if Unit /= No_Unit_Index then
658 for F in Unit.File_Names'Range loop
659 if Unit.File_Names (F) /= null then
660 At_Least_One_File := True;
661 if Unit.File_Names (F).File = Sfile then
667 if not At_Least_One_File then
669 -- The unit was probably created initially for a separate unit
670 -- (which are initially created as IMPL when both suffixes are the
671 -- same). Later on, Override_Kind changed the type of the file,
672 -- and the unit is no longer valid in fact.
677 Verbose_Msg (Uname, "sources do not include ", Name_Id (Sfile));
682 end File_Not_A_Source_Of;
688 procedure Get_Switches
689 (Source : Prj.Source_Id;
691 Project_Tree : Project_Tree_Ref;
692 Value : out Variable_Value;
693 Is_Default : out Boolean)
697 (Source_File => Source.File,
698 Source_Lang => Source.Language.Name,
699 Source_Prj => Source.Project,
700 Pkg_Name => Pkg_Name,
701 Project_Tree => Project_Tree,
703 Is_Default => Is_Default);
710 procedure Get_Switches
711 (Source_File : File_Name_Type;
712 Source_Lang : Name_Id;
713 Source_Prj : Project_Id;
715 Project_Tree : Project_Tree_Ref;
716 Value : out Variable_Value;
717 Is_Default : out Boolean;
718 Test_Without_Suffix : Boolean := False;
719 Check_ALI_Suffix : Boolean := False)
721 Project : constant Project_Id :=
722 Ultimate_Extending_Project_Of (Source_Prj);
723 Pkg : constant Package_Id :=
726 In_Packages => Project.Decl.Packages,
727 Shared => Project_Tree.Shared);
733 if Source_File /= No_File then
734 Value := Prj.Util.Value_Of
735 (Name => Name_Id (Source_File),
736 Attribute_Or_Array_Name => Name_Switches,
738 Shared => Project_Tree.Shared,
739 Allow_Wildcards => True);
742 if Value = Nil_Variable_Value
743 and then Test_Without_Suffix
746 Get_Language_From_Name (Project, Get_Name_String (Source_Lang));
750 Naming : Lang_Naming_Data renames Lang.Config.Naming_Data;
751 SF_Name : constant String := Get_Name_String (Source_File);
752 Last : Positive := SF_Name'Length;
753 Name : String (1 .. Last + 3);
754 Spec_Suffix : String := Get_Name_String (Naming.Spec_Suffix);
755 Body_Suffix : String := Get_Name_String (Naming.Body_Suffix);
756 Truncated : Boolean := False;
759 Canonical_Case_File_Name (Spec_Suffix);
760 Canonical_Case_File_Name (Body_Suffix);
761 Name (1 .. Last) := SF_Name;
763 if Last > Body_Suffix'Length
764 and then Name (Last - Body_Suffix'Length + 1 .. Last) =
768 Last := Last - Body_Suffix'Length;
772 and then Last > Spec_Suffix'Length
773 and then Name (Last - Spec_Suffix'Length + 1 .. Last) =
777 Last := Last - Spec_Suffix'Length;
782 Add_Str_To_Name_Buffer (Name (1 .. Last));
784 Value := Prj.Util.Value_Of
786 Attribute_Or_Array_Name => Name_Switches,
788 Shared => Project_Tree.Shared,
789 Allow_Wildcards => True);
792 if Value = Nil_Variable_Value
793 and then Check_ALI_Suffix
795 Last := SF_Name'Length;
796 while Name (Last) /= '.' loop
801 Add_Str_To_Name_Buffer (Name (1 .. Last));
802 Add_Str_To_Name_Buffer ("ali");
804 Value := Prj.Util.Value_Of
806 Attribute_Or_Array_Name => Name_Switches,
808 Shared => Project_Tree.Shared,
809 Allow_Wildcards => True);
815 if Value = Nil_Variable_Value then
819 (Name => Source_Lang,
820 Attribute_Or_Array_Name => Name_Switches,
822 Shared => Project_Tree.Shared,
823 Force_Lower_Case_Index => True);
826 if Value = Nil_Variable_Value then
829 (Name => All_Other_Names,
830 Attribute_Or_Array_Name => Name_Switches,
832 Shared => Project_Tree.Shared,
833 Force_Lower_Case_Index => True);
836 if Value = Nil_Variable_Value then
839 (Name => Source_Lang,
840 Attribute_Or_Array_Name => Name_Default_Switches,
842 Shared => Project_Tree.Shared);
850 procedure Inform (N : File_Name_Type; Msg : String) is
852 Inform (Name_Id (N), Msg);
855 procedure Inform (N : Name_Id := No_Name; Msg : String) is
857 Osint.Write_Program_Name;
865 Name : constant String := Get_Name_String (N);
867 if Debug.Debug_Flag_F and then Is_Absolute_Path (Name) then
868 Write_Str (File_Name (Name));
881 ------------------------------
882 -- Initialize_Source_Record --
883 ------------------------------
885 procedure Initialize_Source_Record (Source : Prj.Source_Id) is
886 procedure Set_Object_Project
887 (Obj_Dir : String; Obj_Proj : Project_Id; Obj_Path : Path_Name_Type;
888 Stamp : Time_Stamp_Type);
889 -- Update information about object file, switches file,...
891 ------------------------
892 -- Set_Object_Project --
893 ------------------------
895 procedure Set_Object_Project
896 (Obj_Dir : String; Obj_Proj : Project_Id; Obj_Path : Path_Name_Type;
897 Stamp : Time_Stamp_Type) is
899 Source.Object_Project := Obj_Proj;
900 Source.Object_Path := Obj_Path;
901 Source.Object_TS := Stamp;
903 if Source.Language.Config.Dependency_Kind /= None then
905 Dep_Path : constant String :=
908 Get_Name_String (Source.Dep_Name),
909 Resolve_Links => Opt.Follow_Links_For_Files,
910 Directory => Obj_Dir);
912 Source.Dep_Path := Create_Name (Dep_Path);
913 Source.Dep_TS := Osint.Unknown_Attributes;
917 -- Get the path of the switches file, even if Opt.Check_Switches is
918 -- not set, as switch -s may be in the Builder switches that have not
922 Switches_Path : constant String :=
924 (Name => Get_Name_String (Source.Switches),
925 Resolve_Links => Opt.Follow_Links_For_Files,
926 Directory => Obj_Dir);
928 Source.Switches_Path := Create_Name (Switches_Path);
930 if Stamp /= Empty_Time_Stamp then
931 Source.Switches_TS := File_Stamp (Source.Switches_Path);
934 end Set_Object_Project;
936 Obj_Proj : Project_Id;
939 -- Nothing to do if source record has already been fully initialized
941 if Source.Initialized then
945 -- Systematically recompute the time stamp
947 Source.Source_TS := File_Stamp (Source.Path.Display_Name);
949 -- Parse the source file to check whether we have a subunit
951 if Source.Language.Config.Kind = Unit_Based
952 and then Source.Kind = Impl
953 and then Is_Subunit (Source)
958 if Source.Language.Config.Object_Generated
959 and then Is_Compilable (Source)
961 -- First, get the correct object file name and dependency file name
962 -- if the source is in a multi-unit file.
964 if Source.Index /= 0 then
967 (Source_File_Name => Source.File,
968 Source_Index => Source.Index,
970 Source.Language.Config.Multi_Unit_Object_Separator,
971 Object_File_Suffix =>
972 Source.Language.Config.Object_File_Suffix);
976 (Source.Object, Source.Language.Config.Dependency_Kind);
979 -- Find the object file for that source. It could be either in the
980 -- current project or in an extended project (it might actually not
981 -- exist yet in the ultimate extending project, but if not found
982 -- elsewhere that's where we'll expect to find it).
984 Obj_Proj := Source.Project;
985 while Obj_Proj /= No_Project loop
987 Dir : constant String := Get_Name_String
988 (Obj_Proj.Object_Directory.Display_Name);
990 Object_Path : constant String :=
993 Get_Name_String (Source.Object),
995 Opt.Follow_Links_For_Files,
998 Obj_Path : constant Path_Name_Type := Create_Name (Object_Path);
999 Stamp : Time_Stamp_Type := Empty_Time_Stamp;
1002 -- For specs, we do not check object files if there is a body.
1003 -- This saves a system call. On the other hand, we do need to
1004 -- know the object_path, in case the user has passed the .ads
1005 -- on the command line to compile the spec only.
1007 if Source.Kind /= Spec
1008 or else Source.Unit = No_Unit_Index
1009 or else Source.Unit.File_Names (Impl) = No_Source
1011 Stamp := File_Stamp (Obj_Path);
1014 if Stamp /= Empty_Time_Stamp
1015 or else (Obj_Proj.Extended_By = No_Project
1016 and then Source.Object_Project = No_Project)
1018 Set_Object_Project (Dir, Obj_Proj, Obj_Path, Stamp);
1021 Obj_Proj := Obj_Proj.Extended_By;
1025 elsif Source.Language.Config.Dependency_Kind = Makefile then
1027 Object_Dir : constant String :=
1029 (Source.Project.Object_Directory.Display_Name);
1030 Dep_Path : constant String :=
1032 (Name => Get_Name_String (Source.Dep_Name),
1034 Opt.Follow_Links_For_Files,
1035 Directory => Object_Dir);
1037 Source.Dep_Path := Create_Name (Dep_Path);
1038 Source.Dep_TS := Osint.Unknown_Attributes;
1042 Source.Initialized := True;
1043 end Initialize_Source_Record;
1045 ----------------------------
1046 -- Is_External_Assignment --
1047 ----------------------------
1049 function Is_External_Assignment
1050 (Env : Prj.Tree.Environment;
1051 Argv : String) return Boolean
1053 Start : Positive := 3;
1054 Finish : Natural := Argv'Last;
1056 pragma Assert (Argv'First = 1);
1057 pragma Assert (Argv (1 .. 2) = "-X");
1060 if Argv'Last < 5 then
1063 elsif Argv (3) = '"' then
1064 if Argv (Argv'Last) /= '"' or else Argv'Last < 7 then
1068 Finish := Argv'Last - 1;
1072 return Prj.Ext.Check
1073 (Self => Env.External,
1074 Declaration => Argv (Start .. Finish));
1075 end Is_External_Assignment;
1081 function Is_Subunit (Source : Prj.Source_Id) return Boolean is
1082 Src_Ind : Source_File_Index;
1085 if Source.Kind = Sep then
1088 -- A Spec, a file based language source or a body with a spec cannot be
1091 elsif Source.Kind = Spec
1092 or else Source.Unit = No_Unit_Index
1093 or else Other_Part (Source) /= No_Source
1098 -- Here, we are assuming that the language is Ada, as it is the only
1099 -- unit based language that we know.
1102 Sinput.P.Load_Project_File
1103 (Get_Name_String (Source.Path.Display_Name));
1105 return Sinput.P.Source_File_Is_Subunit (Src_Ind);
1108 -----------------------------
1109 -- Linker_Options_Switches --
1110 -----------------------------
1112 function Linker_Options_Switches
1113 (Project : Project_Id;
1114 Do_Fail : Fail_Proc;
1115 In_Tree : Project_Tree_Ref) return String_List
1117 procedure Recursive_Add
1119 In_Tree : Project_Tree_Ref;
1120 Dummy : in out Boolean);
1121 -- The recursive routine used to add linker options
1127 procedure Recursive_Add
1129 In_Tree : Project_Tree_Ref;
1130 Dummy : in out Boolean)
1132 pragma Unreferenced (Dummy);
1134 Linker_Package : Package_Id;
1135 Options : Variable_Value;
1140 (Name => Name_Linker,
1141 In_Packages => Proj.Decl.Packages,
1142 Shared => In_Tree.Shared);
1148 Attribute_Or_Array_Name => Name_Linker_Options,
1149 In_Package => Linker_Package,
1150 Shared => In_Tree.Shared);
1152 -- If attribute is present, add the project with the attribute to
1153 -- table Linker_Opts.
1155 if Options /= Nil_Variable_Value then
1156 Linker_Opts.Increment_Last;
1157 Linker_Opts.Table (Linker_Opts.Last) :=
1158 (Project => Proj, Options => Options.Values);
1162 procedure For_All_Projects is
1163 new For_Every_Project_Imported (Boolean, Recursive_Add);
1165 Dummy : Boolean := False;
1167 -- Start of processing for Linker_Options_Switches
1172 For_All_Projects (Project, In_Tree, Dummy, Imported_First => True);
1174 Last_Linker_Option := 0;
1176 for Index in reverse 1 .. Linker_Opts.Last loop
1178 Options : String_List_Id;
1179 Proj : constant Project_Id :=
1180 Linker_Opts.Table (Index).Project;
1182 Dir_Path : constant String :=
1183 Get_Name_String (Proj.Directory.Name);
1186 Options := Linker_Opts.Table (Index).Options;
1187 while Options /= Nil_String loop
1188 Option := In_Tree.Shared.String_Elements.Table (Options).Value;
1189 Get_Name_String (Option);
1191 -- Do not consider empty linker options
1193 if Name_Len /= 0 then
1194 Add_Linker_Option (Name_Buffer (1 .. Name_Len));
1196 -- Object files and -L switches specified with relative
1197 -- paths must be converted to absolute paths.
1199 Test_If_Relative_Path
1200 (Switch => Linker_Options_Buffer (Last_Linker_Option),
1203 Including_L_Switch => True);
1206 Options := In_Tree.Shared.String_Elements.Table (Options).Next;
1211 return Linker_Options_Buffer (1 .. Last_Linker_Option);
1212 end Linker_Options_Switches;
1218 package body Mains is
1220 package Names is new Table.Table
1221 (Table_Component_Type => Main_Info,
1222 Table_Index_Type => Integer,
1223 Table_Low_Bound => 1,
1224 Table_Initial => 10,
1225 Table_Increment => 100,
1226 Table_Name => "Makeutl.Mains.Names");
1227 -- The table that stores the mains
1229 Current : Natural := 0;
1230 -- The index of the last main retrieved from the table
1232 Count_Of_Mains_With_No_Tree : Natural := 0;
1233 -- Number of main units for which we do not know the project tree
1242 Location : Source_Ptr := No_Location;
1243 Project : Project_Id := No_Project;
1244 Tree : Project_Tree_Ref := null)
1247 if Current_Verbosity = High then
1248 Debug_Output ("Add_Main """ & Name & """ " & Index'Img
1250 & Boolean'Image (Tree /= null));
1254 Add_Str_To_Name_Buffer (Name);
1255 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
1257 Names.Increment_Last;
1258 Names.Table (Names.Last) :=
1259 (Name_Find, Index, Location, No_Source, Project, Tree);
1261 if Tree /= null then
1262 Builder_Data (Tree).Number_Of_Mains :=
1263 Builder_Data (Tree).Number_Of_Mains + 1;
1266 Mains.Count_Of_Mains_With_No_Tree :=
1267 Mains.Count_Of_Mains_With_No_Tree + 1;
1271 --------------------
1272 -- Complete_Mains --
1273 --------------------
1275 procedure Complete_Mains
1276 (Flags : Processing_Flags;
1277 Root_Project : Project_Id;
1278 Project_Tree : Project_Tree_Ref)
1280 procedure Do_Complete (Project : Project_Id; Tree : Project_Tree_Ref);
1281 -- Check the mains for this specific project
1283 procedure Complete_All is new For_Project_And_Aggregated
1286 procedure Add_Multi_Unit_Sources
1287 (Tree : Project_Tree_Ref;
1288 Source : Prj.Source_Id);
1289 -- Add all units from the same file as the multi-unit Source.
1291 function Find_File_Add_Extension
1292 (Tree : Project_Tree_Ref;
1293 Base_Main : String) return Prj.Source_Id;
1294 -- Search for Main in the project, adding body or spec extensions.
1296 ----------------------------
1297 -- Add_Multi_Unit_Sources --
1298 ----------------------------
1300 procedure Add_Multi_Unit_Sources
1301 (Tree : Project_Tree_Ref;
1302 Source : Prj.Source_Id)
1304 Iter : Source_Iterator;
1305 Src : Prj.Source_Id;
1309 ("found multi-unit source file in project", Source.Project.Name);
1311 Iter := For_Each_Source
1312 (In_Tree => Tree, Project => Source.Project);
1314 while Element (Iter) /= No_Source loop
1315 Src := Element (Iter);
1317 if Src.File = Source.File
1318 and then Src.Index /= Source.Index
1320 if Src.File = Source.File then
1322 ("add main in project, index=" & Src.Index'Img);
1325 Names.Increment_Last;
1326 Names.Table (Names.Last) :=
1329 Location => No_Location,
1331 Project => Src.Project,
1334 Builder_Data (Tree).Number_Of_Mains :=
1335 Builder_Data (Tree).Number_Of_Mains + 1;
1340 end Add_Multi_Unit_Sources;
1342 -----------------------------
1343 -- Find_File_Add_Extension --
1344 -----------------------------
1346 function Find_File_Add_Extension
1347 (Tree : Project_Tree_Ref;
1348 Base_Main : String) return Prj.Source_Id
1350 Spec_Source : Prj.Source_Id := No_Source;
1351 Source : Prj.Source_Id;
1352 Iter : Source_Iterator;
1353 Suffix : File_Name_Type;
1356 Source := No_Source;
1357 Iter := For_Each_Source (Tree); -- In all projects
1359 Source := Prj.Element (Iter);
1360 exit when Source = No_Source;
1362 if Source.Kind = Impl then
1363 Get_Name_String (Source.File);
1365 if Name_Len > Base_Main'Length
1366 and then Name_Buffer (1 .. Base_Main'Length) = Base_Main
1369 Source.Language.Config.Naming_Data.Body_Suffix;
1371 if Suffix /= No_File then
1373 Suffix_Str : String := Get_Name_String (Suffix);
1375 Canonical_Case_File_Name (Suffix_Str);
1377 Name_Buffer (Base_Main'Length + 1 .. Name_Len) =
1383 elsif Source.Kind = Spec then
1384 -- A spec needs to be taken into account unless there is
1385 -- also a body. So we delay the decision for them.
1387 Get_Name_String (Source.File);
1389 if Name_Len > Base_Main'Length
1390 and then Name_Buffer (1 .. Base_Main'Length) = Base_Main
1392 Suffix := Source.Language.Config.Naming_Data.Spec_Suffix;
1394 if Suffix /= No_File then
1396 Suffix_Str : String := Get_Name_String (Suffix);
1399 Canonical_Case_File_Name (Suffix_Str);
1401 if Name_Buffer (Base_Main'Length + 1 .. Name_Len) =
1404 Spec_Source := Source;
1414 if Source = No_Source then
1415 Source := Spec_Source;
1419 end Find_File_Add_Extension;
1425 procedure Do_Complete
1426 (Project : Project_Id; Tree : Project_Tree_Ref)
1429 if Mains.Number_Of_Mains (Tree) > 0
1430 or else Mains.Count_Of_Mains_With_No_Tree > 0
1432 -- Traverse in reverse order, since in the case of multi-unit
1433 -- files we will be adding extra files at the end, and there's
1434 -- no need to process them in turn.
1436 for J in reverse Names.First .. Names.Last loop
1438 File : Main_Info := Names.Table (J);
1439 Main_Id : File_Name_Type := File.File;
1440 Main : constant String :=
1441 Get_Name_String (Main_Id);
1442 Base : constant String := Base_Name (Main);
1443 Source : Prj.Source_Id := No_Source;
1444 Is_Absolute : Boolean := False;
1447 if Base /= Main then
1448 Is_Absolute := True;
1450 if Is_Absolute_Path (Main) then
1451 Main_Id := Create_Name (Base);
1454 Absolute : constant String :=
1458 Resolve_Links => False,
1459 Case_Sensitive => False);
1461 File.File := Create_Name (Absolute);
1462 Main_Id := Create_Name (Base);
1467 -- If no project or tree was specified for the main, it
1468 -- came from the command line.
1469 -- Note that the assignments below will not modify inside
1470 -- the table itself.
1472 if File.Project = null then
1473 File.Project := Project;
1476 if File.Tree = null then
1480 if File.Source = null then
1481 if Current_Verbosity = High then
1483 ("search for main """ & Main
1484 & '"' & File.Index'Img & " in "
1485 & Get_Name_String (Debug_Name (File.Tree))
1486 & ", project", Project.Name);
1489 -- First, look for the main as specified. We need to
1490 -- search for the base name though, and if needed
1491 -- check later that we found the correct file.
1493 Source := Find_Source
1494 (In_Tree => File.Tree,
1495 Project => File.Project,
1496 Base_Name => Main_Id,
1497 Index => File.Index,
1498 In_Imported_Only => True);
1500 if Source = No_Source then
1501 Source := Find_File_Add_Extension
1502 (Tree, Get_Name_String (Main_Id));
1506 and then Source /= No_Source
1507 and then File_Name_Type (Source.Path.Name) /=
1511 ("Found a non-matching file",
1512 Name_Id (Source.Path.Display_Name));
1513 Source := No_Source;
1516 if Source /= No_Source then
1518 -- If we have found a multi-unit source file but
1519 -- did not specify an index initially, we'll need
1520 -- to compile all the units from the same source
1523 if Source.Index /= 0 and then File.Index = 0 then
1524 Add_Multi_Unit_Sources (File.Tree, Source);
1527 -- Now update the original Main, otherwise it will
1528 -- be reported as not found.
1531 ("found main in project", Source.Project.Name);
1532 Names.Table (J).File := Source.File;
1533 Names.Table (J).Project := Source.Project;
1535 if Names.Table (J).Tree = null then
1536 Names.Table (J).Tree := File.Tree;
1538 Builder_Data (File.Tree).Number_Of_Mains :=
1539 Builder_Data (File.Tree).Number_Of_Mains + 1;
1540 Mains.Count_Of_Mains_With_No_Tree :=
1541 Mains.Count_Of_Mains_With_No_Tree - 1;
1544 Names.Table (J).Source := Source;
1545 Names.Table (J).Index := Source.Index;
1547 elsif File.Location /= No_Location then
1549 -- If the main is declared in package Builder of
1550 -- the main project, report an error. If the main
1551 -- is on the command line, it may be a main from
1552 -- another project, so do nothing: if the main does
1553 -- not exist in another project, an error will be
1556 Error_Msg_File_1 := Main_Id;
1557 Error_Msg_Name_1 := Root_Project.Name;
1559 (Flags, "{ is not a source of project %%",
1560 File.Location, Project);
1567 if Total_Errors_Detected > 0 then
1568 Fail_Program (Tree, "problems with main sources");
1572 -- Start of processing for Complete_Mains
1575 Complete_All (Root_Project, Project_Tree);
1577 if Mains.Count_Of_Mains_With_No_Tree > 0 then
1578 for J in Names.First .. Names.Last loop
1579 if Names.Table (J).Source = No_Source then
1581 (Project_Tree, '"' & Get_Name_String (Names.Table (J).File)
1582 & """ is not a source of any project");
1598 -----------------------
1599 -- Fill_From_Project --
1600 -----------------------
1602 procedure Fill_From_Project
1603 (Root_Project : Project_Id;
1604 Project_Tree : Project_Tree_Ref)
1606 procedure Add_Mains_From_Project
1607 (Project : Project_Id;
1608 Tree : Project_Tree_Ref);
1609 -- Add the main units from this project into Mains.
1610 -- This takes into account the aggregated projects
1612 ----------------------------
1613 -- Add_Mains_From_Project --
1614 ----------------------------
1616 procedure Add_Mains_From_Project
1617 (Project : Project_Id;
1618 Tree : Project_Tree_Ref)
1620 List : String_List_Id;
1621 Element : String_Element;
1624 if Number_Of_Mains (Tree) = 0
1625 and then Mains.Count_Of_Mains_With_No_Tree = 0
1627 Debug_Output ("Add_Mains_From_Project", Project.Name);
1628 List := Project.Mains;
1630 if List /= Prj.Nil_String then
1632 -- The attribute Main is not an empty list. Get the mains in
1635 while List /= Prj.Nil_String loop
1636 Element := Tree.Shared.String_Elements.Table (List);
1637 Debug_Output ("Add_Main", Element.Value);
1639 if Project.Library then
1642 "cannot specify a main program " &
1643 "for a library project file");
1646 Add_Main (Name => Get_Name_String (Element.Value),
1647 Index => Element.Index,
1648 Location => Element.Location,
1651 List := Element.Next;
1656 if Total_Errors_Detected > 0 then
1657 Fail_Program (Tree, "problems with main sources");
1659 end Add_Mains_From_Project;
1661 procedure Fill_All is new For_Project_And_Aggregated
1662 (Add_Mains_From_Project);
1664 -- Start of processing for Fill_From_Project
1667 Fill_All (Root_Project, Project_Tree);
1668 end Fill_From_Project;
1674 function Next_Main return String is
1675 Info : constant Main_Info := Next_Main;
1677 if Info = No_Main_Info then
1680 return Get_Name_String (Info.File);
1684 function Next_Main return Main_Info is
1686 if Current >= Names.Last then
1687 return No_Main_Info;
1689 Current := Current + 1;
1691 -- If not using projects, and in the gnatmake case, the main file
1692 -- may have not have the extension. Try ".adb" first then ".ads"
1694 if Names.Table (Current).Project = No_Project then
1696 Orig_Main : constant File_Name_Type :=
1697 Names.Table (Current).File;
1698 Current_Main : File_Name_Type;
1701 if Strip_Suffix (Orig_Main) = Orig_Main then
1702 Get_Name_String (Orig_Main);
1703 Add_Str_To_Name_Buffer (".adb");
1704 Current_Main := Name_Find;
1706 if Full_Source_Name (Current_Main) = No_File then
1707 Get_Name_String (Orig_Main);
1708 Add_Str_To_Name_Buffer (".ads");
1709 Current_Main := Name_Find;
1711 if Full_Source_Name (Current_Main) /= No_File then
1712 Names.Table (Current).File := Current_Main;
1716 Names.Table (Current).File := Current_Main;
1722 return Names.Table (Current);
1726 ---------------------
1727 -- Number_Of_Mains --
1728 ---------------------
1730 function Number_Of_Mains (Tree : Project_Tree_Ref) return Natural is
1735 return Builder_Data (Tree).Number_Of_Mains;
1737 end Number_Of_Mains;
1748 --------------------------
1749 -- Set_Multi_Unit_Index --
1750 --------------------------
1752 procedure Set_Multi_Unit_Index
1753 (Project_Tree : Project_Tree_Ref := null;
1758 if Names.Last = 0 then
1761 "cannot specify a multi-unit index but no main " &
1762 "on the command line");
1764 elsif Names.Last > 1 then
1767 "cannot specify several mains with a multi-unit index");
1770 Names.Table (Names.Last).Index := Index;
1773 end Set_Multi_Unit_Index;
1777 -----------------------
1778 -- Path_Or_File_Name --
1779 -----------------------
1781 function Path_Or_File_Name (Path : Path_Name_Type) return String is
1782 Path_Name : constant String := Get_Name_String (Path);
1784 if Debug.Debug_Flag_F then
1785 return File_Name (Path_Name);
1789 end Path_Or_File_Name;
1791 ---------------------------
1792 -- Test_If_Relative_Path --
1793 ---------------------------
1795 procedure Test_If_Relative_Path
1796 (Switch : in out String_Access;
1798 Do_Fail : Fail_Proc;
1799 Including_L_Switch : Boolean := True;
1800 Including_Non_Switch : Boolean := True;
1801 Including_RTS : Boolean := False)
1804 if Switch /= null then
1806 Sw : String (1 .. Switch'Length);
1812 if Sw (1) = '-' then
1814 and then (Sw (2) = 'A'
1815 or else Sw (2) = 'I'
1816 or else (Including_L_Switch and then Sw (2) = 'L'))
1824 elsif Sw'Length >= 4
1825 and then (Sw (2 .. 3) = "aL"
1834 and then Sw'Length >= 7
1835 and then Sw (2 .. 6) = "-RTS="
1843 -- Because relative path arguments to --RTS= may be relative to
1844 -- the search directory prefix, those relative path arguments
1845 -- are converted only when they include directory information.
1847 if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then
1848 if Parent'Length = 0 then
1850 ("relative search path switches ("""
1852 & """) are not allowed");
1854 elsif Including_RTS then
1855 for J in Start .. Sw'Last loop
1856 if Sw (J) = Directory_Separator then
1859 (Sw (1 .. Start - 1) &
1861 Directory_Separator &
1862 Sw (Start .. Sw'Last));
1870 (Sw (1 .. Start - 1) &
1872 Directory_Separator &
1873 Sw (Start .. Sw'Last));
1877 elsif Including_Non_Switch then
1878 if not Is_Absolute_Path (Sw) then
1879 if Parent'Length = 0 then
1881 ("relative paths (""" & Sw & """) are not allowed");
1883 Switch := new String'(Parent & Directory_Separator & Sw);
1889 end Test_If_Relative_Path;
1895 function Unit_Index_Of (ALI_File : File_Name_Type) return Int is
1901 Get_Name_String (ALI_File);
1903 -- First, find the last dot
1907 while Finish >= 1 and then Name_Buffer (Finish) /= '.' loop
1908 Finish := Finish - 1;
1915 -- Now check that the dot is preceded by digits
1918 Finish := Finish - 1;
1919 while Start >= 1 and then Name_Buffer (Start - 1) in '0' .. '9' loop
1923 -- If there are no digits, or if the digits are not preceded by the
1924 -- character that precedes a unit index, this is not the ALI file of
1925 -- a unit in a multi-unit source.
1929 or else Name_Buffer (Start - 1) /= Multi_Unit_Index_Character
1934 -- Build the index from the digit(s)
1936 while Start <= Finish loop
1937 Result := Result * 10 +
1938 Character'Pos (Name_Buffer (Start)) - Character'Pos ('0');
1949 procedure Verbose_Msg
1952 N2 : Name_Id := No_Name;
1954 Prefix : String := " -> ";
1955 Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low)
1958 if not Opt.Verbose_Mode
1959 or else Minimum_Verbosity > Opt.Verbosity_Level
1970 if N2 /= No_Name then
1980 procedure Verbose_Msg
1981 (N1 : File_Name_Type;
1983 N2 : File_Name_Type := No_File;
1985 Prefix : String := " -> ";
1986 Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low)
1990 (Name_Id (N1), S1, Name_Id (N2), S2, Prefix, Minimum_Verbosity);
1997 package body Queue is
1999 type Q_Record is record
2001 Processed : Boolean;
2004 package Q is new Table.Table
2005 (Table_Component_Type => Q_Record,
2006 Table_Index_Type => Natural,
2007 Table_Low_Bound => 1,
2008 Table_Initial => 1000,
2009 Table_Increment => 100,
2010 Table_Name => "Makeutl.Queue.Q");
2011 -- This is the actual Queue
2013 package Busy_Obj_Dirs is new GNAT.HTable.Simple_HTable
2014 (Header_Num => Prj.Header_Num,
2016 No_Element => False,
2017 Key => Path_Name_Type,
2021 type Mark_Key is record
2022 File : File_Name_Type;
2025 -- Identify either a mono-unit source (when Index = 0) or a specific
2026 -- unit (index = 1's origin index of unit) in a multi-unit source.
2028 Max_Mask_Num : constant := 2048;
2029 subtype Mark_Num is Union_Id range 0 .. Max_Mask_Num - 1;
2031 function Hash (Key : Mark_Key) return Mark_Num;
2033 package Marks is new GNAT.HTable.Simple_HTable
2034 (Header_Num => Mark_Num,
2036 No_Element => False,
2040 -- A hash table to keep tracks of the marked units.
2041 -- These are the units that have already been processed, when using the
2042 -- gnatmake format. When using the gprbuild format, we can directly
2043 -- store in the source_id whether the file has already been processed.
2045 procedure Mark (Source_File : File_Name_Type; Index : Int := 0);
2046 -- Mark a unit, identified by its source file and, when Index is not 0,
2047 -- the index of the unit in the source file. Marking is used to signal
2048 -- that the unit has already been inserted in the Q.
2051 (Source_File : File_Name_Type;
2052 Index : Int := 0) return Boolean;
2053 -- Returns True if the unit was previously marked
2055 Q_Processed : Natural := 0;
2056 Q_Initialized : Boolean := False;
2058 Q_First : Natural := 1;
2059 -- Points to the first valid element in the queue
2061 One_Queue_Per_Obj_Dir : Boolean := False;
2062 -- See parameter to Initialize
2064 function Available_Obj_Dir (S : Source_Info) return Boolean;
2065 -- Whether the object directory for S is available for a build
2067 procedure Debug_Display (S : Source_Info);
2068 -- A debug display for S
2070 function Was_Processed (S : Source_Info) return Boolean;
2071 -- Whether S has already been processed. This marks the source as
2072 -- processed, if it hasn't already been processed.
2074 function Insert_No_Roots (Source : Source_Info) return Boolean;
2075 -- Insert Source, but do not look for its roots (see doc for Insert).
2081 function Was_Processed (S : Source_Info) return Boolean is
2084 when Format_Gprbuild =>
2085 if S.Id.In_The_Queue then
2089 S.Id.In_The_Queue := True;
2091 when Format_Gnatmake =>
2092 if Is_Marked (S.File, S.Index) then
2096 Mark (S.File, Index => S.Index);
2102 -----------------------
2103 -- Available_Obj_Dir --
2104 -----------------------
2106 function Available_Obj_Dir (S : Source_Info) return Boolean is
2109 when Format_Gprbuild =>
2110 return not Busy_Obj_Dirs.Get
2111 (S.Id.Project.Object_Directory.Name);
2113 when Format_Gnatmake =>
2114 return S.Project = No_Project
2116 not Busy_Obj_Dirs.Get (S.Project.Object_Directory.Name);
2118 end Available_Obj_Dir;
2124 procedure Debug_Display (S : Source_Info) is
2127 when Format_Gprbuild =>
2128 Write_Name (S.Id.File);
2130 if S.Id.Index /= 0 then
2132 Write_Int (S.Id.Index);
2135 when Format_Gnatmake =>
2136 Write_Name (S.File);
2138 if S.Index /= 0 then
2140 Write_Int (S.Index);
2149 function Hash (Key : Mark_Key) return Mark_Num is
2151 return Union_Id (Key.File) mod Max_Mask_Num;
2159 (Source_File : File_Name_Type;
2160 Index : Int := 0) return Boolean
2163 return Marks.Get (K => (File => Source_File, Index => Index));
2170 procedure Mark (Source_File : File_Name_Type; Index : Int := 0) is
2172 Marks.Set (K => (File => Source_File, Index => Index), E => True);
2180 (Found : out Boolean;
2181 Source : out Source_Info)
2186 if One_Queue_Per_Obj_Dir then
2187 for J in Q_First .. Q.Last loop
2188 if not Q.Table (J).Processed
2189 and then Available_Obj_Dir (Q.Table (J).Info)
2192 Source := Q.Table (J).Info;
2193 Q.Table (J).Processed := True;
2196 while Q_First <= Q.Last
2197 and then Q.Table (Q_First).Processed
2199 Q_First := Q_First + 1;
2207 elsif Q_First <= Q.Last then
2208 Source := Q.Table (Q_First).Info;
2209 Q.Table (Q_First).Processed := True;
2210 Q_First := Q_First + 1;
2215 Q_Processed := Q_Processed + 1;
2218 if Found and then Debug.Debug_Flag_Q then
2219 Write_Str (" Q := Q - [ ");
2220 Debug_Display (Source);
2224 Write_Str (" Q_First =");
2225 Write_Int (Int (Q_First));
2228 Write_Str (" Q.Last =");
2229 Write_Int (Int (Q.Last));
2238 function Processed return Natural is
2247 procedure Initialize
2248 (Queue_Per_Obj_Dir : Boolean;
2249 Force : Boolean := False)
2252 if Force or else not Q_Initialized then
2253 Q_Initialized := True;
2255 for J in 1 .. Q.Last loop
2256 case Q.Table (J).Info.Format is
2257 when Format_Gprbuild =>
2258 Q.Table (J).Info.Id.In_The_Queue := False;
2259 when Format_Gnatmake =>
2267 One_Queue_Per_Obj_Dir := Queue_Per_Obj_Dir;
2271 ---------------------
2272 -- Insert_No_Roots --
2273 ---------------------
2275 function Insert_No_Roots (Source : Source_Info) return Boolean is
2278 (Source.Format = Format_Gnatmake or else Source.Id /= No_Source);
2280 -- Only insert in the Q if it is not already done, to avoid
2281 -- simultaneous compilations if -jnnn is used.
2283 if Was_Processed (Source) then
2287 if Current_Verbosity = High then
2288 Write_Str ("Adding """);
2289 Debug_Display (Source);
2290 Write_Line (""" to the queue");
2293 Q.Append (New_Val => (Info => Source, Processed => False));
2295 if Debug.Debug_Flag_Q then
2296 Write_Str (" Q := Q + [ ");
2297 Debug_Display (Source);
2301 Write_Str (" Q_First =");
2302 Write_Int (Int (Q_First));
2305 Write_Str (" Q.Last =");
2306 Write_Int (Int (Q.Last));
2311 end Insert_No_Roots;
2318 (Source : Source_Info;
2319 With_Roots : Boolean := False) return Boolean
2321 Root_Arr : Array_Element_Id;
2322 Roots : Variable_Value;
2323 List : String_List_Id;
2324 Elem : String_Element;
2325 Unit_Name : Name_Id;
2327 Root_Pattern : Regexp;
2328 Root_Found : Boolean;
2329 Roots_Found : Boolean;
2330 Root_Source : Prj.Source_Id;
2331 Iter : Source_Iterator;
2334 pragma Unreferenced (Dummy);
2337 if not Insert_No_Roots (Source) then
2339 -- Was already in the queue
2344 if With_Roots and then Source.Format = Format_Gprbuild then
2345 Debug_Output ("looking for roots of", Name_Id (Source.Id.File));
2349 (Name => Name_Roots,
2350 In_Arrays => Source.Id.Project.Decl.Arrays,
2351 Shared => Source.Tree.Shared);
2355 (Index => Name_Id (Source.Id.File),
2357 In_Array => Root_Arr,
2358 Shared => Source.Tree.Shared);
2360 -- If there is no roots for the specific main, try the language
2362 if Roots = Nil_Variable_Value then
2365 (Index => Source.Id.Language.Name,
2367 In_Array => Root_Arr,
2368 Shared => Source.Tree.Shared,
2369 Force_Lower_Case_Index => True);
2374 if Roots = Nil_Variable_Value then
2376 Name_Buffer (1) := '*';
2380 (Index => Name_Find,
2382 In_Array => Root_Arr,
2383 Shared => Source.Tree.Shared,
2384 Force_Lower_Case_Index => True);
2387 if Roots = Nil_Variable_Value then
2388 Debug_Output (" -> no roots declared");
2390 List := Roots.Values;
2393 while List /= Nil_String loop
2394 Elem := Source.Tree.Shared.String_Elements.Table (List);
2395 Get_Name_String (Elem.Value);
2396 To_Lower (Name_Buffer (1 .. Name_Len));
2397 Unit_Name := Name_Find;
2399 -- Check if it is a unit name or a pattern
2403 for J in 1 .. Name_Len loop
2404 if Name_Buffer (J) not in 'a' .. 'z' and then
2405 Name_Buffer (J) not in '0' .. '9' and then
2406 Name_Buffer (J) /= '_' and then
2407 Name_Buffer (J) /= '.'
2418 (Pattern => Name_Buffer (1 .. Name_Len),
2422 when Error_In_Regexp =>
2423 Err_Vars.Error_Msg_Name_1 := Unit_Name;
2425 ("invalid pattern %", Roots.Location);
2430 Roots_Found := False;
2431 Iter := For_Each_Source (Source.Tree);
2435 Root_Source := Prj.Element (Iter);
2436 exit Source_Loop when Root_Source = No_Source;
2438 Root_Found := False;
2440 Root_Found := Root_Source.Unit /= No_Unit_Index
2442 (Get_Name_String (Root_Source.Unit.Name),
2447 Root_Source.Unit /= No_Unit_Index
2448 and then Root_Source.Unit.Name = Unit_Name;
2452 case Root_Source.Kind is
2457 Root_Found := Other_Part (Root_Source) = No_Source;
2460 Root_Found := False;
2465 Roots_Found := True;
2467 (" -> ", Name_Id (Root_Source.Display_File));
2468 Dummy := Queue.Insert_No_Roots
2469 (Source => (Format => Format_Gprbuild,
2470 Tree => Source.Tree,
2471 Id => Root_Source));
2473 Initialize_Source_Record (Root_Source);
2475 if Other_Part (Root_Source) /= No_Source then
2476 Initialize_Source_Record (Other_Part (Root_Source));
2479 -- Save the root for the binder.
2481 Source.Id.Roots := new Source_Roots'
2482 (Root => Root_Source,
2483 Next => Source.Id.Roots);
2485 exit Source_Loop when not Pat_Root;
2489 end loop Source_Loop;
2491 if not Roots_Found then
2493 if not Quiet_Output then
2494 Error_Msg_Name_1 := Unit_Name;
2496 ("?no unit matches pattern %", Roots.Location);
2501 ("Unit " & Get_Name_String (Unit_Name)
2502 & " does not exist", Roots.Location);
2507 end loop Pattern_Loop;
2519 (Source : Source_Info;
2520 With_Roots : Boolean := False)
2523 pragma Unreferenced (Discard);
2525 Discard := Insert (Source, With_Roots);
2532 function Is_Empty return Boolean is
2534 return Q_Processed >= Q.Last;
2537 ------------------------
2538 -- Is_Virtually_Empty --
2539 ------------------------
2541 function Is_Virtually_Empty return Boolean is
2543 if One_Queue_Per_Obj_Dir then
2544 for J in Q_First .. Q.Last loop
2545 if not Q.Table (J).Processed
2546 and then Available_Obj_Dir (Q.Table (J).Info)
2557 end Is_Virtually_Empty;
2559 ----------------------
2560 -- Set_Obj_Dir_Busy --
2561 ----------------------
2563 procedure Set_Obj_Dir_Busy (Obj_Dir : Path_Name_Type) is
2565 if One_Queue_Per_Obj_Dir then
2566 Busy_Obj_Dirs.Set (Obj_Dir, True);
2568 end Set_Obj_Dir_Busy;
2570 ----------------------
2571 -- Set_Obj_Dir_Free --
2572 ----------------------
2574 procedure Set_Obj_Dir_Free (Obj_Dir : Path_Name_Type) is
2576 if One_Queue_Per_Obj_Dir then
2577 Busy_Obj_Dirs.Set (Obj_Dir, False);
2579 end Set_Obj_Dir_Free;
2585 function Size return Natural is
2594 function Element (Rank : Positive) return File_Name_Type is
2596 if Rank <= Q.Last then
2597 case Q.Table (Rank).Info.Format is
2598 when Format_Gprbuild =>
2599 return Q.Table (Rank).Info.Id.File;
2600 when Format_Gnatmake =>
2601 return Q.Table (Rank).Info.File;
2612 procedure Remove_Marks is
2617 ----------------------------
2618 -- Insert_Project_Sources --
2619 ----------------------------
2621 procedure Insert_Project_Sources
2622 (Project : Project_Id;
2623 Project_Tree : Project_Tree_Ref;
2624 All_Projects : Boolean;
2625 Unique_Compile : Boolean)
2627 procedure Do_Insert (Project : Project_Id; Tree : Project_Tree_Ref);
2628 procedure Do_Insert (Project : Project_Id; Tree : Project_Tree_Ref) is
2629 Unit_Based : constant Boolean :=
2631 or else not Builder_Data (Tree).Closure_Needed;
2632 -- When Unit_Based is True, put in the queue all compilable
2633 -- sources including the unit based (Ada) one. When Unit_Based is
2634 -- False, put the Ada sources only when they are in a library
2637 Iter : Source_Iterator;
2638 Source : Prj.Source_Id;
2641 -- Nothing to do when "-u" was specified and some files were
2642 -- specified on the command line
2645 and then Mains.Number_Of_Mains (Tree) > 0
2650 Iter := For_Each_Source (Tree);
2652 Source := Prj.Element (Iter);
2653 exit when Source = No_Source;
2655 if Is_Compilable (Source)
2658 or else Is_Extending (Project, Source.Project))
2659 and then not Source.Locally_Removed
2660 and then Source.Replaced_By = No_Source
2662 (not Source.Project.Externally_Built
2664 (Is_Extending (Project, Source.Project)
2665 and then not Project.Externally_Built))
2666 and then Source.Kind /= Sep
2667 and then Source.Path /= No_Path_Information
2669 if Source.Kind = Impl
2670 or else (Source.Unit /= No_Unit_Index
2671 and then Source.Kind = Spec
2672 and then (Other_Part (Source) = No_Source
2674 Other_Part (Source).Locally_Removed))
2677 or else Source.Unit = No_Unit_Index
2678 or else Source.Project.Library)
2679 and then not Is_Subunit (Source)
2682 (Source => (Format => Format_Gprbuild,
2693 procedure Insert_All is new For_Project_And_Aggregated (Do_Insert);
2696 Insert_All (Project, Project_Tree);
2697 end Insert_Project_Sources;
2699 -------------------------------
2700 -- Insert_Withed_Sources_For --
2701 -------------------------------
2703 procedure Insert_Withed_Sources_For
2704 (The_ALI : ALI.ALI_Id;
2705 Project_Tree : Project_Tree_Ref;
2706 Excluding_Shared_SALs : Boolean := False)
2708 Sfile : File_Name_Type;
2709 Afile : File_Name_Type;
2710 Src_Id : Prj.Source_Id;
2713 -- Insert in the queue the unmarked source files (i.e. those which
2714 -- have never been inserted in the queue and hence never considered).
2716 for J in ALI.ALIs.Table (The_ALI).First_Unit ..
2717 ALI.ALIs.Table (The_ALI).Last_Unit
2719 for K in ALI.Units.Table (J).First_With ..
2720 ALI.Units.Table (J).Last_With
2722 Sfile := ALI.Withs.Table (K).Sfile;
2726 if Sfile /= No_File then
2727 Afile := ALI.Withs.Table (K).Afile;
2729 Src_Id := Source_Files_Htable.Get
2730 (Project_Tree.Source_Files_HT, Sfile);
2731 while Src_Id /= No_Source loop
2732 Initialize_Source_Record (Src_Id);
2734 if Is_Compilable (Src_Id)
2735 and then Src_Id.Dep_Name = Afile
2740 Bdy : constant Prj.Source_Id :=
2741 Other_Part (Src_Id);
2744 and then not Bdy.Locally_Removed
2746 Src_Id := Other_Part (Src_Id);
2751 if Is_Subunit (Src_Id) then
2752 Src_Id := No_Source;
2756 Src_Id := No_Source;
2762 Src_Id := Src_Id.Next_With_File_Name;
2765 -- If Excluding_Shared_SALs is True, do not insert in the
2766 -- queue the sources of a shared Stand-Alone Library.
2768 if Src_Id /= No_Source
2769 and then (not Excluding_Shared_SALs
2770 or else not Src_Id.Project.Standalone_Library
2771 or else Src_Id.Project.Library_Kind = Static)
2774 (Source => (Format => Format_Gprbuild,
2775 Tree => Project_Tree,
2781 end Insert_Withed_Sources_For;
2788 procedure Free (Data : in out Builder_Project_Tree_Data) is
2789 procedure Unchecked_Free is new Ada.Unchecked_Deallocation
2790 (Binding_Data_Record, Binding_Data);
2792 TmpB, Binding : Binding_Data := Data.Binding;
2795 while Binding /= null loop
2796 TmpB := Binding.Next;
2797 Unchecked_Free (Binding);
2806 function Builder_Data
2807 (Tree : Project_Tree_Ref) return Builder_Data_Access
2810 if Tree.Appdata = null then
2811 Tree.Appdata := new Builder_Project_Tree_Data;
2814 return Builder_Data_Access (Tree.Appdata);
2817 --------------------------------
2818 -- Compute_Compilation_Phases --
2819 --------------------------------
2821 procedure Compute_Compilation_Phases
2822 (Tree : Project_Tree_Ref;
2823 Root_Project : Project_Id;
2824 Option_Unique_Compile : Boolean := False; -- Was "-u" specified ?
2825 Option_Compile_Only : Boolean := False; -- Was "-c" specified ?
2826 Option_Bind_Only : Boolean := False;
2827 Option_Link_Only : Boolean := False)
2829 procedure Do_Compute (Project : Project_Id; Tree : Project_Tree_Ref);
2831 procedure Do_Compute (Project : Project_Id; Tree : Project_Tree_Ref) is
2832 Data : constant Builder_Data_Access := Builder_Data (Tree);
2833 All_Phases : constant Boolean :=
2834 not Option_Compile_Only
2835 and then not Option_Bind_Only
2836 and then not Option_Link_Only;
2837 -- Whether the command line asked for all three phases. Depending on
2838 -- the project settings, we might still disable some of the phases.
2840 Has_Mains : constant Boolean := Data.Number_Of_Mains > 0;
2841 -- Whether there are some main units defined for this project tree
2842 -- (either from one of the projects, or from the command line)
2845 if Option_Unique_Compile then
2847 -- If -u or -U is specified on the command line, disregard any -c,
2848 -- -b or -l switch: only perform compilation.
2850 Data.Closure_Needed := False;
2851 Data.Need_Compilation := True;
2852 Data.Need_Binding := False;
2853 Data.Need_Linking := False;
2856 Data.Closure_Needed := Has_Mains;
2857 Data.Need_Compilation := All_Phases or Option_Compile_Only;
2858 Data.Need_Binding := All_Phases or Option_Bind_Only;
2859 Data.Need_Linking := (All_Phases or Option_Link_Only)
2863 if Current_Verbosity = High then
2864 Debug_Output ("compilation phases: "
2865 & " compile=" & Data.Need_Compilation'Img
2866 & " bind=" & Data.Need_Binding'Img
2867 & " link=" & Data.Need_Linking'Img
2868 & " closure=" & Data.Closure_Needed'Img
2869 & " mains=" & Data.Number_Of_Mains'Img,
2874 procedure Compute_All is new For_Project_And_Aggregated (Do_Compute);
2877 Compute_All (Root_Project, Tree);
2878 end Compute_Compilation_Phases;
2880 ------------------------------
2881 -- Compute_Builder_Switches --
2882 ------------------------------
2884 procedure Compute_Builder_Switches
2885 (Project_Tree : Project_Tree_Ref;
2886 Root_Environment : in out Prj.Tree.Environment;
2887 Main_Project : Project_Id;
2888 Only_For_Lang : Name_Id := No_Name)
2890 Builder_Package : constant Package_Id :=
2891 Value_Of (Name_Builder, Main_Project.Decl.Packages,
2892 Project_Tree.Shared);
2894 Global_Compilation_Array : Array_Element_Id;
2895 Global_Compilation_Elem : Array_Element;
2896 Global_Compilation_Switches : Variable_Value;
2898 Default_Switches_Array : Array_Id;
2900 Builder_Switches_Lang : Name_Id := No_Name;
2902 List : String_List_Id;
2903 Element : String_Element;
2906 Source : Prj.Source_Id;
2908 Lang : Name_Id := No_Name; -- language index for Switches
2909 Switches_For_Lang : Variable_Value := Nil_Variable_Value;
2910 -- Value of Builder'Default_Switches(lang)
2912 Name : Name_Id := No_Name; -- main file index for Switches
2913 Switches_For_Main : Variable_Value := Nil_Variable_Value;
2914 -- Switches for a specific main. When there are several mains, Name is
2915 -- set to No_Name, and Switches_For_Main might be left with an actual
2916 -- value (so that we can display a warning that it was ignored).
2918 Other_Switches : Variable_Value := Nil_Variable_Value;
2919 -- Value of Builder'Switches(others)
2921 Defaults : Variable_Value := Nil_Variable_Value;
2923 Switches : Variable_Value := Nil_Variable_Value;
2924 -- The computed builder switches
2926 Success : Boolean := False;
2928 if Builder_Package /= No_Package then
2931 -- If there is no main, and there is only one compilable language,
2932 -- use this language as the switches index.
2934 if Mains.Number_Of_Mains (Project_Tree) = 0 then
2936 if Only_For_Lang = No_Name then
2938 Language : Language_Ptr := Main_Project.Languages;
2941 while Language /= No_Language_Index loop
2942 if Language.Config.Compiler_Driver /= No_File
2943 and then Language.Config.Compiler_Driver /= Empty_File
2945 if Lang /= No_Name then
2949 Lang := Language.Name;
2952 Language := Language.Next;
2956 Lang := Only_For_Lang;
2960 for Index in 1 .. Mains.Number_Of_Mains (Project_Tree) loop
2961 Source := Mains.Next_Main.Source;
2962 if Source /= No_Source then
2964 if Switches_For_Main = Nil_Variable_Value then
2965 Switches_For_Main := Value_Of
2966 (Name => Name_Id (Source.File),
2967 Attribute_Or_Array_Name => Name_Switches,
2968 In_Package => Builder_Package,
2969 Shared => Project_Tree.Shared,
2970 Force_Lower_Case_Index => False,
2971 Allow_Wildcards => True);
2973 -- If not found, try without extension.
2974 -- That's because gnatmake accepts truncated file names
2975 -- in Builder'Switches
2977 if Switches_For_Main = Nil_Variable_Value
2978 and then Source.Unit /= null
2980 Switches_For_Main := Value_Of
2981 (Name => Source.Unit.Name,
2982 Attribute_Or_Array_Name => Name_Switches,
2983 In_Package => Builder_Package,
2984 Shared => Project_Tree.Shared,
2985 Force_Lower_Case_Index => False,
2986 Allow_Wildcards => True);
2991 Lang := Source.Language.Name;
2992 Name := Name_Id (Source.File);
2994 Name := No_Name; -- Can't use main specific switches
2996 if Lang /= Source.Language.Name then
3004 Global_Compilation_Array := Value_Of
3005 (Name => Name_Global_Compilation_Switches,
3006 In_Arrays => Project_Tree.Shared.Packages.Table
3007 (Builder_Package).Decl.Arrays,
3008 Shared => Project_Tree.Shared);
3010 Default_Switches_Array :=
3011 Project_Tree.Shared.Packages.Table (Builder_Package).Decl.Arrays;
3013 while Default_Switches_Array /= No_Array and then
3014 Project_Tree.Shared.Arrays.Table (Default_Switches_Array).Name /=
3015 Name_Default_Switches
3017 Default_Switches_Array :=
3018 Project_Tree.Shared.Arrays.Table (Default_Switches_Array).Next;
3021 if Global_Compilation_Array /= No_Array_Element
3022 and then Default_Switches_Array /= No_Array
3025 (Root_Environment.Flags,
3026 "Default_Switches forbidden in presence of " &
3027 "Global_Compilation_Switches. Use Switches instead.",
3028 Project_Tree.Shared.Arrays.Table
3029 (Default_Switches_Array).Location);
3032 "*** illegal combination of Builder attributes");
3035 if Lang /= No_Name then
3036 Switches_For_Lang := Prj.Util.Value_Of
3039 Attribute_Or_Array_Name => Name_Switches,
3040 In_Package => Builder_Package,
3041 Shared => Project_Tree.Shared,
3042 Force_Lower_Case_Index => True);
3044 Defaults := Prj.Util.Value_Of
3047 Attribute_Or_Array_Name => Name_Default_Switches,
3048 In_Package => Builder_Package,
3049 Shared => Project_Tree.Shared,
3050 Force_Lower_Case_Index => True);
3053 Other_Switches := Prj.Util.Value_Of
3054 (Name => All_Other_Names,
3056 Attribute_Or_Array_Name => Name_Switches,
3057 In_Package => Builder_Package,
3058 Shared => Project_Tree.Shared);
3061 and then Mains.Number_Of_Mains (Project_Tree) > 1
3062 and then Switches_For_Main /= Nil_Variable_Value
3064 -- More than one main, but we had main-specific switches that
3067 if Switches_For_Lang /= Nil_Variable_Value then
3069 ("Warning: using Builder'Switches("""
3070 & Get_Name_String (Lang)
3071 & """), as there are several mains");
3073 elsif Other_Switches /= Nil_Variable_Value then
3075 ("Warning: using Builder'Switches(others), "
3076 & "as there are several mains");
3078 elsif Defaults /= Nil_Variable_Value then
3080 ("Warning: using Builder'Default_Switches("""
3081 & Get_Name_String (Lang)
3082 & """), as there are several mains");
3085 ("Warning: using no switches from package "
3086 & "Builder, as there are several mains");
3090 Builder_Switches_Lang := Lang;
3092 if Name /= No_Name then
3093 -- Get the switches for the single main
3094 Switches := Switches_For_Main;
3097 if Switches = Nil_Variable_Value or else Switches.Default then
3098 -- Get the switches for the common language of the mains
3099 Switches := Switches_For_Lang;
3102 if Switches = Nil_Variable_Value or else Switches.Default then
3103 Switches := Other_Switches;
3106 -- For backward compatibility with gnatmake, if no Switches
3107 -- are declared, check for Default_Switches (<language>).
3109 if Switches = Nil_Variable_Value or else Switches.Default then
3110 Switches := Defaults;
3113 -- If switches have been found, scan them
3115 if Switches /= Nil_Variable_Value and then not Switches.Default then
3116 List := Switches.Values;
3118 while List /= Nil_String loop
3119 Element := Project_Tree.Shared.String_Elements.Table (List);
3120 Get_Name_String (Element.Value);
3122 if Name_Len /= 0 then
3124 -- Add_Switch might itself be using the name_buffer, so
3125 -- we make a temporary here.
3126 Switch : constant String :=
3127 Name_Buffer (1 .. Name_Len);
3129 Success := Add_Switch
3131 For_Lang => Builder_Switches_Lang,
3132 For_Builder => True,
3133 Has_Global_Compilation_Switches =>
3134 Global_Compilation_Array /= No_Array_Element);
3138 for J in reverse 1 .. Name_Len loop
3139 Name_Buffer (J + J) := Name_Buffer (J);
3140 Name_Buffer (J + J - 1) := ''';
3143 Name_Len := Name_Len + Name_Len;
3146 (Root_Environment.Flags,
3147 '"' & Name_Buffer (1 .. Name_Len) &
3148 """ is not a builder switch. Consider moving " &
3149 "it to Global_Compilation_Switches.",
3153 "*** illegal switch """ &
3154 Get_Name_String (Element.Value) & '"');
3158 List := Element.Next;
3162 -- Reset the Builder Switches language
3164 Builder_Switches_Lang := No_Name;
3166 -- Take into account attributes Global_Compilation_Switches
3168 while Global_Compilation_Array /= No_Array_Element loop
3169 Global_Compilation_Elem :=
3170 Project_Tree.Shared.Array_Elements.Table
3171 (Global_Compilation_Array);
3173 Get_Name_String (Global_Compilation_Elem.Index);
3174 To_Lower (Name_Buffer (1 .. Name_Len));
3177 if Only_For_Lang = No_Name or else Index = Only_For_Lang then
3178 Global_Compilation_Switches := Global_Compilation_Elem.Value;
3180 if Global_Compilation_Switches /= Nil_Variable_Value
3181 and then not Global_Compilation_Switches.Default
3183 -- We have found an attribute
3184 -- Global_Compilation_Switches for a language: put the
3185 -- switches in the appropriate table.
3187 List := Global_Compilation_Switches.Values;
3188 while List /= Nil_String loop
3190 Project_Tree.Shared.String_Elements.Table (List);
3192 if Element.Value /= No_Name then
3193 Success := Add_Switch
3194 (Switch => Get_Name_String (Element.Value),
3196 For_Builder => False,
3197 Has_Global_Compilation_Switches =>
3198 Global_Compilation_Array /= No_Array_Element);
3201 List := Element.Next;
3206 Global_Compilation_Array := Global_Compilation_Elem.Next;
3209 end Compute_Builder_Switches;