diff options
Diffstat (limited to 'gcc/ada/make.adb')
-rw-r--r-- | gcc/ada/make.adb | 91 |
1 files changed, 88 insertions, 3 deletions
diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index 9aa812a2356..4f09513fe4a 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -432,6 +432,9 @@ package body Make is -- with the switches -c, -b and -l. These flags are reset to True for -- each invocation of procedure Gnatmake. + Do_Codepeer_Globalize_Step : Boolean := False; + -- Flag to indicate whether the CodePeer globalizer should be called + Shared_String : aliased String := "-shared"; Force_Elab_Flags_String : aliased String := "-F"; @@ -654,20 +657,27 @@ package body Make is Gnatlink : String_Access := Program_Name ("gnatlink", "gnatmake"); -- Default compiler, binder, linker programs + Globalizer : constant String := "codepeer_globalizer"; + -- CodePeer globalizer executable name + Saved_Gcc : String_Access := null; Saved_Gnatbind : String_Access := null; Saved_Gnatlink : String_Access := null; -- Given by the command line. Will be used, if non null Gcc_Path : String_Access := - GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all); + GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all); Gnatbind_Path : String_Access := - GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all); + GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all); Gnatlink_Path : String_Access := - GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all); + GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all); -- Path for compiler, binder, linker programs, defaulted now for gnatdist. -- Changed later if overridden on command line. + Globalizer_Path : constant String_Access := + GNAT.OS_Lib.Locate_Exec_On_Path (Globalizer); + -- Path for CodePeer globalizer + Comp_Flag : constant String_Access := new String'("-c"); Output_Flag : constant String_Access := new String'("-o"); Ada_Flag_1 : constant String_Access := new String'("-x"); @@ -1007,6 +1017,10 @@ package body Make is -- during a compilation are also transitively included in the W section -- of the originally compiled file. + procedure Globalize (Success : out Boolean); + -- Call the CodePeer globalizer on all the project's object directories, + -- or on the current directory if no projects. + procedure Initialize (Project_Node_Tree : out Project_Node_Tree_Ref); -- Performs default and package initialization. Therefore, -- Compile_Sources can be called by an external unit. @@ -2885,6 +2899,13 @@ package body Make is Do_Bind_Step := False; Do_Link_Step := False; Syntax_Only := False; + + elsif Args (J).all = "-gnatC" + or else Args (J).all = "-gnatcC" + then + -- If we compile with -gnatC, enable CodePeer globalize step + + Do_Codepeer_Globalize_Step := True; end if; end loop; @@ -4111,6 +4132,53 @@ package body Make is Obsoleted.Set (F2, True); end Enter_Into_Obsoleted; + --------------- + -- Globalize -- + --------------- + + procedure Globalize (Success : out Boolean) is + Quiet_Str : aliased String := "-quiet"; + Globalizer_Args : constant Argument_List := + (1 => Quiet_Str'Unchecked_Access); + Previous_Dir : String_Access; + + procedure Globalize_Dir (Dir : String); + -- Call CodePeer globalizer on Dir + + ------------------- + -- Globalize_Dir -- + ------------------- + + procedure Globalize_Dir (Dir : String) is + Result : Boolean; + begin + if Previous_Dir = null or else Dir /= Previous_Dir.all then + Free (Previous_Dir); + Previous_Dir := new String'(Dir); + Change_Dir (Dir); + GNAT.OS_Lib.Spawn (Globalizer_Path.all, Globalizer_Args, Result); + Success := Success and Result; + end if; + end Globalize_Dir; + + procedure Globalize_Dirs is new + Prj.Env.For_All_Object_Dirs (Globalize_Dir); + + begin + Success := True; + Display (Globalizer, Globalizer_Args); + + if Globalizer_Path = null then + Make_Failed ("error, unable to locate " & Globalizer); + end if; + + if Main_Project = No_Project then + GNAT.OS_Lib.Spawn (Globalizer_Path.all, Globalizer_Args, Success); + else + Globalize_Dirs (Main_Project); + end if; + end Globalize; + -------------- -- Gnatmake -- -------------- @@ -6387,6 +6455,23 @@ package body Make is Delete_All_Marks; end loop Multiple_Main_Loop; + if Do_Codepeer_Globalize_Step then + declare + Success : Boolean := False; + begin + Globalize (Success); + + if not Success then + Set_Standard_Error; + Write_Str ("*** globalize failed."); + + if Commands_To_Stdout then + Set_Standard_Output; + end if; + end if; + end; + end if; + if Failed_Links.Last > 0 then for Index in 1 .. Successful_Links.Last loop Write_Str ("Linking of """); |