1------------------------------------------------------------------------------ 2-- -- 3-- GNATMETRIC COMPONENTS -- 4-- -- 5-- A S I S _ U L . S O U R C E _ T A B L E . P R O C E S S I N G . -- 6-- F I N A L I Z E -- 7-- -- 8-- (adapted for gnatpp from ASIS Utility Library) -- 9-- -- 10-- B o d y -- 11-- -- 12-- Copyright (C) 2014-2015, AdaCore -- 13-- -- 14-- GNATPP is free software; you can redistribute it and/or modify it under -- 15-- terms of the GNU General Public License as published by the Free Soft- -- 16-- ware Foundation; either version 2, or (at your option) any later ver- -- 17-- sion. GNATPP is distributed in the hope that it will be useful, but -- 18-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABI- -- 19-- LITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 20-- License for more details. You should have received a copy of the GNU -- 21-- General Public License distributed with GNAT; see file COPYING. If not, -- 22-- write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- 23-- Boston, MA 02110-1301, USA. -- 24-- -- 25-- GNATPP is maintained by AdaCore (http://www.adacore.com) -- 26-- -- 27------------------------------------------------------------------------------ 28 29with Text_IO; use Text_IO; 30with GNAT.OS_Lib; 31 32with ASIS_UL.String_Utilities; use ASIS_UL.String_Utilities; 33with GNATPP.Options; use GNATPP.Options; 34 35separate (ASIS_UL.Source_Table.Processing) 36procedure Finalize is 37 -- See also comments on File_Name_File_Name in GNATPP.Options. 38 39 -- If this is the outer process of an incremental build, or it is a 40 -- non-incremental build, we move all the temp files to the output files. 41 -- We don't need any file locking here, because all the inner processes 42 -- that were writing to the File_Name_File have finished. 43 44 File_Name_File : File_Type; 45 Success : Boolean; 46 pragma Unreferenced (Success); 47 Count : Natural := 0; -- number of files moved 48begin 49 if not Mimic_gcc then 50 Open (File_Name_File, In_File, Name => File_Name_File_Name.all); 51 52 -- The File_Name_File contains an initial blank line, due to Text_IO 53 -- weirdness, so we need to discard it. 54 55 declare 56 Discard : constant String := Get_Line (File_Name_File); 57 pragma Unreferenced (Discard); 58 begin 59 null; 60 end; 61 62 -- Read pairs of lines from the file name file, and do the moves. 63 64 while not End_Of_File (File_Name_File) loop 65 Count := Count + 1; 66 declare 67 Temp_Output_Name : constant String := Get_Line (File_Name_File); 68 Output_Name : constant String := Get_Line (File_Name_File); 69 begin 70 Move_File (Old_Name => Temp_Output_Name, New_Name => Output_Name); 71 end; 72 end loop; 73 74 Close (File_Name_File); 75 76 if not Debug_Flag_N then 77 GNAT.OS_Lib.Delete_File (File_Name_File_Name.all, Success); 78 -- No point in complaining if Success is False 79 end if; 80 81 if Incremental_Mode and then Count = 0 then 82 Put_Line ("files are up to date"); 83 end if; 84 end if; 85end Finalize; 86