1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1996-2005, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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 GNAT.Directory_Operations; use GNAT.Directory_Operations;
30 with MLib.Tgt; use MLib.Tgt;
32 with Namet; use Namet;
34 with Osint; use Osint;
38 with Prj.Ext; use Prj.Ext;
40 with Prj.Util; use Prj.Util;
42 with Snames; use Snames;
44 with Types; use Types;
45 with Hostparm; use Hostparm;
46 -- Used to determine if we are in VMS or not for error message purposes
48 with Ada.Characters.Handling; use Ada.Characters.Handling;
49 with Ada.Command_Line; use Ada.Command_Line;
50 with Ada.Text_IO; use Ada.Text_IO;
52 with GNAT.OS_Lib; use GNAT.OS_Lib;
56 with VMS_Conv; use VMS_Conv;
59 Project_Tree : constant Project_Tree_Ref := new Project_Tree_Data;
60 Project_File : String_Access;
61 Project : Prj.Project_Id;
62 Current_Verbosity : Prj.Verbosity := Prj.Default;
63 Tool_Package_Name : Name_Id := No_Name;
65 Old_Project_File_Used : Boolean := False;
66 -- This flag indicates a switch -p (for gnatxref and gnatfind) for
67 -- an old fashioned project file. -p cannot be used in conjonction
70 Max_Files_On_The_Command_Line : constant := 30; -- Arbitrary
72 Temp_File_Name : String_Access := null;
73 -- The name of the temporary text file to put a list of source/object
74 -- files to pass to a tool, when there are more than
75 -- Max_Files_On_The_Command_Line files.
77 package First_Switches is new Table.Table
78 (Table_Component_Type => String_Access,
79 Table_Index_Type => Integer,
82 Table_Increment => 100,
83 Table_Name => "Gnatcmd.First_Switches");
84 -- A table to keep the switches from the project file
86 package Carg_Switches is new Table.Table
87 (Table_Component_Type => String_Access,
88 Table_Index_Type => Integer,
91 Table_Increment => 100,
92 Table_Name => "Gnatcmd.Carg_Switches");
93 -- A table to keep the switches following -cargs for ASIS tools
95 package Library_Paths is new Table.Table (
96 Table_Component_Type => String_Access,
97 Table_Index_Type => Integer,
100 Table_Increment => 100,
101 Table_Name => "Make.Library_Path");
103 -- Packages of project files to pass to Prj.Pars.Parse, depending on the
104 -- tool. We allocate objects because we cannot declare aliased objects
105 -- as we are in a procedure, not a library level package.
107 Naming_String : constant String_Access := new String'("naming");
108 Binder_String : constant String_Access := new String'("binder");
109 Compiler_String : constant String_Access := new String'("compiler");
110 Check_String : constant String_Access := new String'("check");
111 Eliminate_String : constant String_Access := new String'("eliminate");
112 Finder_String : constant String_Access := new String'("finder");
113 Linker_String : constant String_Access := new String'("linker");
114 Gnatls_String : constant String_Access := new String'("gnatls");
115 Pretty_String : constant String_Access := new String'("pretty_printer");
116 Gnatstub_String : constant String_Access := new String'("gnatstub");
117 Metric_String : constant String_Access := new String'("metrics");
118 Xref_String : constant String_Access := new String'("cross_reference");
120 Packages_To_Check_By_Binder : constant String_List_Access :=
121 new String_List'((Naming_String, Binder_String));
123 Packages_To_Check_By_Check : constant String_List_Access :=
124 new String_List'((Naming_String, Check_String, Compiler_String));
126 Packages_To_Check_By_Eliminate : constant String_List_Access :=
127 new String_List'((Naming_String, Eliminate_String, Compiler_String));
129 Packages_To_Check_By_Finder : constant String_List_Access :=
130 new String_List'((Naming_String, Finder_String));
132 Packages_To_Check_By_Linker : constant String_List_Access :=
133 new String_List'((Naming_String, Linker_String));
135 Packages_To_Check_By_Gnatls : constant String_List_Access :=
136 new String_List'((Naming_String, Gnatls_String));
138 Packages_To_Check_By_Pretty : constant String_List_Access :=
139 new String_List'((Naming_String, Pretty_String, Compiler_String));
141 Packages_To_Check_By_Gnatstub : constant String_List_Access :=
142 new String_List'((Naming_String, Gnatstub_String, Compiler_String));
144 Packages_To_Check_By_Metric : constant String_List_Access :=
145 new String_List'((Naming_String, Metric_String, Compiler_String));
147 Packages_To_Check_By_Xref : constant String_List_Access :=
148 new String_List'((Naming_String, Xref_String));
150 Packages_To_Check : String_List_Access := Prj.All_Packages;
152 ----------------------------------
153 -- Declarations for GNATCMD use --
154 ----------------------------------
156 The_Command : Command_Type;
157 -- The command specified in the invocation of the GNAT driver
159 Command_Arg : Positive := 1;
160 -- The index of the command in the arguments of the GNAT driver
162 My_Exit_Status : Exit_Status := Success;
163 -- The exit status of the spawned tool. Used to set the correct VMS
166 Current_Work_Dir : constant String := Get_Current_Dir;
167 -- The path of the working directory
169 All_Projects : Boolean := False;
170 -- Flag used for GNAT PRETTY and GNAT METRIC to indicate that
171 -- the underlying tool (gnatcheck, gnatpp or gnatmetric) should be invoked
172 -- for all sources of all projects.
174 -----------------------
175 -- Local Subprograms --
176 -----------------------
178 procedure Add_To_Carg_Switches (Switch : String_Access);
179 -- Add a switch to the Carg_Switches table. If it is the first one,
180 -- put the switch "-cargs" at the beginning of the table.
182 procedure Check_Files;
183 -- For GNAT LIST, GNAT PRETTY and GNAT METRIC, check if a project
184 -- file is specified, without any file arguments. If it is the case,
185 -- invoke the GNAT tool with the proper list of files, derived from
186 -- the sources of the project.
188 function Check_Project
189 (Project : Project_Id;
190 Root_Project : Project_Id) return Boolean;
191 -- Returns True if Project = Root_Project.
192 -- For GNAT METRIC, also returns True if Project is extended by
195 procedure Check_Relative_Executable (Name : in out String_Access);
196 -- Check if an executable is specified as a relative path.
197 -- If it is, and the path contains directory information, fail.
198 -- Otherwise, prepend the exec directory.
199 -- This procedure is only used for GNAT LINK when a project file
202 function Configuration_Pragmas_File return Name_Id;
203 -- Return an argument, if there is a configuration pragmas file to be
204 -- specified for Project, otherwise return No_Name.
205 -- Used for gnatstub (GNAT STUB), gnatpp (GNAT PRETTY), gnatelim
206 -- (GNAT ELIM), and gnatmetric (GNAT METRIC).
208 procedure Delete_Temp_Config_Files;
209 -- Delete all temporary config files
211 function Index (Char : Character; Str : String) return Natural;
212 -- Returns the first occurrence of Char in Str.
213 -- Returns 0 if Char is not in Str.
215 procedure Non_VMS_Usage;
216 -- Display usage for platforms other than VMS
218 procedure Process_Link;
219 -- Process GNAT LINK, when there is a project file specified
221 procedure Set_Library_For
222 (Project : Project_Id;
223 There_Are_Libraries : in out Boolean);
224 -- If Project is a library project, add the correct
225 -- -L and -l switches to the linker invocation.
227 procedure Set_Libraries is
228 new For_Every_Project_Imported (Boolean, Set_Library_For);
229 -- Add the -L and -l switches to the linker for all
230 -- of the library projects.
232 procedure Test_If_Relative_Path
233 (Switch : in out String_Access;
235 -- Test if Switch is a relative search path switch.
236 -- If it is and it includes directory information, prepend the path with
237 -- Parent.This subprogram is only called when using project files.
239 --------------------------
240 -- Add_To_Carg_Switches --
241 --------------------------
243 procedure Add_To_Carg_Switches (Switch : String_Access) is
245 -- If the Carg_Switches table is empty, put "-cargs" at the beginning
247 if Carg_Switches.Last = 0 then
248 Carg_Switches.Increment_Last;
249 Carg_Switches.Table (Carg_Switches.Last) := new String'("-cargs");
252 Carg_Switches.Increment_Last;
253 Carg_Switches.Table (Carg_Switches.Last) := Switch;
254 end Add_To_Carg_Switches;
260 procedure Check_Files is
261 Add_Sources : Boolean := True;
262 Unit_Data : Prj.Unit_Data;
263 Subunit : Boolean := False;
266 -- Check if there is at least one argument that is not a switch
268 for Index in 1 .. Last_Switches.Last loop
269 if Last_Switches.Table (Index) (1) /= '-' then
270 Add_Sources := False;
275 -- If all arguments were switches, add the path names of
276 -- all the sources of the main project.
280 Current_Last : constant Integer := Last_Switches.Last;
282 for Unit in Unit_Table.First ..
283 Unit_Table.Last (Project_Tree.Units)
285 Unit_Data := Project_Tree.Units.Table (Unit);
287 -- For gnatls, we only need to put the library units,
288 -- body or spec, but not the subunits.
290 if The_Command = List then
292 Unit_Data.File_Names (Body_Part).Name /= No_Name
294 -- There is a body; check if it is for this
297 if Unit_Data.File_Names (Body_Part).Project =
302 if Unit_Data.File_Names (Specification).Name =
305 -- We have a body with no spec: we need
306 -- to check if this is a subunit, because
307 -- gnatls will complain about subunits.
310 Src_Ind : Source_File_Index;
313 Src_Ind := Sinput.P.Load_Project_File
315 (Unit_Data.File_Names
319 Sinput.P.Source_File_Is_Subunit
325 Last_Switches.Increment_Last;
326 Last_Switches.Table (Last_Switches.Last) :=
329 (Unit_Data.File_Names
330 (Body_Part).Display_Name));
334 elsif Unit_Data.File_Names (Specification).Name /=
337 -- We have a spec with no body; check if it is
340 if Unit_Data.File_Names (Specification).Project =
343 Last_Switches.Increment_Last;
344 Last_Switches.Table (Last_Switches.Last) :=
347 (Unit_Data.File_Names
348 (Specification).Display_Name));
353 -- For gnatcheck, gnatpp and gnatmetric, put all sources
354 -- of the project, or of all projects if -U was specified.
356 for Kind in Spec_Or_Body loop
358 -- Put only sources that belong to the main
362 (Unit_Data.File_Names (Kind).Project, Project)
364 Last_Switches.Increment_Last;
365 Last_Switches.Table (Last_Switches.Last) :=
368 (Unit_Data.File_Names
369 (Kind).Display_Path));
375 -- If the list of files is too long, create a temporary
376 -- text file that lists these files, and pass this temp
377 -- file to gnatcheck, gnatpp or gnatmetric using switch -files=.
379 if Last_Switches.Last - Current_Last >
380 Max_Files_On_The_Command_Line
383 Temp_File_FD : File_Descriptor;
384 Buffer : String (1 .. 1_000);
386 OK : Boolean := True;
389 Create_Temp_File (Temp_File_FD, Temp_File_Name);
391 if Temp_File_Name /= null then
392 for Index in Current_Last + 1 ..
395 Len := Last_Switches.Table (Index)'Length;
397 Last_Switches.Table (Index).all;
399 Buffer (Len) := ASCII.LF;
400 Buffer (Len + 1) := ASCII.NUL;
409 Close (Temp_File_FD, OK);
411 Close (Temp_File_FD, OK);
415 -- If there were any problem creating the temp
416 -- file, then pass the list of files.
420 -- Replace the list of files with
421 -- "-files=<temp file name>".
423 Last_Switches.Set_Last (Current_Last + 1);
424 Last_Switches.Table (Last_Switches.Last) :=
425 new String'("-files=" & Temp_File_Name.all);
438 function Check_Project
439 (Project : Project_Id;
440 Root_Project : Project_Id) return Boolean
443 if Project = No_Project then
446 elsif All_Projects or Project = Root_Project then
449 elsif The_Command = Metric then
451 Data : Project_Data :=
452 Project_Tree.Projects.Table (Root_Project);
455 while Data.Extends /= No_Project loop
456 if Project = Data.Extends then
460 Data := Project_Tree.Projects.Table (Data.Extends);
468 -------------------------------
469 -- Check_Relative_Executable --
470 -------------------------------
472 procedure Check_Relative_Executable (Name : in out String_Access) is
473 Exec_File_Name : constant String := Name.all;
476 if not Is_Absolute_Path (Exec_File_Name) then
477 for Index in Exec_File_Name'Range loop
478 if Exec_File_Name (Index) = Directory_Separator then
479 Fail ("relative executable (""" &
481 """) with directory part not allowed " &
482 "when using project files");
486 Get_Name_String (Project_Tree.Projects.Table
487 (Project).Exec_Directory);
489 if Name_Buffer (Name_Len) /= Directory_Separator then
490 Name_Len := Name_Len + 1;
491 Name_Buffer (Name_Len) := Directory_Separator;
494 Name_Buffer (Name_Len + 1 ..
495 Name_Len + Exec_File_Name'Length) :=
497 Name_Len := Name_Len + Exec_File_Name'Length;
498 Name := new String'(Name_Buffer (1 .. Name_Len));
500 end Check_Relative_Executable;
502 --------------------------------
503 -- Configuration_Pragmas_File --
504 --------------------------------
506 function Configuration_Pragmas_File return Name_Id is
508 Prj.Env.Create_Config_Pragmas_File
509 (Project, Project, Project_Tree, Include_Config_Files => False);
510 return Project_Tree.Projects.Table (Project).Config_File_Name;
511 end Configuration_Pragmas_File;
513 ------------------------------
514 -- Delete_Temp_Config_Files --
515 ------------------------------
517 procedure Delete_Temp_Config_Files is
521 if not Keep_Temporary_Files then
522 if Project /= No_Project then
523 for Prj in Project_Table.First ..
524 Project_Table.Last (Project_Tree.Projects)
527 Project_Tree.Projects.Table (Prj).Config_File_Temp
530 Output.Write_Str ("Deleting temp configuration file """);
533 (Project_Tree.Projects.Table
534 (Prj).Config_File_Name));
535 Output.Write_Line ("""");
539 (Name => Get_Name_String
540 (Project_Tree.Projects.Table
541 (Prj).Config_File_Name),
547 -- If a temporary text file that contains a list of files for a tool
548 -- has been created, delete this temporary file.
550 if Temp_File_Name /= null then
551 Delete_File (Temp_File_Name.all, Success);
554 end Delete_Temp_Config_Files;
560 function Index (Char : Character; Str : String) return Natural is
562 for Index in Str'Range loop
563 if Str (Index) = Char then
575 procedure Process_Link is
576 Look_For_Executable : Boolean := True;
577 There_Are_Libraries : Boolean := False;
578 Path_Option : constant String_Access :=
579 MLib.Linker_Library_Path_Option;
580 Prj : Project_Id := Project;
583 Skip_Executable : Boolean := False;
586 -- Add the default search directories, to be able to find
587 -- libgnat in call to MLib.Utl.Lib_Directory.
589 Add_Default_Search_Dirs;
591 Library_Paths.Set_Last (0);
593 -- Check if there are library project files
595 if MLib.Tgt.Support_For_Libraries /= MLib.Tgt.None then
596 Set_Libraries (Project, Project_Tree, There_Are_Libraries);
599 -- If there are, add the necessary additional switches
601 if There_Are_Libraries then
603 -- Add -L<lib_dir> -lgnarl -lgnat -Wl,-rpath,<lib_dir>
605 Last_Switches.Increment_Last;
606 Last_Switches.Table (Last_Switches.Last) :=
607 new String'("-L" & MLib.Utl.Lib_Directory);
608 Last_Switches.Increment_Last;
609 Last_Switches.Table (Last_Switches.Last) :=
610 new String'("-lgnarl");
611 Last_Switches.Increment_Last;
612 Last_Switches.Table (Last_Switches.Last) :=
613 new String'("-lgnat");
615 -- If Path_Option is not null, create the switch
616 -- ("-Wl,-rpath," or equivalent) with all the library dirs
617 -- plus the standard GNAT library dir.
619 if Path_Option /= null then
621 Option : String_Access;
622 Length : Natural := Path_Option'Length;
626 -- First, compute the exact length for the switch
629 Library_Paths.First .. Library_Paths.Last
631 -- Add the length of the library dir plus one
632 -- for the directory separator.
636 Library_Paths.Table (Index)'Length + 1;
639 -- Finally, add the length of the standard GNAT
642 Length := Length + MLib.Utl.Lib_Directory'Length;
643 Option := new String (1 .. Length);
644 Option (1 .. Path_Option'Length) := Path_Option.all;
645 Current := Path_Option'Length;
647 -- Put each library dir followed by a dir separator
650 Library_Paths.First .. Library_Paths.Last
655 Library_Paths.Table (Index)'Length) :=
656 Library_Paths.Table (Index).all;
659 Library_Paths.Table (Index)'Length + 1;
660 Option (Current) := Path_Separator;
663 -- Finally put the standard GNAT library dir
667 Current + MLib.Utl.Lib_Directory'Length) :=
668 MLib.Utl.Lib_Directory;
670 -- And add the switch to the last switches
672 Last_Switches.Increment_Last;
673 Last_Switches.Table (Last_Switches.Last) :=
679 -- Check if the first ALI file specified can be found, either
680 -- in the object directory of the main project or in an object
681 -- directory of a project file extended by the main project.
682 -- If the ALI file can be found, replace its name with its
685 Skip_Executable := False;
687 Switch_Loop : for J in 1 .. Last_Switches.Last loop
689 -- If we have an executable just reset the flag
691 if Skip_Executable then
692 Skip_Executable := False;
694 -- If -o, set flag so that next switch is not processed
696 elsif Last_Switches.Table (J).all = "-o" then
697 Skip_Executable := True;
703 Switch : constant String :=
704 Last_Switches.Table (J).all;
706 ALI_File : constant String (1 .. Switch'Length + 4) :=
709 Test_Existence : Boolean := False;
712 Last := Switch'Length;
714 -- Skip real switches
716 if Switch'Length /= 0
717 and then Switch (Switch'First) /= '-'
719 -- Append ".ali" if file name does not end with it
721 if Switch'Length <= 4
722 or else Switch (Switch'Last - 3 .. Switch'Last)
725 Last := ALI_File'Last;
728 -- If file name includes directory information,
729 -- stop if ALI file exists.
731 if Is_Absolute_Path (ALI_File (1 .. Last)) then
732 Test_Existence := True;
735 for K in Switch'Range loop
736 if Switch (K) = '/' or else
737 Switch (K) = Directory_Separator
739 Test_Existence := True;
745 if Test_Existence then
746 if Is_Regular_File (ALI_File (1 .. Last)) then
750 -- Look in object directories if ALI file exists
755 Dir : constant String :=
757 (Project_Tree.Projects.Table
758 (Prj).Object_Directory);
762 Directory_Separator &
763 ALI_File (1 .. Last))
765 -- We have found the correct project, so we
766 -- replace the file with the absolute path.
768 Last_Switches.Table (J) :=
770 (Dir & Directory_Separator &
771 ALI_File (1 .. Last));
779 -- Go to the project being extended,
783 Project_Tree.Projects.Table (Prj).Extends;
784 exit Project_Loop when Prj = No_Project;
785 end loop Project_Loop;
790 end loop Switch_Loop;
792 -- If a relative path output file has been specified, we add
793 -- the exec directory.
795 for J in reverse 1 .. Last_Switches.Last - 1 loop
796 if Last_Switches.Table (J).all = "-o" then
797 Check_Relative_Executable
798 (Name => Last_Switches.Table (J + 1));
799 Look_For_Executable := False;
804 if Look_For_Executable then
805 for J in reverse 1 .. First_Switches.Last - 1 loop
806 if First_Switches.Table (J).all = "-o" then
807 Look_For_Executable := False;
808 Check_Relative_Executable
809 (Name => First_Switches.Table (J + 1));
815 -- If no executable is specified, then find the name
816 -- of the first ALI file on the command line and issue
817 -- a -o switch with the absolute path of the executable
818 -- in the exec directory.
820 if Look_For_Executable then
821 for J in 1 .. Last_Switches.Last loop
822 Arg := Last_Switches.Table (J);
825 if Arg'Length /= 0 and then Arg (Arg'First) /= '-' then
827 and then Arg (Arg'Last - 3 .. Arg'Last) = ".ali"
829 Last := Arg'Last - 4;
831 elsif Is_Regular_File (Arg.all & ".ali") then
836 Last_Switches.Increment_Last;
837 Last_Switches.Table (Last_Switches.Last) :=
840 (Project_Tree.Projects.Table
841 (Project).Exec_Directory);
842 Last_Switches.Increment_Last;
843 Last_Switches.Table (Last_Switches.Last) :=
844 new String'(Name_Buffer (1 .. Name_Len) &
845 Directory_Separator &
846 Base_Name (Arg (Arg'First .. Last)) &
847 Get_Executable_Suffix.all);
855 ---------------------
856 -- Set_Library_For --
857 ---------------------
859 procedure Set_Library_For
860 (Project : Project_Id;
861 There_Are_Libraries : in out Boolean)
863 Path_Option : constant String_Access :=
864 MLib.Linker_Library_Path_Option;
867 -- Case of library project
869 if Project_Tree.Projects.Table (Project).Library then
870 There_Are_Libraries := True;
874 Last_Switches.Increment_Last;
875 Last_Switches.Table (Last_Switches.Last) :=
878 (Project_Tree.Projects.Table
879 (Project).Library_Dir));
883 Last_Switches.Increment_Last;
884 Last_Switches.Table (Last_Switches.Last) :=
887 (Project_Tree.Projects.Table
888 (Project).Library_Name));
890 -- Add the directory to table Library_Paths, to be processed later
891 -- if library is not static and if Path_Option is not null.
893 if Project_Tree.Projects.Table (Project).Library_Kind /=
895 and then Path_Option /= null
897 Library_Paths.Increment_Last;
898 Library_Paths.Table (Library_Paths.Last) :=
899 new String'(Get_Name_String
900 (Project_Tree.Projects.Table
901 (Project).Library_Dir));
906 ---------------------------
907 -- Test_If_Relative_Path --
908 ---------------------------
910 procedure Test_If_Relative_Path
911 (Switch : in out String_Access;
915 if Switch /= null then
918 Sw : String (1 .. Switch'Length);
919 Start : Positive := 1;
926 and then (Sw (2) = 'A' or else
937 and then (Sw (2 .. 3) = "aL" or else
938 Sw (2 .. 3) = "aO" or else
944 and then Sw (2 .. 6) = "-RTS="
952 -- If the path is relative, test if it includes directory
953 -- information. If it does, prepend Parent to the path.
955 if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then
956 for J in Start .. Sw'Last loop
957 if Sw (J) = Directory_Separator then
960 (Sw (1 .. Start - 1) &
962 Directory_Separator &
963 Sw (Start .. Sw'Last));
970 end Test_If_Relative_Path;
976 procedure Non_VMS_Usage is
980 Put_Line ("List of available commands");
983 for C in Command_List'Range loop
984 if not Command_List (C).VMS_Only then
985 Put ("gnat " & To_Lower (Command_List (C).Cname.all));
987 Put (Command_List (C).Unixcmd.all);
990 Sws : Argument_List_Access renames Command_List (C).Unixsws;
993 for J in Sws'Range loop
1005 Put_Line ("Commands find, list, metric, pretty, stub and xref accept " &
1006 "project file switches -vPx, -Pprj and -Xnam=val");
1010 -------------------------------------
1011 -- Start of processing for GNATCmd --
1012 -------------------------------------
1022 Prj.Initialize (Project_Tree);
1025 Last_Switches.Set_Last (0);
1027 First_Switches.Init;
1028 First_Switches.Set_Last (0);
1030 Carg_Switches.Set_Last (0);
1032 VMS_Conv.Initialize;
1034 -- Add the directory where the GNAT driver is invoked in front of the
1035 -- path, if the GNAT driver is invoked with directory information.
1036 -- Only do this if the platform is not VMS, where the notion of path
1037 -- does not really exist.
1041 Command : constant String := Command_Name;
1044 for Index in reverse Command'Range loop
1045 if Command (Index) = Directory_Separator then
1047 Absolute_Dir : constant String :=
1049 (Command (Command'First .. Index));
1051 PATH : constant String :=
1054 Getenv ("PATH").all;
1057 Setenv ("PATH", PATH);
1066 -- If on VMS, or if VMS emulation is on, convert VMS style /qualifiers,
1067 -- filenames and pathnames to Unix style.
1070 or else To_Lower (Getenv ("EMULATE_VMS").all) = "true"
1072 VMS_Conversion (The_Command);
1074 -- If not on VMS, scan the command line directly
1077 if Argument_Count = 0 then
1083 if Argument_Count > Command_Arg
1084 and then Argument (Command_Arg) = "-v"
1086 Verbose_Mode := True;
1087 Command_Arg := Command_Arg + 1;
1089 elsif Argument_Count > Command_Arg
1090 and then Argument (Command_Arg) = "-dn"
1092 Keep_Temporary_Files := True;
1093 Command_Arg := Command_Arg + 1;
1100 The_Command := Real_Command_Type'Value (Argument (Command_Arg));
1102 if Command_List (The_Command).VMS_Only then
1106 Command_List (The_Command).Cname.all,
1107 """ can only be used on VMS");
1111 when Constraint_Error =>
1113 -- Check if it is an alternate command
1116 Alternate : Alternate_Command;
1119 Alternate := Alternate_Command'Value
1120 (Argument (Command_Arg));
1121 The_Command := Corresponding_To (Alternate);
1124 when Constraint_Error =>
1126 Fail ("Unknown command: ", Argument (Command_Arg));
1130 -- Get the arguments from the command line and from the eventual
1131 -- argument file(s) specified on the command line.
1133 for Arg in Command_Arg + 1 .. Argument_Count loop
1135 The_Arg : constant String := Argument (Arg);
1138 -- Check if an argument file is specified
1140 if The_Arg (The_Arg'First) = '@' then
1142 Arg_File : Ada.Text_IO.File_Type;
1143 Line : String (1 .. 256);
1147 -- Open the file and fail if the file cannot be found
1152 The_Arg (The_Arg'First + 1 .. The_Arg'Last));
1157 (Standard_Error, "Cannot open argument file """);
1160 The_Arg (The_Arg'First + 1 .. The_Arg'Last));
1162 Put_Line (Standard_Error, """");
1166 -- Read line by line and put the content of each
1167 -- non empty line in the Last_Switches table.
1169 while not End_Of_File (Arg_File) loop
1170 Get_Line (Arg_File, Line, Last);
1173 Last_Switches.Increment_Last;
1174 Last_Switches.Table (Last_Switches.Last) :=
1175 new String'(Line (1 .. Last));
1183 -- It is not an argument file; just put the argument in
1184 -- the Last_Switches table.
1186 Last_Switches.Increment_Last;
1187 Last_Switches.Table (Last_Switches.Last) :=
1188 new String'(The_Arg);
1196 Program : constant String :=
1197 Program_Name (Command_List (The_Command).Unixcmd.all).all;
1199 Exec_Path : String_Access;
1202 -- First deal with built-in command(s)
1204 if The_Command = Setup then
1207 Arg_Num : Positive := 1;
1208 Argv : String_Access;
1211 while Arg_Num <= Last_Switches.Last loop
1212 Argv := Last_Switches.Table (Arg_Num);
1214 if Argv (Argv'First) /= '-' then
1215 Fail ("invalid parameter """, Argv.all, """");
1218 if Argv'Length = 1 then
1220 ("switch character cannot be followed by a blank");
1223 -- -vPx Specify verbosity while parsing project files
1226 and then Argv (Argv'First + 1 .. Argv'First + 2) = "vP"
1228 case Argv (Argv'Last) is
1230 Current_Verbosity := Prj.Default;
1232 Current_Verbosity := Prj.Medium;
1234 Current_Verbosity := Prj.High;
1236 Fail ("Invalid switch: ", Argv.all);
1239 -- -Pproject_file Specify project file to be used
1241 elsif Argv (Argv'First + 1) = 'P' then
1243 -- Only one -P switch can be used
1245 if Project_File /= null then
1248 ": second project file forbidden (first is """,
1249 Project_File.all & """)");
1251 elsif Argv'Length = 2 then
1253 -- There is space between -P and the project file
1254 -- name. -P cannot be the last option.
1256 if Arg_Num = Last_Switches.Last then
1257 Fail ("project file name missing after -P");
1260 Arg_Num := Arg_Num + 1;
1261 Argv := Last_Switches.Table (Arg_Num);
1263 -- After -P, there must be a project file name,
1264 -- not another switch.
1266 if Argv (Argv'First) = '-' then
1267 Fail ("project file name missing after -P");
1270 Project_File := new String'(Argv.all);
1275 -- No space between -P and project file name
1278 new String'(Argv (Argv'First + 2 .. Argv'Last));
1281 -- -Xexternal=value Specify an external reference to be
1282 -- used in project files
1284 elsif Argv'Length >= 5
1285 and then Argv (Argv'First + 1) = 'X'
1288 Equal_Pos : constant Natural :=
1289 Index ('=', Argv (Argv'First + 2 .. Argv'Last));
1291 if Equal_Pos >= Argv'First + 3 and then
1292 Equal_Pos /= Argv'Last then
1295 Argv (Argv'First + 2 .. Equal_Pos - 1),
1296 Value => Argv (Equal_Pos + 1 .. Argv'Last));
1300 " is not a valid external assignment.");
1304 elsif Argv.all = "-v" then
1305 Verbose_Mode := True;
1307 elsif Argv.all = "-q" then
1308 Quiet_Output := True;
1311 Fail ("invalid parameter """, Argv.all, """");
1315 Arg_Num := Arg_Num + 1;
1318 if Project_File = null then
1319 Fail ("no project file specified");
1322 Setup_Projects := True;
1324 Prj.Pars.Set_Verbosity (To => Current_Verbosity);
1326 -- Missing directories are created during processing of the
1330 (Project => Project,
1331 In_Tree => Project_Tree,
1332 Project_File_Name => Project_File.all,
1333 Packages_To_Check => All_Packages);
1335 if Project = Prj.No_Project then
1336 Fail ("""", Project_File.all, """ processing failed");
1339 -- Processing is done
1345 -- Locate the executable for the command
1347 Exec_Path := Locate_Exec_On_Path (Program);
1349 if Exec_Path = null then
1350 Put_Line (Standard_Error, "could not locate " & Program);
1354 -- If there are switches for the executable, put them as first switches
1356 if Command_List (The_Command).Unixsws /= null then
1357 for J in Command_List (The_Command).Unixsws'Range loop
1358 First_Switches.Increment_Last;
1359 First_Switches.Table (First_Switches.Last) :=
1360 Command_List (The_Command).Unixsws (J);
1364 -- For BIND, CHECK, FIND, LINK, LIST, PRETTY ad XREF, look for project
1365 -- file related switches.
1367 if The_Command = Bind
1368 or else The_Command = Check
1369 or else The_Command = Elim
1370 or else The_Command = Find
1371 or else The_Command = Link
1372 or else The_Command = List
1373 or else The_Command = Xref
1374 or else The_Command = Pretty
1375 or else The_Command = Stub
1376 or else The_Command = Metric
1380 Tool_Package_Name := Name_Binder;
1381 Packages_To_Check := Packages_To_Check_By_Binder;
1383 Tool_Package_Name := Name_Check;
1384 Packages_To_Check := Packages_To_Check_By_Check;
1386 Tool_Package_Name := Name_Eliminate;
1387 Packages_To_Check := Packages_To_Check_By_Eliminate;
1389 Tool_Package_Name := Name_Finder;
1390 Packages_To_Check := Packages_To_Check_By_Finder;
1392 Tool_Package_Name := Name_Linker;
1393 Packages_To_Check := Packages_To_Check_By_Linker;
1395 Tool_Package_Name := Name_Gnatls;
1396 Packages_To_Check := Packages_To_Check_By_Gnatls;
1398 Tool_Package_Name := Name_Metrics;
1399 Packages_To_Check := Packages_To_Check_By_Metric;
1401 Tool_Package_Name := Name_Pretty_Printer;
1402 Packages_To_Check := Packages_To_Check_By_Pretty;
1404 Tool_Package_Name := Name_Gnatstub;
1405 Packages_To_Check := Packages_To_Check_By_Gnatstub;
1407 Tool_Package_Name := Name_Cross_Reference;
1408 Packages_To_Check := Packages_To_Check_By_Xref;
1413 -- Check that the switches are consistent.
1414 -- Detect project file related switches.
1418 Arg_Num : Positive := 1;
1419 Argv : String_Access;
1421 procedure Remove_Switch (Num : Positive);
1422 -- Remove a project related switch from table Last_Switches
1428 procedure Remove_Switch (Num : Positive) is
1430 Last_Switches.Table (Num .. Last_Switches.Last - 1) :=
1431 Last_Switches.Table (Num + 1 .. Last_Switches.Last);
1432 Last_Switches.Decrement_Last;
1435 -- Start of processing for Inspect_Switches
1438 while Arg_Num <= Last_Switches.Last loop
1439 Argv := Last_Switches.Table (Arg_Num);
1441 if Argv (Argv'First) = '-' then
1442 if Argv'Length = 1 then
1444 ("switch character cannot be followed by a blank");
1447 -- The two style project files (-p and -P) cannot be used
1450 if (The_Command = Find or else The_Command = Xref)
1451 and then Argv (2) = 'p'
1453 Old_Project_File_Used := True;
1454 if Project_File /= null then
1455 Fail ("-P and -p cannot be used together");
1459 -- -vPx Specify verbosity while parsing project files
1462 and then Argv (Argv'First + 1 .. Argv'First + 2) = "vP"
1464 case Argv (Argv'Last) is
1466 Current_Verbosity := Prj.Default;
1468 Current_Verbosity := Prj.Medium;
1470 Current_Verbosity := Prj.High;
1472 Fail ("Invalid switch: ", Argv.all);
1475 Remove_Switch (Arg_Num);
1477 -- -Pproject_file Specify project file to be used
1479 elsif Argv (Argv'First + 1) = 'P' then
1481 -- Only one -P switch can be used
1483 if Project_File /= null then
1486 ": second project file forbidden (first is """,
1487 Project_File.all & """)");
1489 -- The two style project files (-p and -P) cannot be
1492 elsif Old_Project_File_Used then
1493 Fail ("-p and -P cannot be used together");
1495 elsif Argv'Length = 2 then
1497 -- There is space between -P and the project file
1498 -- name. -P cannot be the last option.
1500 if Arg_Num = Last_Switches.Last then
1501 Fail ("project file name missing after -P");
1504 Remove_Switch (Arg_Num);
1505 Argv := Last_Switches.Table (Arg_Num);
1507 -- After -P, there must be a project file name,
1508 -- not another switch.
1510 if Argv (Argv'First) = '-' then
1511 Fail ("project file name missing after -P");
1514 Project_File := new String'(Argv.all);
1519 -- No space between -P and project file name
1522 new String'(Argv (Argv'First + 2 .. Argv'Last));
1525 Remove_Switch (Arg_Num);
1527 -- -Xexternal=value Specify an external reference to be
1528 -- used in project files
1530 elsif Argv'Length >= 5
1531 and then Argv (Argv'First + 1) = 'X'
1534 Equal_Pos : constant Natural :=
1535 Index ('=', Argv (Argv'First + 2 .. Argv'Last));
1537 if Equal_Pos >= Argv'First + 3 and then
1538 Equal_Pos /= Argv'Last then
1539 Add (External_Name =>
1540 Argv (Argv'First + 2 .. Equal_Pos - 1),
1541 Value => Argv (Equal_Pos + 1 .. Argv'Last));
1545 " is not a valid external assignment.");
1549 Remove_Switch (Arg_Num);
1552 (The_Command = Check or else
1553 The_Command = Pretty or else
1554 The_Command = Metric)
1555 and then Argv'Length = 2
1556 and then Argv (2) = 'U'
1558 All_Projects := True;
1559 Remove_Switch (Arg_Num);
1562 Arg_Num := Arg_Num + 1;
1566 Arg_Num := Arg_Num + 1;
1569 end Inspect_Switches;
1572 -- If there is a project file specified, parse it, get the switches
1573 -- for the tool and setup PATH environment variables.
1575 if Project_File /= null then
1576 Prj.Pars.Set_Verbosity (To => Current_Verbosity);
1579 (Project => Project,
1580 In_Tree => Project_Tree,
1581 Project_File_Name => Project_File.all,
1582 Packages_To_Check => Packages_To_Check);
1584 if Project = Prj.No_Project then
1585 Fail ("""", Project_File.all, """ processing failed");
1588 -- Check if a package with the name of the tool is in the project
1589 -- file and if there is one, get the switches, if any, and scan them.
1592 Data : constant Prj.Project_Data :=
1593 Project_Tree.Projects.Table (Project);
1595 Pkg : constant Prj.Package_Id :=
1597 (Name => Tool_Package_Name,
1598 In_Packages => Data.Decl.Packages,
1599 In_Tree => Project_Tree);
1601 Element : Package_Element;
1603 Default_Switches_Array : Array_Element_Id;
1605 The_Switches : Prj.Variable_Value;
1606 Current : Prj.String_List_Id;
1607 The_String : String_Element;
1610 if Pkg /= No_Package then
1611 Element := Project_Tree.Packages.Table (Pkg);
1613 -- Packages Gnatls has a single attribute Switches, that is
1614 -- not an associative array.
1616 if The_Command = List then
1619 (Variable_Name => Snames.Name_Switches,
1620 In_Variables => Element.Decl.Attributes,
1621 In_Tree => Project_Tree);
1623 -- Packages Binder (for gnatbind), Cross_Reference (for
1624 -- gnatxref), Linker (for gnatlink) Finder (for gnatfind),
1625 -- Pretty_Printer (for gnatpp) Eliminate (for gnatelim),
1626 -- Check (for gnatcheck) and Metric (for gnatmetric) have
1627 -- an attributed Switches, an associative array, indexed
1628 -- by the name of the file.
1630 -- They also have an attribute Default_Switches, indexed
1631 -- by the name of the programming language.
1634 if The_Switches.Kind = Prj.Undefined then
1635 Default_Switches_Array :=
1637 (Name => Name_Default_Switches,
1638 In_Arrays => Element.Decl.Arrays,
1639 In_Tree => Project_Tree);
1640 The_Switches := Prj.Util.Value_Of
1643 In_Array => Default_Switches_Array,
1644 In_Tree => Project_Tree);
1648 -- If there are switches specified in the package of the
1649 -- project file corresponding to the tool, scan them.
1651 case The_Switches.Kind is
1652 when Prj.Undefined =>
1657 Switch : constant String :=
1658 Get_Name_String (The_Switches.Value);
1661 if Switch'Length > 0 then
1662 First_Switches.Increment_Last;
1663 First_Switches.Table (First_Switches.Last) :=
1664 new String'(Switch);
1669 Current := The_Switches.Values;
1670 while Current /= Prj.Nil_String loop
1671 The_String := Project_Tree.String_Elements.
1675 Switch : constant String :=
1676 Get_Name_String (The_String.Value);
1679 if Switch'Length > 0 then
1680 First_Switches.Increment_Last;
1681 First_Switches.Table (First_Switches.Last) :=
1682 new String'(Switch);
1686 Current := The_String.Next;
1692 if The_Command = Bind
1693 or else The_Command = Link
1694 or else The_Command = Elim
1698 (Project_Tree.Projects.Table
1699 (Project).Object_Directory));
1702 -- Set up the env vars for project path files
1704 Prj.Env.Set_Ada_Paths
1705 (Project, Project_Tree, Including_Libraries => False);
1707 -- For gnatcheck, gnatstub, gnatmetric, gnatpp and gnatelim, create
1708 -- a configuration pragmas file, if necessary.
1710 if The_Command = Pretty
1711 or else The_Command = Metric
1712 or else The_Command = Stub
1713 or else The_Command = Elim
1714 or else The_Command = Check
1716 -- If there are switches in package Compiler, put them in the
1717 -- Carg_Switches table.
1720 Data : constant Prj.Project_Data :=
1721 Project_Tree.Projects.Table (Project);
1723 Pkg : constant Prj.Package_Id :=
1725 (Name => Name_Compiler,
1726 In_Packages => Data.Decl.Packages,
1727 In_Tree => Project_Tree);
1729 Element : Package_Element;
1731 Default_Switches_Array : Array_Element_Id;
1733 The_Switches : Prj.Variable_Value;
1734 Current : Prj.String_List_Id;
1735 The_String : String_Element;
1738 if Pkg /= No_Package then
1739 Element := Project_Tree.Packages.Table (Pkg);
1741 Default_Switches_Array :=
1743 (Name => Name_Default_Switches,
1744 In_Arrays => Element.Decl.Arrays,
1745 In_Tree => Project_Tree);
1746 The_Switches := Prj.Util.Value_Of
1749 In_Array => Default_Switches_Array,
1750 In_Tree => Project_Tree);
1752 -- If there are switches specified in the package of the
1753 -- project file corresponding to the tool, scan them.
1755 case The_Switches.Kind is
1756 when Prj.Undefined =>
1761 Switch : constant String :=
1762 Get_Name_String (The_Switches.Value);
1765 if Switch'Length > 0 then
1766 Add_To_Carg_Switches (new String'(Switch));
1771 Current := The_Switches.Values;
1772 while Current /= Prj.Nil_String loop
1774 Project_Tree.String_Elements.Table (Current);
1777 Switch : constant String :=
1778 Get_Name_String (The_String.Value);
1780 if Switch'Length > 0 then
1781 Add_To_Carg_Switches (new String'(Switch));
1785 Current := The_String.Next;
1791 -- If -cargs is one of the switches, move the following switches
1792 -- to the Carg_Switches table.
1794 for J in 1 .. First_Switches.Last loop
1795 if First_Switches.Table (J).all = "-cargs" then
1796 for K in J + 1 .. First_Switches.Last loop
1797 Add_To_Carg_Switches (First_Switches.Table (K));
1799 First_Switches.Set_Last (J - 1);
1804 for J in 1 .. Last_Switches.Last loop
1805 if Last_Switches.Table (J).all = "-cargs" then
1806 for K in J + 1 .. Last_Switches.Last loop
1807 Add_To_Carg_Switches (Last_Switches.Table (K));
1809 Last_Switches.Set_Last (J - 1);
1815 CP_File : constant Name_Id := Configuration_Pragmas_File;
1818 if CP_File /= No_Name then
1819 if The_Command = Elim then
1820 First_Switches.Increment_Last;
1821 First_Switches.Table (First_Switches.Last) :=
1822 new String'("-C" & Get_Name_String (CP_File));
1825 Add_To_Carg_Switches
1826 (new String'("-gnatec=" & Get_Name_String (CP_File)));
1832 if The_Command = Link then
1836 if The_Command = Link or The_Command = Bind then
1838 -- For files that are specified as relative paths with directory
1839 -- information, we convert them to absolute paths, with parent
1840 -- being the current working directory if specified on the command
1841 -- line and the project directory if specified in the project
1842 -- file. This is what gnatmake is doing for linker and binder
1845 for J in 1 .. Last_Switches.Last loop
1846 Test_If_Relative_Path
1847 (Last_Switches.Table (J), Current_Work_Dir);
1851 (Project_Tree.Projects.Table (Project).Directory);
1854 Project_Dir : constant String := Name_Buffer (1 .. Name_Len);
1856 for J in 1 .. First_Switches.Last loop
1857 Test_If_Relative_Path
1858 (First_Switches.Table (J), Project_Dir);
1862 elsif The_Command = Stub then
1864 Data : constant Prj.Project_Data :=
1865 Project_Tree.Projects.Table (Project);
1866 File_Index : Integer := 0;
1867 Dir_Index : Integer := 0;
1868 Last : constant Integer := Last_Switches.Last;
1871 for Index in 1 .. Last loop
1872 if Last_Switches.Table (Index)
1873 (Last_Switches.Table (Index)'First) /= '-'
1875 File_Index := Index;
1880 -- If the naming scheme of the project file is not standard,
1881 -- and if the file name ends with the spec suffix, then
1882 -- indicate to gnatstub the name of the body file with
1885 if Data.Naming.Ada_Spec_Suffix /=
1886 Prj.Default_Ada_Spec_Suffix
1888 if File_Index /= 0 then
1890 Spec : constant String :=
1891 Base_Name (Last_Switches.Table (File_Index).all);
1892 Last : Natural := Spec'Last;
1895 Get_Name_String (Data.Naming.Ada_Spec_Suffix);
1897 if Spec'Length > Name_Len
1898 and then Spec (Last - Name_Len + 1 .. Last) =
1899 Name_Buffer (1 .. Name_Len)
1901 Last := Last - Name_Len;
1902 Get_Name_String (Data.Naming.Ada_Body_Suffix);
1903 Last_Switches.Increment_Last;
1904 Last_Switches.Table (Last_Switches.Last) :=
1906 Last_Switches.Increment_Last;
1907 Last_Switches.Table (Last_Switches.Last) :=
1908 new String'(Spec (Spec'First .. Last) &
1909 Name_Buffer (1 .. Name_Len));
1915 -- Add the directory of the spec as the destination directory
1916 -- of the body, if there is no destination directory already
1919 if File_Index /= 0 then
1920 for Index in File_Index + 1 .. Last loop
1921 if Last_Switches.Table (Index)
1922 (Last_Switches.Table (Index)'First) /= '-'
1929 if Dir_Index = 0 then
1930 Last_Switches.Increment_Last;
1931 Last_Switches.Table (Last_Switches.Last) :=
1933 (Dir_Name (Last_Switches.Table (File_Index).all));
1939 -- For gnatmetric, the generated files should be put in the object
1940 -- directory. This must be the first switch, because it may be
1941 -- overriden by a switch in package Metrics in the project file or by
1942 -- a command line option.
1944 if The_Command = Metric then
1945 First_Switches.Increment_Last;
1946 First_Switches.Table (2 .. First_Switches.Last) :=
1947 First_Switches.Table (1 .. First_Switches.Last - 1);
1948 First_Switches.Table (1) :=
1951 (Project_Tree.Projects.Table
1952 (Project).Object_Directory));
1955 -- For gnat check, gnat pretty, gnat metric ands gnat list,
1956 -- if no file has been put on the command line, call tool with all
1957 -- the sources of the main project.
1959 if The_Command = Check or else
1960 The_Command = Pretty or else
1961 The_Command = Metric or else
1968 -- Gather all the arguments and invoke the executable
1971 The_Args : Argument_List
1972 (1 .. First_Switches.Last +
1973 Last_Switches.Last +
1974 Carg_Switches.Last);
1975 Arg_Num : Natural := 0;
1978 for J in 1 .. First_Switches.Last loop
1979 Arg_Num := Arg_Num + 1;
1980 The_Args (Arg_Num) := First_Switches.Table (J);
1983 for J in 1 .. Last_Switches.Last loop
1984 Arg_Num := Arg_Num + 1;
1985 The_Args (Arg_Num) := Last_Switches.Table (J);
1988 for J in 1 .. Carg_Switches.Last loop
1989 Arg_Num := Arg_Num + 1;
1990 The_Args (Arg_Num) := Carg_Switches.Table (J);
1993 -- If Display_Command is on, only display the generated command
1995 if Display_Command then
1996 Put (Standard_Error, "generated command -->");
1997 Put (Standard_Error, Exec_Path.all);
1999 for Arg in The_Args'Range loop
2000 Put (Standard_Error, " ");
2001 Put (Standard_Error, The_Args (Arg).all);
2004 Put (Standard_Error, "<--");
2005 New_Line (Standard_Error);
2009 if Verbose_Mode then
2010 Output.Write_Str (Exec_Path.all);
2012 for Arg in The_Args'Range loop
2013 Output.Write_Char (' ');
2014 Output.Write_Str (The_Args (Arg).all);
2021 Exit_Status (Spawn (Exec_Path.all, The_Args));
2028 Prj.Env.Delete_All_Path_Files (Project_Tree);
2029 Delete_Temp_Config_Files;
2030 Set_Exit_Status (Failure);
2033 Prj.Env.Delete_All_Path_Files (Project_Tree);
2034 Delete_Temp_Config_Files;
2036 -- Since GNATCmd is normally called from DCL (the VMS shell), it must
2037 -- return an understandable VMS exit status. However the exit status
2038 -- returned *to* GNATCmd is a Posix style code, so we test it and return
2039 -- just a simple success or failure on VMS.
2041 if Hostparm.OpenVMS and then My_Exit_Status /= Success then
2042 Set_Exit_Status (Failure);
2044 Set_Exit_Status (My_Exit_Status);